g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::columns::parser Class Reference
Inheritance diagram for tools::columns::parser:
Inheritance graph
[legend]
Collaboration diagram for tools::columns::parser:
Collaboration graph
[legend]

Public Member Functions

 parser ()
 
virtual ~parser ()
 
bool parse (const std::string &a_s)
 
void dump (std::ostream &a_out)
 

Protected Member Functions

 parser (const parser &)
 
parseroperator= (const parser &)
 

Protected Attributes

tree m_top
 

Detailed Description

Definition at line 65 of file columns.

Constructor & Destructor Documentation

◆ parser() [1/2]

tools::columns::parser::parser ( )
inline

Definition at line 67 of file columns.

67 :m_top(0,""){}

◆ ~parser()

virtual tools::columns::parser::~parser ( )
inlinevirtual

Definition at line 68 of file columns.

68 {m_top.clear();}

◆ parser() [2/2]

tools::columns::parser::parser ( const parser )
inlineprotected

Definition at line 70 of file columns.

70 :m_top(0,"") {}

Member Function Documentation

◆ dump()

void tools::columns::parser::dump ( std::ostream &  a_out)
inline

Definition at line 111 of file columns.

111 {m_top.dump_tree(a_out,"");}

◆ operator=()

parser& tools::columns::parser::operator= ( const parser )
inlineprotected

Definition at line 71 of file columns.

71 {return *this;}

◆ parse()

bool tools::columns::parser::parse ( const std::string &  a_s)
inline

Definition at line 73 of file columns.

73  {
74  m_top.clear();
75  tree* prev = &m_top;
76  {std::string s;
77  for(std::string::const_iterator it=a_s.begin();;++it) {
78  if(it==a_s.end()) {
79  if(s.size()) {
80  new tree(prev,s);
81  s.clear();
82  }
83  break;
84  } else {
85  const char& c = *it;
86  if(c==',') {
87  if(s.size()) {
88  new tree(prev,s);
89  s.clear();
90  }
91  } else if(c=='{') {
92  tree* _tree = new tree(prev,s);
93  s.clear();
94 
95  prev = _tree;
96  } else if(c=='}') {
97  if(s.size()) {
98  new tree(prev,s);
99  s.clear();
100  }
101  prev = prev->m_parent;
102  if(!prev) return false; //should not happen.
103  } else {
104  s += c;
105  }
106  }
107  }}
108  return true;
109  }

Member Data Documentation

◆ m_top

tree tools::columns::parser::m_top
protected

Definition at line 113 of file columns.


The documentation for this class was generated from the following file:
tools::columns::tree::clear
void clear()
Definition: columns:42
tools::columns::tree::dump_tree
void dump_tree(std::ostream &a_out, const std::string &a_margin)
Definition: columns:46
tools::columns::parser::m_top
tree m_top
Definition: columns:113