BALL 1.5.0
Loading...
Searching...
No Matches
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
16namespace 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
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
std::pair< String, JCAMPValue > KeyValuePair
a key-value pair
Definition JCAMPFile.h:66
JCAMPFile(const String &name, OpenMode open_mode=std::ios::in)
EntryMap & getEntries()
Definition JCAMPFile.h:114
HeaderMap & getHeader()
Definition JCAMPFile.h:108
bool hasHeader(const String &name) const
Definition JCAMPFile.h:136
StringHashMap< JCAMPValue > EntryMap
A hash map containing the JCAMP entries.
Definition JCAMPFile.h:69
bool hasEntry(const String &name) const
Definition JCAMPFile.h:133
Index getIntValue(const String &name) const
const EntryMap & getEntries() const
Definition JCAMPFile.h:117
HeaderMap header_
Entries from the header section.
Definition JCAMPFile.h:159
const HeaderMap & getHeader() const
Definition JCAMPFile.h:111
virtual ~JCAMPFile()
Definition JCAMPFile.h:90
double getDoubleValue(const String &name) const
EntryMap entries_
Entries from the key-value section.
Definition JCAMPFile.h:162
StringHashMap< String > HeaderMap
A hash map containing the header entries.
Definition JCAMPFile.h:72
std::vector< double > numeric_value
Definition JCAMPFile.h:54
std::ios::openmode OpenMode
Definition file.h:165
#define BALL_EXPORT