Flow123d  release_3.0.0-869-g0e4dab6
path_base.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file path_base.cc
15  * @brief
16  */
17 
18 #include "input/path_base.hh"
19 #include "input/input_exception.hh"
20 
21 
22 namespace Input {
23 using namespace std;
24 
25 
27  path_.push_back( make_pair( (int)(-1), string("/") ) );
28 }
29 
30 
31 void PathBase::output(ostream &stream) const {
32  if (level() == 0) {
33  stream << "/";
34  return;
35  }
36 
37  for(vector< pair<int, string> >::const_iterator it = path_.begin()+1; it != path_.end(); ++it) {
38  if ( it->second == "" ) {
39  stream << "/" << it->first;
40  } else {
41  stream << "/" << it->second;
42  }
43  }
44 }
45 
46 
47 
48 string PathBase::as_string() const {
49  stringstream ss;
50  output(ss);
51  return ss.str();
52 }
53 
54 
55 
57  while (path_.size() > 1) {
58  this->up();
59  }
60 }
61 
62 
63 
64 std::string PathBase::get_node_type(unsigned int type_idx) const {
65  return json_type_names[ type_idx ];
66 }
67 
68 
69 
70 } // namespace Input
Abstract linear system class.
Definition: balance.hh:35
std::string as_string() const
Returns string address of current position.
Definition: path_base.cc:48
PathBase()
Forbid default constructor.
Definition: path_base.cc:26
std::string get_node_type(unsigned int type_idx) const
Get short string description of node type, method is used for printout of messages.
Definition: path_base.cc:64
void go_to_root()
Move to root node.
Definition: path_base.cc:56
void output(std::ostream &stream) const
Output to the given stream.
Definition: path_base.cc:31