BALL  1.5.0
JCAMPFile.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_FORMAT_JCAMPFILE_H
6 #define BALL_FORMAT_JCAMPFILE_H
7 
8 #ifndef BALL_FORMAT_LINEBASEDFILE_H
10 #endif
11 
12 #ifndef BALL_DATATYPE_STRINGHASHMAP_H
14 #endif
15 
16 namespace BALL
17 {
29  : public LineBasedFile
30  {
31  public:
32 
36  // The value types supported by JCAMP
38  {
44  ARRAY
45  };
46 
49  {
50  public:
54  std::vector<double> numeric_value;
57 
58  JCAMPValue() : string_value(""), numeric_value(), type(STRING) {}
59 
60  bool operator == (const JCAMPValue& value) const;
61 
62  bool operator != (const JCAMPValue& value) const;
63  };
64 
66  typedef std::pair<String, JCAMPValue> KeyValuePair;
67 
70 
73 
75 
78 
81  JCAMPFile() {}
82 
86  JCAMPFile(const String& name, OpenMode open_mode = std::ios::in);
87 
90  virtual ~JCAMPFile() {}
91 
93 
96 
100  void read();
101 
105  bool write();
106 
108  HeaderMap& getHeader() { return header_; }
109 
111  const HeaderMap& getHeader() const { return header_; }
112 
114  EntryMap& getEntries() { return entries_; }
115 
117  const EntryMap& getEntries() const { return entries_; }
118 
120  const JCAMPValue& operator [] (const String& name) const { return entries_[name]; }
121 
125  double getDoubleValue(const String& name) const;
126 
130  Index getIntValue(const String& name) const;
131 
133  bool hasEntry(const String& name) const { return entries_.has(name); }
134 
136  bool hasHeader(const String& name) const { return header_.has(name); }
137 
139  const JCAMPFile& operator = (const JCAMPFile& file) ;
140 
142 
145 
148  bool operator == (const JCAMPFile& f) const;
149 
152  bool operator != (const JCAMPFile& f) const;
154 
155 
156  protected:
157 
160 
163  };
164 }
165 
166 #endif // BALL_FORMAT_JCAMPFILE_H
BALL::JCAMPFile::~JCAMPFile
virtual ~JCAMPFile()
Definition: JCAMPFile.h:90
BALL::JCAMPFile::JCAMPValue::numeric_value
std::vector< double > numeric_value
Definition: JCAMPFile.h:54
BALL::JCAMPFile::JCAMPValue::string_value
String string_value
Definition: JCAMPFile.h:52
BALL::JCAMPFile::NUMERIC
@ NUMERIC
Definition: JCAMPFile.h:42
BALL::operator!=
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
BALL::JCAMPFile::JCAMPValue
Definition: JCAMPFile.h:48
BALL::JCAMPFile::header_
HeaderMap header_
Entries from the header section.
Definition: JCAMPFile.h:159
BALL::JCAMPFile::STRING
@ STRING
Definition: JCAMPFile.h:40
stringHashMap.h
BALL::JCAMPFile::entries_
EntryMap entries_
Entries from the key-value section.
Definition: JCAMPFile.h:162
BALL::String
Definition: string.h:56
BALL::JCAMPFile::hasHeader
bool hasHeader(const String &name) const
Definition: JCAMPFile.h:136
BALL
Definition: constants.h:12
BALL::JCAMPFile::JCAMPValue::JCAMPValue
JCAMPValue()
Definition: JCAMPFile.h:58
BALL::JCAMPFile::getEntries
EntryMap & getEntries()
Definition: JCAMPFile.h:114
BALL::JCAMPFile::getEntries
const EntryMap & getEntries() const
Definition: JCAMPFile.h:117
BALL::JCAMPFile
Definition: JCAMPFile.h:28
BALL::StringHashMap< JCAMPValue >
BALL_INDEX_TYPE
BALL::JCAMPFile::JCAMPFile
JCAMPFile()
Definition: JCAMPFile.h:81
BALL::JCAMPFile::getHeader
const HeaderMap & getHeader() const
Definition: JCAMPFile.h:111
BALL::operator==
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL::JCAMPFile::HeaderMap
StringHashMap< String > HeaderMap
A hash map containing the header entries.
Definition: JCAMPFile.h:72
BALL::JCAMPFile::EntryMap
StringHashMap< JCAMPValue > EntryMap
A hash map containing the JCAMP entries.
Definition: JCAMPFile.h:69
BALL::JCAMPFile::getHeader
HeaderMap & getHeader()
Definition: JCAMPFile.h:108
BALL::JCAMPFile::KeyValuePair
std::pair< String, JCAMPValue > KeyValuePair
a key-value pair
Definition: JCAMPFile.h:66
BALL::LineBasedFile
Definition: lineBasedFile.h:20
BALL::JCAMPFile::ContentType
ContentType
Definition: JCAMPFile.h:37
BALL::JCAMPFile::hasEntry
bool hasEntry(const String &name) const
Definition: JCAMPFile.h:133
lineBasedFile.h
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::JCAMPFile::JCAMPValue::type
ContentType type
Definition: JCAMPFile.h:56