Loading...
Searching...
No Matches
JCAMPFile.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_FORMAT_JCAMPFILE_H
#define BALL_FORMAT_JCAMPFILE_H
#ifndef BALL_FORMAT_LINEBASEDFILE_H
# include <BALL/FORMAT/lineBasedFile.h>
#endif
#ifndef BALL_DATATYPE_STRINGHASHMAP_H
# include <BALL/DATATYPE/stringHashMap.h>
#endif
namespace BALL
{
class BALL_EXPORT JCAMPFile
: public LineBasedFile
{
public:
// The value types supported by JCAMP
enum ContentType
{
STRING,
NUMERIC,
ARRAY
};
class BALL_EXPORT JCAMPValue
{
public:
String string_value;
std::vector<double> numeric_value;
ContentType type;
JCAMPValue() : string_value(""), numeric_value(), type(STRING) {}
bool operator == (const JCAMPValue& value) const;
bool operator != (const JCAMPValue& value) const;
};
typedef std::pair<String, JCAMPValue> KeyValuePair;
typedef StringHashMap<JCAMPValue> EntryMap;
typedef StringHashMap<String> HeaderMap;
JCAMPFile() {}
JCAMPFile(const String& name, OpenMode open_mode = std::ios::in);
virtual ~JCAMPFile() {}
void read();
bool write();
HeaderMap& getHeader() { return header_; }
const HeaderMap& getHeader() const { return header_; }
EntryMap& getEntries() { return entries_; }
const EntryMap& getEntries() const { return entries_; }
const JCAMPValue& operator [] (const String& name) const { return entries_[name]; }
double getDoubleValue(const String& name) const;
Index getIntValue(const String& name) const;
bool hasEntry(const String& name) const { return entries_.has(name); }
bool hasHeader(const String& name) const { return header_.has(name); }
const JCAMPFile& operator = (const JCAMPFile& file) ;
bool operator == (const JCAMPFile& f) const;
bool operator != (const JCAMPFile& f) const;
protected:
HeaderMap header_;
EntryMap entries_;
};
}
#endif // BALL_FORMAT_JCAMPFILE_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition file.h:165
BALL::JCAMPFile::JCAMPValue
Definition JCAMPFile.h:49
BALL::JCAMPFile::JCAMPValue::type
ContentType type
Definition JCAMPFile.h:56
BALL::JCAMPFile::JCAMPValue::numeric_value
std::vector< double > numeric_value
Definition JCAMPFile.h:54
BALL::JCAMPFile::JCAMPValue::JCAMPValue
JCAMPValue()
Definition JCAMPFile.h:58
BALL::JCAMPFile::JCAMPValue::string_value
String string_value
Definition JCAMPFile.h:52
BALL::JCAMPFile::write
bool write()
BALL::JCAMPFile::JCAMPFile
JCAMPFile(const String &name, OpenMode open_mode=std::ios::in)
BALL::JCAMPFile::KeyValuePair
std::pair< String, JCAMPValue > KeyValuePair
a key-value pair
Definition JCAMPFile.h:66
BALL::JCAMPFile::EntryMap
StringHashMap< JCAMPValue > EntryMap
A hash map containing the JCAMP entries.
Definition JCAMPFile.h:69
BALL::JCAMPFile::getEntries
EntryMap & getEntries()
Definition JCAMPFile.h:114
BALL::JCAMPFile::getHeader
HeaderMap & getHeader()
Definition JCAMPFile.h:108
BALL::JCAMPFile::hasHeader
bool hasHeader(const String &name) const
Definition JCAMPFile.h:136
BALL::JCAMPFile::hasEntry
bool hasEntry(const String &name) const
Definition JCAMPFile.h:133
BALL::JCAMPFile::getIntValue
Index getIntValue(const String &name) const
BALL::JCAMPFile::ContentType
ContentType
Definition JCAMPFile.h:38
BALL::JCAMPFile::NUMERIC
@ NUMERIC
Definition JCAMPFile.h:42
BALL::JCAMPFile::ARRAY
@ ARRAY
Definition JCAMPFile.h:44
BALL::JCAMPFile::STRING
@ STRING
Definition JCAMPFile.h:40
BALL::JCAMPFile::getEntries
const EntryMap & getEntries() const
Definition JCAMPFile.h:117
BALL::JCAMPFile::header_
HeaderMap header_
Entries from the header section.
Definition JCAMPFile.h:159
BALL::JCAMPFile::getHeader
const HeaderMap & getHeader() const
Definition JCAMPFile.h:111
BALL::JCAMPFile::read
void read()
BALL::JCAMPFile::~JCAMPFile
virtual ~JCAMPFile()
Definition JCAMPFile.h:90
BALL::JCAMPFile::HeaderMap
StringHashMap< String > HeaderMap
A hash map containing the header entries.
Definition JCAMPFile.h:72
BALL::JCAMPFile::JCAMPFile
JCAMPFile()
Definition JCAMPFile.h:81
BALL::JCAMPFile::getDoubleValue
double getDoubleValue(const String &name) const
BALL::JCAMPFile::entries_
EntryMap entries_
Entries from the key-value section.
Definition JCAMPFile.h:162
BALL::LineBasedFile::LineBasedFile
LineBasedFile()
Default constructor.
BALL::StringHashMap
Definition stringHashMap.h:42
BALL::String
Definition string.h:57
lineBasedFile.h
BALL
Definition constants.h:13
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105
stringHashMap.h