32 #ifndef VLXParserVLB_INCLUDE_ONCE 33 #define VLXParserVLB_INCLUDE_ONCE 58 unsigned char vlx_identifier[] = { 0xAB,
'V',
'L',
'X', 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
59 unsigned char vlx[
sizeof(vlx_identifier)];
60 memset(vlx, 0,
sizeof(vlx));
62 if ( memcmp(vlx, vlx_identifier,
sizeof(vlx)) != 0 )
68 unsigned char ch = 0xFF;
74 if (
inputFile()->readUInt32(&mFlags, 1) != 4 )
87 const unsigned char nxt_flag = 0x80;
88 const unsigned char neg_flag = 0x40;
89 unsigned char byte = 0;
92 bool is_neg = (byte & neg_flag) != 0;
95 while(byte & nxt_flag)
99 n |= (
long long)(byte & 0x7F) << shift;
108 void decodeIntegers(
const std::vector<unsigned char>& in, std::vector<long long>& out)
110 out.reserve(in.size());
111 const unsigned char nxt_flag = 0x80;
112 const unsigned char neg_flag = 0x40;
113 for(
size_t i=0 ; i<in.size() ; )
115 unsigned char byte = in[i++];
116 bool is_neg = (byte & neg_flag) != 0;
117 long long n = byte & 0x3F;
119 while(byte & nxt_flag)
122 n |= (
long long)(byte & 0x7F) << shift;
142 str.resize((
size_t)len);
143 bool ok = (size_t)
inputFile()->
read(&str[0], str.length()) == str.length();
174 Log::error(
"VLXParserVLB : error parsing VLB header.\n");
209 Log::error(
Say(
"Error parsing binary file at offset %n. Expected chunk structure.\n") <<
inputFile()->position() );
231 st->
setID(str.c_str());
239 for(
int i=0; i<count; ++i)
251 st->
value().push_back(val);
264 list->
setTag(str.c_str());
272 for(
int i=0; i<count; ++i)
279 list->
value().push_back(val);
287 unsigned char chunk = 0;
322 long long encode_count = 0;
328 std::vector<unsigned char> encoded;
329 encoded.resize((
size_t)encode_count);
335 return (
size_t)count == arr.
value().size();
351 arr.
value().resize( (
size_t)count );
356 VL_CHECK(c == count * (
int)
sizeof(
double))
357 return c == count * (int)
sizeof(
double);
361 std::vector<unsigned char> zipped;
362 zipped.resize((
size_t)zsize);
386 arr.
value().resize( (
size_t)count );
390 std::vector<float> floats;
391 floats.resize( (
size_t)count );
394 for(
size_t i=0; i<floats.size(); ++i)
395 arr.
value()[i] = floats[i];
396 VL_CHECK(c == count * (
int)
sizeof(
float))
397 return c == count * (int)
sizeof(
float);
401 std::vector<unsigned char> zipped;
402 zipped.resize((
size_t)zsize);
443 if (
inputFile()->readDouble(&d, 1) !=
sizeof(
double))
475 val.
setID(str.c_str());
481 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.
VLXRawtextBlock * getRawtextBlock()
bool decompress(const void *cdata, size_t csize, void *data_out)
double setReal(double val)
long long setInteger(long long val)
void setKey(const char *key)
std::vector< ref< VLXStructure > > mStructures
void setTag(const char *tag)
An abstract class representing a file.
Base class for VLX parsers.
void setValue(const char *value)
bool readString(std::string &str)
A simple String formatting class.
VLXArrayInteger * getArrayInteger()
VLCORE_EXPORT VLXStructure * setStructure(VLXStructure *)
std::map< std::string, VLXValue > mMetadata
Parses a VLT file translating it into a VLX hierarchy.
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
VLCORE_EXPORT VLXList * setList(VLXList *)
bool readValue(VLXValue &val)
An array of 64 bits floating point numbers, can also have a tag.
const std::string & setID(const char *str)
float readFloat(bool little_endian_data=true)
Reads single entry.
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
virtual void close()=0
Closes the file.
Visualization Library main namespace.
void decodeIntegers(const std::vector< unsigned char > &in, std::vector< long long > &out)
bool parseList(VLXList *list)
const VirtualFile * inputFile() const
Key/value pair used by VLXStructure.
VLXStructure * getStructure()
bool readInteger(long long &n)
VLCORE_EXPORT VLXArrayReal * setArrayReal(VLXArrayReal *)
void setInputFile(VirtualFile *file)
std::vector< T > & value()
std::vector< Value > & value()
void setID(const char *uid)
unsigned char readUInt8()
Reads single entry.
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
const std::string & setIdentifier(const char *str)
Wrapper for all VLX value types.
An array of 64 bits integers, can also have a tag.
bool parseStructure(VLXStructure *st)
VLXArrayReal * getArrayReal()
const std::string & setString(const char *str)
VLCORE_EXPORT VLXArrayInteger * setArrayInteger(VLXArrayInteger *)
A simple sequence of VLXValue objects, can also have a tag.
bool readChunk(unsigned char &chunk)
The ref<> class is used to reference-count an Object.
VLCORE_EXPORT VLXRawtextBlock * setRawtextBlock(VLXRawtextBlock *)
std::vector< VLXValue > & value()
void parseMetadata()
Moves the <Metadata> key/value pairs in the Metadata map for quick and easy access and removes the <M...
A list of key/VLXValue pairs, can also have a tag.
VirtualFile * inputFile()
double readDouble(bool little_endian_data=true)
Reads single entry.