Go to the documentation of this file.00001 #ifndef EPT_APT_RECORDPARSER_H
00002 #define EPT_APT_RECORDPARSER_H
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <vector>
00027 #include <string>
00028
00029 namespace ept {
00030 namespace apt {
00031
00038 class RecordParser
00039 {
00041 std::string buffer;
00042
00044 std::vector<size_t> ends;
00045
00047 std::vector<size_t> sorted;
00048
00049 public:
00050 RecordParser() {}
00051 RecordParser(const std::string& str) { scan(str); }
00052
00054 void scan(const std::string& str);
00055
00061 size_t index(const std::string& str) const;
00062
00064 std::string field(size_t idx) const;
00065
00067 std::string name(size_t idx) const;
00068
00070 std::string lookup(size_t idx) const;
00071
00073 std::string lookup(const std::string& name) const { return lookup(index(name)); }
00074
00076 std::string operator[](size_t idx) const { return lookup(idx); }
00077
00079 std::string operator[](const std::string& name) const { return lookup(name); }
00080
00082 const std::string& record() const { return buffer; }
00083
00085 std::string record() { return buffer; }
00086
00088 size_t size() const { return ends.size(); }
00089 };
00090
00091 }
00092 }
00093
00094
00095 #endif