Chemical Data Processing Library C++ API - Version 1.4.0
StringDataBlock.hpp
Go to the documentation of this file.
1 /*
2  * StringDataBlock.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_CHEM_STRINGDATABLOCK_HPP
30 #define CDPL_CHEM_STRINGDATABLOCK_HPP
31 
32 #include <string>
33 
34 #include "CDPL/Chem/APIPrefix.hpp"
35 #include "CDPL/Util/Array.hpp"
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Chem
42  {
43 
51  {
52 
53  public:
58 
64  StringDataBlockEntry(const std::string& header, const std::string& data):
65  header(header), data(data) {}
66 
71  const std::string& getHeader() const;
72 
77  void setHeader(const std::string& header);
78 
83  const std::string& getData() const;
84 
89  void setData(const std::string& data);
90 
96  bool operator==(const StringDataBlockEntry& entry) const;
97 
107  bool operator!=(const StringDataBlockEntry& entry) const;
108 
114  bool operator<(const StringDataBlockEntry& entry) const;
115 
121  bool operator>(const StringDataBlockEntry& entry) const;
122 
128  bool operator<=(const StringDataBlockEntry& entry) const;
129 
135  bool operator>=(const StringDataBlockEntry& entry) const;
136 
137  private:
138  std::string header;
139  std::string data;
140  };
141 
148  class CDPL_CHEM_API StringDataBlock : public Util::Array<StringDataBlockEntry>
149  {
150 
151  public:
153  typedef std::shared_ptr<StringDataBlock> SharedPointer;
154 
160  void addEntry(const std::string& header, const std::string& data)
161  {
162  addElement(StringDataBlockEntry(header, data));
163  }
164 
165  private:
166  const char* getClassName() const
167  {
168  return "StringDataBlock";
169  }
170  };
171  } // namespace Chem
172 } // namespace CDPL
173 
174 #endif // CDPL_CHEM_STRINGDATABLOCK_HPP
Definition of class CDPL::Util::Array.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Represents a data item consisting of a header and a data payload.
Definition: StringDataBlock.hpp:51
StringDataBlockEntry(const std::string &header, const std::string &data)
Constructs a StringDataBlockEntry object with the specified data header and content.
Definition: StringDataBlock.hpp:64
void setHeader(const std::string &header)
Sets the data header.
bool operator<=(const StringDataBlockEntry &entry) const
Less-than-or-equal comparison operator (lexicographic ordering by header, then data).
bool operator==(const StringDataBlockEntry &entry) const
Equality comparison operator.
void setData(const std::string &data)
Sets the data content.
const std::string & getHeader() const
Returns the data header.
bool operator<(const StringDataBlockEntry &entry) const
Less-than comparison operator (lexicographic ordering by header, then data).
const std::string & getData() const
Returns the stored data content.
bool operator!=(const StringDataBlockEntry &entry) const
Inequality comparison operator.
bool operator>=(const StringDataBlockEntry &entry) const
Greater-than-or-equal comparison operator (lexicographic ordering by header, then data).
bool operator>(const StringDataBlockEntry &entry) const
Greater-than comparison operator (lexicographic ordering by header, then data).
StringDataBlockEntry()
Constructs a StringDataBlockEntry object with an empty data header and content.
Definition: StringDataBlock.hpp:57
Array of Chem::StringDataBlockEntry objects.
Definition: StringDataBlock.hpp:149
void addEntry(const std::string &header, const std::string &data)
Appends a new entry with the supplied data header and content to the block.
Definition: StringDataBlock.hpp:160
std::shared_ptr< StringDataBlock > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated StringDataBlock instances.
Definition: StringDataBlock.hpp:153
Dynamic array class providing amortized constant time access to arbitrary elements.
Definition: Array.hpp:92
The namespace of the Chemical Data Processing Library.