OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
info_path.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  info path
23 
24  Author: Ansgar Philippsen
25 */
26 
27 #include <vector>
28 #include <iostream>
29 
30 #include <ost/base.hh>
31 
33 
34 
35 namespace ost { namespace info {
36 
38 
45 friend InfoPath operator+(const InfoPath& p1, const InfoPath& p2);
46 public:
48  InfoPath(const String& p);
49  InfoPath(const char* cp);
50 
52  std::vector<String> GetList() const {return list_;}
53 
55  bool IsRelative() const {return relative_flag_;}
56 
58  String Leaf() const { return list_.empty() ? "" : list_.back(); }
59 
61  InfoPath Strip() const;
62 
63 private:
64  InfoPath(const std::vector<String> lst,bool rf);
65 
66  std::vector<String> list_;
67  bool relative_flag_;
68 
69  void init(const String& path);
70 };
71 
72 DLLEXPORT_OST_INFO std::ostream& operator<<(std::ostream&, const InfoPath& p);
73 #ifndef _MSC_VER
74 DLLEXPORT_OST_INFO InfoPath operator+(const InfoPath& p1, const InfoPath& p2);
75 #endif
76 
77 }} // ns
#define DLLEXPORT_OST_INFO
std::string String
Definition: base.hh:54
String Leaf() const
return last path element
Definition: info_path.hh:58
bool IsRelative() const
returns true if this path is relative
Definition: info_path.hh:55
DLLEXPORT_OST_INFO InfoPath operator+(const InfoPath &p1, const InfoPath &p2)
DLLEXPORT_OST_INFO std::ostream & operator<<(std::ostream &, const InfoPath &p)
std::vector< String > GetList() const
retrieve list of path elements
Definition: info_path.hh:52
encapsulates path to info groups and items
Definition: info_path.hh:44