Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
Parser Class Reference

#include <parser.h>

Public Member Functions

 Parser (const std::string &d, char t)
 
std::vector< std::string > Find (const std::string &tag)
 
std::string Find (const std::string &tag, size_t index, std::string value="")
 

Private Attributes

std::multimap< std::string, std::string > mmap
 

Detailed Description

Definition at line 10 of file parser.h.

Constructor & Destructor Documentation

◆ Parser()

Parser::Parser ( const std::string & d,
char t )

Definition at line 7 of file parser.cc.

8{
9 std::istringstream iss(d);
10 std::string token;
11
12 while (std::getline(iss, token, t)) {
13 boost::algorithm::trim(token);
14 size_t pos = token.find('=');
15 std::string key = token.substr(0, pos);
16 std::string value = token.substr(pos + 1);
17 boost::algorithm::trim(key);
18 boost::algorithm::trim(value);
19 mmap.insert(std::pair<std::string, std::string>(key, value));
20 }
21}
std::multimap< std::string, std::string > mmap
Definition parser.h:23

Member Function Documentation

◆ Find() [1/2]

std::vector< std::string > Parser::Find ( const std::string & tag)

Definition at line 23 of file parser.cc.

24{
26 auto i = mmap.equal_range(tag);
27 for (auto it = i.first; it != i.second; ++it) {
28 r.push_back(it->second);
29 }
30
31 return r;
32}

◆ Find() [2/2]

std::string Parser::Find ( const std::string & tag,
size_t index,
std::string value = "" )

Definition at line 34 of file parser.cc.

36{
38
39 if (result.size() > index) {
40 return result[index];
41 }
42 return value;
43}
std::vector< std::string > Find(const std::string &tag)
Definition parser.cc:23

Member Data Documentation

◆ mmap

std::multimap<std::string, std::string> Parser::mmap
private

Definition at line 23 of file parser.h.


The documentation for this class was generated from the following files: