00001
00002 #ifndef EPT_CORE_APT_RECORDPARSER_H
00003 #define EPT_CORE_APT_RECORDPARSER_H
00004
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <vector>
00028 #include <string>
00029
00030 namespace ept {
00031 namespace core {
00032 namespace record {
00033
00040 class RecordParser
00041 {
00043 std::string buffer;
00044
00046 std::vector<size_t> ends;
00047
00049 std::vector<size_t> sorted;
00050
00051 public:
00052 RecordParser() {}
00053 RecordParser(const std::string& str) { scan(str); }
00054
00056 void scan(const std::string& str);
00057
00063 size_t index(const std::string& str) const;
00064
00066 std::string field(size_t idx) const;
00067
00069 std::string name(size_t idx) const;
00070
00072 std::string lookup(size_t idx) const;
00073
00075 std::string lookup(const std::string& name) const { return lookup(index(name)); }
00076
00078 std::string operator[](size_t idx) const { return lookup(idx); }
00079
00081 std::string operator[](const std::string& name) const { return lookup(name); }
00082
00084 const std::string& record() const { return buffer; }
00085
00087 std::string record() { return buffer; }
00088
00090 size_t size() const { return ends.size(); }
00091 };
00092
00093 }
00094 }
00095 }
00096
00097
00098 #endif