OpenStructure
Loading...
Searching...
No Matches
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-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/*
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
36namespace ost { namespace info {
37
38class InfoHandle;
39
42DLLEXPORT InfoHandle CreateInfo(const String& dtdfile);
43
45DLLEXPORT InfoHandle LoadInfo(const String& file);
46
47
49
56 friend InfoHandle CreateInfo(const String& text);
57 friend InfoHandle LoadInfo(const String&);
58
59 typedef std::vector<RootPtr> RootPtrList;
60public:
63
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;
81
82 bool HasDefaultItem(const InfoPath& p) const;
84
87 void SetName(const String& name);
88 String GetName() const;
89 InfoGroup GetGroup(const InfoPath& path, bool use_defaults=true) const;
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;
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
110private:
111 InfoHandle(RootPtr impl);
112
113 RootPtr impl_;
114};
115
116}} // ns
117
118#endif
main info handle
void Remove(const InfoGroup &group)
String GetTextData() const
friend InfoHandle CreateInfo()
Create InfoHandle from scratch.
bool HasAttribute(const String &name) const
InfoHandle()
empty, ie invalid handle
void Import(const String &file)
generate info from file
String GetName() const
std::vector< String > GetAttributeList() const
bool HasGroup(const InfoPath &name, bool use_defaults=true) const
InfoGroup GetGroup(const InfoPath &path, bool use_defaults=true) const
bool HasItem(const InfoPath &path, bool use_defaults=true) const
InfoHandle Copy() const
return clone of the underlying representation
InfoGroup RetrieveGroup(const InfoPath &path, bool use_defaults=true)
InfoItem GetDefaultItem(const InfoPath &p) const
void SetTextData(const String &td)
void Export(const String &file) const
write content to file
void AddDefault(const InfoHandle &h)
void RemoveAttribute(const String &name)
friend InfoHandle CreateInfo(const String &text)
InfoGroup GetParent() const
group interface
void Apply(InfoVisitor &v, bool visit_this=true)
InfoGroup GetDefaultGroup(const InfoPath &p) const
bool HasDefaultGroup(const InfoPath &p) const
String GetAttribute(const String &name) const
void Remove(const InfoPath &path, bool remove_defaults=false)
void Apply(InfoConstVisitor &v, bool visit_this=true) const
InfoItem GetItem(const InfoPath &path, bool use_defaults=true) const
bool IsValid() const
bool HasDefaultItem(const InfoPath &p) const
InfoGroup CreateGroup(const String &name)
void SetName(const String &name)
friend InfoHandle LoadInfo(const String &)
Load InfoHandle from a file.
void SetAttribute(const String &name, const String &value)
InfoGroup Root() const
InfoItem CreateItem(const String &name, const String &value)
InfoItem RetrieveItem(const InfoPath &path, bool use_defaults=true)
encapsulates path to info groups and items
Definition info_path.hh:44
#define DLLEXPORT_OST_INFO
std::string String
Definition base.hh:54
DLLEXPORT InfoHandle LoadInfo(const String &file)
Load InfoHandle from a file.
boost::shared_ptr< detail::InfoImpl > RootPtr
DLLEXPORT InfoHandle CreateInfo()
Create InfoHandle from scratch.
Definition base.dox:1