MeVisLab Toolbox Reference
mlImageFormatTag.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_IMAGE_FORMAT_TAG_H
14#define ML_IMAGE_FORMAT_TAG_H
15
18
19// Resolve platform independencies.
21
22#include "mlModuleIncludes.h"
23
24#include <utility>
25
26// Implement everything in ML namespace.
27ML_START_NAMESPACE
28
29 //----------------------------------------------------------------------
31 //----------------------------------------------------------------------
33 public:
34
35 //------------------------------------------------------------------
38 //------------------------------------------------------------------
40 MLImageFormatTag() = default;
41
43 MLImageFormatTag(std::string name, std::string value) :
44 _name (std::move(name)),
45 _value(std::move(value))
46 {}
47
49 MLImageFormatTag(std::string name, MLint value) :
50 _name (std::move(name))
51 {
52 setValue(value);
53 }
54
56 MLImageFormatTag(std::string name, MLdouble value) :
57 _name (std::move(name))
58 {
59 setValue(value);
60 }
61
63 MLImageFormatTag(std::string name, MLldouble value) :
64 _name (std::move(name))
65 {
66 setValue(value);
67 }
68
69
70 //------------------------------------------------------------------
73 //------------------------------------------------------------------
75 const std::string &getName() const { return _name; }
76
78 const std::string &getValue() const { return _value; }
79
81 void setName(const std::string& newName) { _name = newName; }
83
84
85 //------------------------------------------------------------------
88 //------------------------------------------------------------------
90 void setValue(const std::string& newVal) { _value = newVal; }
91
93 void setValue(MLint newVal);
94
96 void setValue(MLdouble newVal);
97
99 void setValue(MLldouble newVal);
100
102 size_t getTagSize() const
103 {
104 return _name.size() + _value.size() + 2;
105 }
106
110 void writeNameAndValueIntoMemory(char *memPos) const;
111
130 const char * setNameAndValueFromMemory(const char* mem, const char* lastValidMemByte);
132
133
134
135 //------------------------------------------------------------------
138 //------------------------------------------------------------------
140 const std::string &getStringValue() const { return _value; }
141
144
147
151
152 protected:
154 std::string _name;
155
157 std::string _value;
158 };
159
160
161 //----------------------------------------------------------------------
163 //----------------------------------------------------------------------
164 bool operator==(const MLImageFormatTag& tag1, const MLImageFormatTag& tag2);
165
166 //----------------------------------------------------------------------
168 //----------------------------------------------------------------------
169 bool operator!=(const MLImageFormatTag& tag1, const MLImageFormatTag& tag2);
170
171
172ML_END_NAMESPACE
173
174#endif // of __mlImageFormat_H
175
#define MLIMAGEFORMATBASE_EXPORT
Class defining a tag used in the MLImageFormat class.
MLldouble getLongDoubleValue() const
Returns the value as a long double or 0 on failure.
MLdouble getDoubleValue() const
Returns the value as a double or 0 on failure.
std::string _name
The name of the tag to be stored in a file; default is "".
MLint getMLintValue() const
Sets the value as an MLint or 0 on failure.
void setValue(MLldouble newVal)
Sets the value from a long double.
MLImageFormatTag(std::string name, std::string value)
Constructor from name and value.
size_t getTagSize() const
Returns the size of name and value strings + 2 for the two terminating nulls.
const std::string & getStringValue() const
Sets the value from an MLint64.
void setValue(const std::string &newVal)
Sets the value from a string.
const std::string & getName() const
Returns the tag name as string.
void setValue(MLdouble newVal)
Sets the value from a double.
void setName(const std::string &newName)
Sets the value from an MLint64.
MLImageFormatTag(std::string name, MLdouble value)
Constructor from name and MLdouble.
MLImageFormatTag()=default
Default constructor, setting name and value to empty strings.
MLImageFormatTag(std::string name, MLint value)
Constructor from name and MLint.
MLImageFormatTag(std::string name, MLldouble value)
Constructor from name and MLldouble.
std::string _value
The value of the tag to be stored in a file; default is "".
void writeNameAndValueIntoMemory(char *memPos) const
Writes name and tag terminated with null characters to the memory position memPos.
const char * setNameAndValueFromMemory(const char *mem, const char *lastValidMemByte)
Sets tag and value from a memory buffer which is assumed to contain two NULL-terminated strings direc...
void setValue(MLint newVal)
Sets the value from an MLint64.
const std::string & getValue() const
Returns the value as string.
long double MLldouble
Definition mlTypeDefs.h:231
double MLdouble
Definition mlTypeDefs.h:216
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Returns true if yes.
Definition mlMatrix2.h:425
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Returns true if yes.
Definition mlMatrix2.h:433
STL namespace.