Chemical Data Processing Library C++ API - Version 1.2.0
MMCIFData.hpp
Go to the documentation of this file.
1 /*
2  * MMCIFData.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_BIOMOL_MMCIFDATA_HPP
30 #define CDPL_BIOMOL_MMCIFDATA_HPP
31 
32 #include <cstddef>
33 #include <string>
34 #include <memory>
35 #include <iosfwd>
36 
37 #include <boost/ptr_container/ptr_vector.hpp>
38 #include <boost/ptr_container/ptr_deque.hpp>
39 
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Biomol
47  {
48 
54  {
55 
56  public:
57  typedef std::shared_ptr<MMCIFData> SharedPointer;
58 
60  {
61 
62  typedef std::vector<std::string> ValueList;
63 
64  public:
65  typedef ValueList::const_iterator ConstValueIterator;
66  typedef ValueList::iterator ValueIterator;
67 
68  Item(const std::string& name):
69  name(name) {}
70 
71  const std::string& getName() const;
72 
73  std::size_t getNumValues() const;
74 
75  void clear();
76 
77  const std::string& getValue(std::size_t index) const;
78 
79  void setValue(std::size_t index, const std::string& value);
80  void setValue(std::size_t index, std::string&& value);
81 
82  void addValue(const std::string& value);
83  void addValue(std::string&& value);
84 
86 
87  void removeValue(std::size_t index);
88 
89  void swap(Item& item);
90 
92 
94 
96 
98 
100 
102 
104 
106 
107  private:
108  std::string name;
109  ValueList values;
110  };
111 
113  {
114 
115  typedef boost::ptr_vector<Item> ItemList;
116 
117  public:
118  typedef ItemList::const_iterator ConstItemIterator;
119  typedef ItemList::iterator ItemIterator;
120 
121  Category(const std::string& name):
122  name(name), numRows(0) {}
123 
124  const std::string& getName() const;
125 
126  void clear();
127 
128  std::size_t getNumItems() const;
129 
130  Item& getItem(std::size_t index);
131 
132  const Item& getItem(std::size_t index) const;
133 
134  Item& getItem(const std::string& name);
135 
136  const Item& getItem(const std::string& name) const;
137 
138  const Item* findItem(const std::string& name) const;
139 
140  Item* findItem(const std::string& name);
141 
142  Item& addItem(const std::string& name);
143 
145 
146  bool removeItem(const std::string& name);
147 
148  void removeItem(std::size_t index);
149 
150  void swap(Category& cat);
151 
153 
155 
157 
159 
161 
163 
165 
167 
168  std::size_t getNumValueRows() const;
169 
170  private:
171  ItemIterator getItemIter(const std::string& name);
172 
173  ConstItemIterator getItemIter(const std::string& name) const;
174 
175  std::string name;
176  ItemList items;
177  std::size_t numRows;
178  };
179 
180  private:
181  typedef boost::ptr_deque<Category> CategoryList;
182 
183  public:
184  typedef CategoryList::const_iterator ConstCategoryIterator;
185  typedef CategoryList::iterator CategoryIterator;
186 
187  MMCIFData() = default;
188 
189  MMCIFData(const std::string& id);
190 
191  void setID(const std::string& id);
192 
193  const std::string& getID() const;
194 
195  void clear();
196 
197  std::size_t getNumCategories() const;
198 
199  Category& getCategory(std::size_t index);
200 
201  const Category& getCategory(std::size_t index) const;
202 
203  Category& getCategory(const std::string& name);
204 
205  const Category& getCategory(const std::string& name) const;
206 
207  const Category* findCategory(const std::string& name) const;
208 
209  Category* findCategory(const std::string& name);
210 
211  const Category& lastCategory() const;
212 
214 
215  Category& addCategory(const std::string& name, bool front = false);
216 
218 
219  bool removeCategory(const std::string& name);
220 
221  void removeCategory(std::size_t index);
222 
223  void swap(MMCIFData& data);
224 
226 
228 
230 
232 
234 
236 
238 
240 
241  private:
242  CategoryIterator getCategoryIter(const std::string& name);
243 
244  ConstCategoryIterator getCategoryIter(const std::string& name) const;
245 
246  std::string id;
247  CategoryList categories;
248  };
249 
253  CDPL_BIOMOL_API std::ostream& operator<<(std::ostream& os, const MMCIFData& data);
254 
258  CDPL_BIOMOL_API std::ostream& operator<<(std::ostream& os, const MMCIFData::Category& cat);
259 
260  } // namespace Biomol
261 } // namespace CDPL
262 
263 #endif // CDPL_BIOMOL_MMCIFDATA_HPP
Definition of the preprocessor macro CDPL_BIOMOL_API.
#define CDPL_BIOMOL_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition: MMCIFData.hpp:113
ConstItemIterator getItemsBegin() const
const Item & getItem(const std::string &name) const
ConstItemIterator end() const
std::size_t getNumItems() const
Item * findItem(const std::string &name)
bool removeItem(const std::string &name)
std::size_t getNumValueRows() const
Item & getItem(std::size_t index)
Item & getItem(const std::string &name)
ItemList::const_iterator ConstItemIterator
Definition: MMCIFData.hpp:118
ConstItemIterator begin() const
ConstItemIterator getItemsEnd() const
ItemIterator removeItem(const ItemIterator &it)
const std::string & getName() const
ItemList::iterator ItemIterator
Definition: MMCIFData.hpp:119
void removeItem(std::size_t index)
Category(const std::string &name)
Definition: MMCIFData.hpp:121
const Item & getItem(std::size_t index) const
const Item * findItem(const std::string &name) const
Item & addItem(const std::string &name)
Definition: MMCIFData.hpp:60
ValueIterator removeValue(const ValueIterator &it)
ConstValueIterator getValuesEnd() const
void addValue(const std::string &value)
ValueList::const_iterator ConstValueIterator
Definition: MMCIFData.hpp:65
Item(const std::string &name)
Definition: MMCIFData.hpp:68
std::size_t getNumValues() const
void setValue(std::size_t index, std::string &&value)
ValueList::iterator ValueIterator
Definition: MMCIFData.hpp:66
ConstValueIterator end() const
void setValue(std::size_t index, const std::string &value)
ConstValueIterator getValuesBegin() const
ValueIterator getValuesBegin()
const std::string & getName() const
ConstValueIterator begin() const
void removeValue(std::size_t index)
const std::string & getValue(std::size_t index) const
void addValue(std::string &&value)
A data structure for the storage of imported MMCIF data (see [MMCIF]).
Definition: MMCIFData.hpp:54
Category & addCategory(const std::string &name, bool front=false)
std::shared_ptr< MMCIFData > SharedPointer
Definition: MMCIFData.hpp:57
const Category & getCategory(std::size_t index) const
const std::string & getID() const
void setID(const std::string &id)
const Category * findCategory(const std::string &name) const
Category & getCategory(const std::string &name)
CategoryIterator end()
CategoryIterator begin()
Category * findCategory(const std::string &name)
std::size_t getNumCategories() const
CategoryIterator removeCategory(const CategoryIterator &it)
const Category & getCategory(const std::string &name) const
CategoryIterator getCategoriesBegin()
bool removeCategory(const std::string &name)
CategoryList::const_iterator ConstCategoryIterator
Definition: MMCIFData.hpp:184
Category & lastCategory()
CategoryList::iterator CategoryIterator
Definition: MMCIFData.hpp:185
ConstCategoryIterator getCategoriesBegin() const
void swap(MMCIFData &data)
CategoryIterator getCategoriesEnd()
Category & getCategory(std::size_t index)
MMCIFData(const std::string &id)
const Category & lastCategory() const
ConstCategoryIterator getCategoriesEnd() const
ConstCategoryIterator end() const
ConstCategoryIterator begin() const
void removeCategory(std::size_t index)
CDPL_BIOMOL_API std::ostream & operator<<(std::ostream &os, const MMCIFData &data)
The namespace of the Chemical Data Processing Library.