32 #ifndef VLXParserVLB_INCLUDE_ONCE 33 #define VLXParserVLB_INCLUDE_ONCE 59 unsigned char vlx_identifier[] = { 0xAB,
'V',
'L',
'X', 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
60 unsigned char vlx[
sizeof(vlx_identifier)];
61 memset(vlx, 0,
sizeof(vlx));
63 if ( memcmp(vlx, vlx_identifier,
sizeof(vlx)) != 0 )
69 unsigned char ch = 0xFF;
75 if (
inputFile()->readUInt32(&mFlags, 1) != 4 )
88 const unsigned char nxt_flag = 0x80;
89 const unsigned char neg_flag = 0x40;
90 unsigned char byte = 0;
93 bool is_neg = (byte & neg_flag) != 0;
96 while(byte & nxt_flag)
100 n |= (
long long)(byte & 0x7F) << shift;
109 void decodeIntegers(
const std::vector<unsigned char>& in, std::vector<long long>& out)
111 out.reserve(in.size());
112 const unsigned char nxt_flag = 0x80;
113 const unsigned char neg_flag = 0x40;
114 for(
size_t i=0 ; i<in.size() ; )
116 unsigned char byte = in[i++];
117 bool is_neg = (byte & neg_flag) != 0;
118 long long n = byte & 0x3F;
120 while(byte & nxt_flag)
123 n |= (
long long)(byte & 0x7F) << shift;
143 str.resize((
size_t)len);
144 bool ok = (size_t)
inputFile()->
read(&str[0], str.length()) == str.length();
232 st->
setID(str.c_str());
240 for(
int i=0; i<count; ++i)
252 st->
value().push_back(val);
265 list->
setTag(str.c_str());
273 for(
int i=0; i<count; ++i)
280 list->
value().push_back(val);
288 unsigned char chunk = 0;
323 long long encode_count = 0;
329 std::vector<unsigned char> encoded;
330 encoded.resize((
size_t)encode_count);
336 return (
size_t)count == arr.
value().size();
352 arr.
value().resize( (
size_t)count );
357 VL_CHECK(c == count * (
int)
sizeof(
double))
358 return c == count * (int)
sizeof(
double);
362 std::vector<unsigned char> zipped;
363 zipped.resize((
size_t)zsize);
387 arr.
value().resize( (
size_t)count );
391 std::vector<float> floats;
392 floats.resize( (
size_t)count );
395 for(
size_t i=0; i<floats.size(); ++i)
396 arr.
value()[i] = floats[i];
397 VL_CHECK(c == count * (
int)
sizeof(
float))
398 return c == count * (int)
sizeof(
float);
402 std::vector<unsigned char> zipped;
403 zipped.resize((
size_t)zsize);
444 if (
inputFile()->readDouble(&d, 1) !=
sizeof(
double))
476 val.
setID(str.c_str());
482 unsigned char boolean =
false;
long long read(void *buffer, long long byte_count)
Reads byte_count bytes from a file. Returns the number of bytes actually read.
double setReal(double val)
void setKey(const char *key)
bool decompress(const void *cdata, size_t csize, void *data_out)
VLXRawtextBlock * getRawtextBlock()
Wrapper for all VLX value types.
void setInputFile(vl::VirtualFile *file)
An abstract class representing a file.
A simple String formatting class.
VLX_EXPORT VLXList * setList(VLXList *)
void parseMetadata()
Moves the <Metadata> key/value pairs in the Metadata map for quick and easy access and removes the <M...
void setValue(const char *value)
Key/value pair used by VLXStructure.
vl::VirtualFile * inputFile()
long long setInteger(long long val)
VLX_EXPORT VLXRawtextBlock * setRawtextBlock(VLXRawtextBlock *)
void setTag(const char *tag)
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
An array of 64 bits floating point numbers, can also have a tag.
VLXStructure * getStructure()
float readFloat(bool little_endian_data=true)
Reads single entry.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
virtual void close()=0
Closes the file.
bool readValue(VLXValue &val)
std::vector< vl::ref< VLXStructure > > mStructures
const std::string & setIdentifier(const char *str)
std::vector< VLXValue > & value()
const std::string & setString(const char *str)
A list of key/VLXValue pairs, can also have a tag.
void setID(const char *uid)
bool parseList(VLXList *list)
A simple sequence of VLXValue objects, can also have a tag.
bool readChunk(unsigned char &chunk)
#define VL_SERIALIZER_VERSION
VLX_EXPORT VLXStructure * setStructure(VLXStructure *)
unsigned char readUInt8()
Reads single entry.
VLX_EXPORT VLXArrayInteger * setArrayInteger(VLXArrayInteger *)
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
std::vector< KeyValue > & value()
bool readString(std::string &str)
An array of 64 bits integers, can also have a tag.
std::vector< T > & value()
const std::string & setID(const char *str)
Parses a VLT file translating it into a VLX hierarchy.
const vl::VirtualFile * inputFile() const
Base class for VLX parsers.
VLXArrayInteger * getArrayInteger()
VLXArrayReal * getArrayReal()
bool parseStructure(VLXStructure *st)
std::map< std::string, VLXValue > mMetadata
bool readInteger(long long &n)
void decodeIntegers(const std::vector< unsigned char > &in, std::vector< long long > &out)
double readDouble(bool little_endian_data=true)
Reads single entry.
VLX_EXPORT VLXArrayReal * setArrayReal(VLXArrayReal *)