/usr/include/BALL/FORMAT/JCAMPFile.h is in libball1.4-dev 1.4.3~beta1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | // -*- 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
{
/** JCAMP file class.
This class parses JCAMP files, which are often
used to store parameter files in spectroscopy (NMR, IR, MS), e.g.
in Bruker instruments.
\par
This class has rudimentary support for the format only. The most severe
drawback currently is the lack of support for writing JCAMP files.
\ingroup NMRFileFormats
*/
class BALL_EXPORT JCAMPFile
: public LineBasedFile
{
public:
/** Type definitions
*/
//@{
// 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;
};
/// a key-value pair
typedef std::pair<String, JCAMPValue> KeyValuePair;
/// A hash map containing the JCAMP entries
typedef StringHashMap<JCAMPValue> EntryMap;
/// A hash map containing the header entries
typedef StringHashMap<String> HeaderMap;
//@}
/** @name Constructors and Destructors
*/
//@{
/** Default constructor
*/
JCAMPFile() {}
/** Detailed constructor
* @throw Exception::FileNotFound if the file could not be opened
*/
JCAMPFile(const String& name, OpenMode open_mode = std::ios::in);
/** Destructor
*/
virtual ~JCAMPFile() {}
//@}
/** @name Accessors
*/
//@{
/** Read the file.
* @throw Exception::ParseError if a syntax error was encountered
*/
void read();
/** Write the file.
* @throw File::CannotWrite if writing to the file failed
*/
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]; }
/** Return a double value for key name
* @throw Exception::InvalidFormat if the value is not a floating point number
*/
double getDoubleValue(const String& name) const;
/** Return an int value for key name
* @throw Exception::InvalidFormat if the value is not convertible to an int
*/
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) ;
//@}
/** @name Equality operators
*/
//@{
/** Equality operator
*/
bool operator == (const JCAMPFile& f) const;
/** Inequality operator
*/
bool operator != (const JCAMPFile& f) const;
//@}
protected:
/// Entries from the header section
HeaderMap header_;
/// Entries from the key-value section
EntryMap entries_;
};
}
#endif // BALL_FORMAT_JCAMPFILE_H
|