libept
Main Page
Namespaces
Classes
Files
File List
File Members
ept
core
apt
core/apt/recordparser.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
#ifndef EPT_CORE_APT_RECORDPARSER_H
3
#define EPT_CORE_APT_RECORDPARSER_H
4
9
/*
10
* Copyright (C) 2007 Enrico Zini <enrico@enricozini.org>
11
*
12
* This library is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU Lesser General Public
14
* License as published by the Free Software Foundation; either
15
* version 2.1 of the License, or (at your option) any later version.
16
*
17
* This library is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
* Lesser General Public License for more details.
21
*
22
* You should have received a copy of the GNU Lesser General Public
23
* License along with this library; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
*/
26
27
#include <vector>
28
#include <string>
29
30
namespace
ept {
31
namespace
core {
32
namespace
record {
33
40
class
RecordParser
41
{
43
std::string buffer;
44
46
std::vector<size_t> ends;
47
49
std::vector<size_t> sorted;
50
51
public
:
52
RecordParser
() {}
53
RecordParser
(
const
std::string& str) {
scan
(str); }
54
56
void
scan
(
const
std::string& str);
57
63
size_t
index
(
const
std::string& str)
const
;
64
66
std::string
field
(
size_t
idx)
const
;
67
69
std::string
name
(
size_t
idx)
const
;
70
72
std::string
lookup
(
size_t
idx)
const
;
73
75
std::string
lookup
(
const
std::string&
name
)
const
{
return
lookup
(
index
(name)); }
76
78
std::string
operator[]
(
size_t
idx)
const
{
return
lookup
(idx); }
79
81
std::string
operator[]
(
const
std::string&
name
)
const
{
return
lookup
(name); }
82
84
const
std::string&
record
()
const
{
return
buffer; }
85
87
std::string
record
() {
return
buffer; }
88
90
size_t
size
()
const
{
return
ends.size(); }
91
};
92
93
}
94
}
95
}
96
97
// vim:set ts=4 sw=4:
98
#endif
Generated on Tue Dec 31 2013 18:17:27 for libept by
1.8.1.2