34#include <NDEVR/String.h>
35#include <NDEVR/ProgressInfo.h>
36#include <NDEVR/Resource.h>
37#include <NDEVR/Scanner.h>
38#include <NDEVR/Buffer.h>
39#include <NDEVR/Dictionary.h>
40#include <NDEVR/Matrix.h>
59 template<
class t_type>
65 , m_type_pointer_shared(&value)
66 , m_type_pointer(
nullptr)
68 INIObject(t_type& value)
70 , m_type_pointer_shared(
nullptr)
71 , m_type_pointer(&value)
73 INIObject(
const INIObject& other)
75 , m_type_pointer_shared(other.m_type_pointer_shared)
76 , m_type_pointer(other.m_type_pointer)
79 void readOptionAscii(
Scanner& scan)
override
83 void readOptionAscii(
String option)
override
85 INIFactory::ConvertFromINIString(option);
86 if (option.
size() > 0)
88 if (m_type_pointer_shared !=
nullptr)
89 m_type_pointer_shared->set(option.
getAs<t_type>());
91 *m_type_pointer = option.
getAs<t_type>();
94 String writeOptionAscii()
const override
97 if (m_type_pointer_shared !=
nullptr)
98 s =
String(m_type_pointer_shared->get());
100 s =
String(*m_type_pointer);
101 INIFactory::ConvertToINIString(s);
104 void readOptionBinary(
const char* bytes)
override
109 memcpy(&value, bytes,
sizeof(t_type));
110 if (m_type_pointer_shared !=
nullptr)
111 m_type_pointer_shared->set(value);
113 *m_type_pointer = value;
117 readOptionAscii(
String(bytes));
120 void writeOptionBinary(FILE* stream)
const override
124 uint04 size =
sizeof(t_type);
125 fwrite(&size,
sizeof(
uint04), 1, stream);
126 if (m_type_pointer_shared !=
nullptr)
127 fwrite(&(m_type_pointer_shared->get()),
sizeof(t_type), 1, stream);
129 fwrite(m_type_pointer,
sizeof(t_type), 1, stream);
133 const String value = writeOptionAscii();
135 fwrite(&value_size,
sizeof(
uint04), 1, stream);
136 fwrite(value.
c_str(),
sizeof(
char), value_size, stream);
139 INIObject<t_type>* copy()
const override
141 return new INIObject<t_type>(*
this);
145 t_type*
const m_type_pointer;
147 template<
class t_type>
153 , m_type_pointer_shared(&value)
154 , m_type_pointer(
nullptr)
158 , m_type_pointer_shared(
nullptr)
159 , m_type_pointer(&value)
161 INIObject(
const INIObject& other)
163 , m_type_pointer_shared(other.m_type_pointer_shared)
164 , m_type_pointer(other.m_type_pointer)
167 void readOptionAscii(
Scanner& scan)
override
171 void readOptionAscii(
String option)
override
173 INIFactory::ConvertFromINIString(option);
174 if (option.
size() > 0)
176 if (m_type_pointer_shared !=
nullptr)
182 String writeOptionAscii()
const override
185 if (m_type_pointer_shared !=
nullptr)
186 s =
String(m_type_pointer_shared->get().template as<DEGREES>());
188 s =
String(m_type_pointer->template as<DEGREES>());
189 INIFactory::ConvertToINIString(s);
192 void readOptionBinary(
const char* bytes)
override
196 if (m_type_pointer_shared !=
nullptr)
197 m_type_pointer_shared->set(value);
199 *m_type_pointer = value;
201 void writeOptionBinary(FILE* stream)
const override
204 fwrite(&size,
sizeof(
uint04), 1, stream);
205 if (m_type_pointer_shared !=
nullptr)
206 fwrite(&(m_type_pointer_shared->get()),
sizeof(
Angle<t_type>), 1, stream);
210 INIObject<Angle<t_type>>* copy()
const override
212 return new INIObject<Angle<t_type>>(*this);
224 template<
class t_type>
227 return new INIObject<t_type>(mem_loc);
229 template<
class t_type>
232 return new INIObject<t_type>(value);
235 template<u
int01 t_dims,
class t_type>
241 template<u
int01 t_dims,
class t_type>
247 template<
class t_type>
250 template<
class t_type>
253 addINIOption(label,
new INIObject<t_type>(mem_loc));
255 template<
class t_type>
258 template<
class t_type>
261 addINIOption(label,
new INIObject<t_type>(mem_loc));
263 template<
class t_type, u
int01 t_row_dims, u
int01 t_col_dims>
269 bool addManagedOption(
const String& option_label,
const String& option,
bool replace =
true);
270 bool hasOption(
const String& option)
const;
271 bool hasOption(
uint08 hash_option)
const;
272 void setDelimiter(
char delimiter);
275 void readAsciiFile(
File& file);
276 void readBinaryFile(
File& file);
279 void writeToAsciiFile(
File& file,
bool include_end_comment =
false);
280 void writeToBinaryFile(
File& file);
282 void setUseHashLabels(
bool use_hash_labels);
286 static void ConvertToINIString(
String& s);
287 static void ConvertFromINIString(
String& s);
295 bool m_preserve_order =
false;
296 bool m_use_hash_labels =
false;
Stores an angle in an optimized format.
Definition StringStream.h:352
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
constexpr t_index_type size() const
Definition Buffer.hpp:1461
Definition Dictionary.h:48
Definition INIReader.h:57
void addOption(const String &label, Resource< Matrix< t_type, t_row_dims, t_col_dims > > &mem_loc)
Definition INIReader.h:264
void addOption(const String &label, const t_type &mem_loc)=delete
void addOption(const String &label, Resource< Vector< t_dims, t_type > > &mem_loc)
Definition INIReader.h:236
bool preserveOrder() const
Definition INIReader.h:278
void setComment(char comment)
Definition INIReader.h:273
static INIOption * ToOption(t_type &mem_loc)
Definition INIReader.h:225
void addOption(const String &label, const Resource< t_type > &mem_loc)=delete
INIFactory(const INIFactory &reader)=delete
static INIOption * ToOption(Resource< t_type > &value)
Definition INIReader.h:230
Dictionary< String, String * > & extraOptionsRef()
Definition INIReader.h:284
void addOption(const String &label, t_type &mem_loc)
Definition INIReader.h:259
void addOption(const String &label, Vector< t_dims, t_type > &mem_loc)
Definition INIReader.h:242
void addOption(const String &label, Resource< t_type > &mem_loc)
Definition INIReader.h:251
void setPreserveOrder(bool preserve_order)
Definition INIReader.h:277
Definition INIReader.h:45
virtual String writeOptionAscii() const =0
virtual void readOptionAscii(String option)=0
virtual void readOptionAscii(Scanner &option)=0
virtual INIOption * copy() const =0
virtual void readOptionBinary(const char *bytes)=0
virtual void writeOptionBinary(FILE *stream) const =0
virtual ~INIOption()
Definition INIReader.h:48
Definition Matrix.hpp:173
Definition ProgressInfo.hpp:43
NDEVR_BASE_API const char * c_str() const
Definition String.cpp:490
t_type getAs() const
Definition String.h:334
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
@ DEGREES
Definition Angle.h:66
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Information about the object.
Definition ObjectInfo.h:56