OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
info_handle.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-2011 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 /*
23  high level info interface
24 
25  Author: Ansgar Philippsen
26 */
27 
28 #ifndef OST_DATA_INFO_H
29 #define OST_DATA_INFO_H
30 
31 #include <ost/base.hh>
32 
33 #include "info_path.hh"
34 #include "info_fw.hh"
35 
36 namespace ost { namespace info {
37 
38 class InfoHandle;
39 
41 DLLEXPORT InfoHandle CreateInfo();
42 DLLEXPORT InfoHandle CreateInfo(const String& dtdfile);
43 
45 DLLEXPORT InfoHandle LoadInfo(const String& file);
46 
47 
49 
55  friend InfoHandle CreateInfo();
56  friend InfoHandle CreateInfo(const String& text);
57  friend InfoHandle LoadInfo(const String&);
58 
59  typedef std::vector<RootPtr> RootPtrList;
60 public:
62  InfoHandle();
63 
65  InfoHandle Copy() const;
66 
68  void Import(const String& file);
69 
71  void Export(const String& file) const;
72 
73  bool IsValid() const;
74 
75  InfoGroup Root() const;
76 
77  void AddDefault(const InfoHandle& h);
78 
79  bool HasDefaultGroup(const InfoPath& p) const;
80  InfoGroup GetDefaultGroup(const InfoPath& p) const;
81 
82  bool HasDefaultItem(const InfoPath& p) const;
83  InfoItem GetDefaultItem(const InfoPath& p) const;
84 
86  InfoGroup GetParent() const;
87  void SetName(const String& name);
88  String GetName() const;
89  InfoGroup GetGroup(const InfoPath& path, bool use_defaults=true) const;
90  InfoGroup CreateGroup(const String& name);
91  bool HasGroup(const InfoPath& name, bool use_defaults=true) const;
92  InfoGroup RetrieveGroup(const InfoPath& path, bool use_defaults=true);
93  InfoItem GetItem(const InfoPath& path, bool use_defaults=true) const;
94  InfoItem CreateItem(const String& name, const String& value);
95  bool HasItem(const InfoPath& path, bool use_defaults=true) const;
96  InfoItem RetrieveItem(const InfoPath& path, bool use_defaults=true);
97  void Remove(const InfoPath& path, bool remove_defaults=false);
98  void Remove(const InfoGroup& group);
99  String GetAttribute(const String& name) const;
100  void SetAttribute(const String& name, const String& value);
101  bool HasAttribute(const String& name) const;
102  void RemoveAttribute(const String& name);
103  std::vector<String> GetAttributeList() const;
104  String GetTextData() const;
105  void SetTextData(const String& td);
106  void Apply(InfoVisitor& v, bool visit_this=true);
107  void Apply(InfoConstVisitor& v, bool visit_this=true) const;
108 
109 
110 private:
111  InfoHandle(RootPtr impl);
112 
113  RootPtr impl_;
114 };
115 
116 }} // ns
117 
118 #endif
std::vector< RootPtr > RootPtrList
Definition: info_impl_fw.hh:41
#define DLLEXPORT_OST_INFO
std::string String
Definition: base.hh:54
boost::shared_ptr< detail::InfoImpl > RootPtr
Definition: info_impl_fw.hh:40
DLLEXPORT InfoHandle LoadInfo(const String &file)
Load InfoHandle from a file.
main info handle
Definition: info_handle.hh:54
DLLEXPORT InfoHandle CreateInfo()
Create InfoHandle from scratch.
encapsulates path to info groups and items
Definition: info_path.hh:44