Flow123d
JS_before_hm-1709-g5393e92e3
src
input
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
26
PathBase::PathBase
() {
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
56
void
PathBase::go_to_root
() {
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
Input
Abstract linear system class.
Definition:
balance.hh:40
std::vector
Definition:
doxy_dummy_defs.hh:7
Input::PathBase::PathBase
PathBase()
Forbid default constructor.
Definition:
path_base.cc:26
Input::PathBase::as_string
std::string as_string() const
Returns string address of current position.
Definition:
path_base.cc:48
Input::PathBase::go_to_root
void go_to_root()
Move to root node.
Definition:
path_base.cc:56
Input::PathBase::get_node_type
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
input_exception.hh
Input::Type
Definition:
balance.hh:41
path_base.hh
Input::PathBase::output
void output(std::ostream &stream) const
Output to the given stream.
Definition:
path_base.cc:31
std
Definition:
doxy_dummy_defs.hh:5
Generated by
1.8.17