32 #ifndef VLXVisitorExportToVLB_INCLUDE_ONCE 33 #define VLXVisitorExportToVLB_INCLUDE_ONCE 58 std::map< std::string, int >::iterator it = mIDSet->find(uid);
59 if (it != mIDSet->end())
60 return it->second > 1;
182 for(
size_t i=0; i<obj->
value().size(); ++i)
211 for(
size_t i=0; i<list->
value().size(); ++i)
227 if (arr->
value().size() > 0)
229 std::vector<unsigned char> encoded;
232 mOutputFile->
writeUInt8(&encoded[0], encoded.size());
238 for(
size_t i=0; i<count; ++i)
240 float f = (float)in[i];
241 if ((
double)f != in[i])
259 if (arr->
value().size())
266 std::vector<float> floats;
267 floats.resize(arr->
value().size());
268 for(
size_t i=0; i<arr->
value().size(); ++i)
269 floats[i] = (
float)arr->
value()[i];
270 mOutputFile->
writeFloat(&floats[0], floats.size());
273 std::vector<unsigned char> zipped;
276 mOutputFile->
write(&zipped[0], zipped.size());
298 unsigned char vlx_identifier[] = { 0xAB,
'V',
'L',
'X', 0xBB, 0x0D, 0x0A, 0x1A, 0x0A };
300 mOutputFile->
write(vlx_identifier,
sizeof(vlx_identifier));
302 mOutputFile->
write(
"ascii", 5+1);
308 size_t len = strlen(str);
310 mOutputFile->
write(str, len);
318 const unsigned char nxt_flag = 0x80;
319 const unsigned char neg_flag = 0x40;
320 unsigned char bytes[12]; memset(bytes, 0,
sizeof(bytes));
321 unsigned char* byte = bytes;
328 *byte |= n & 0x3F; n >>= 6;
329 *byte |= n ? nxt_flag : 0;
334 *byte = n & 0x7F; n >>= 7;
335 *byte |= n ? nxt_flag : 0;
338 mOutputFile->
write(bytes, byte - bytes);
344 const unsigned char nxt_flag = 0x80;
345 const unsigned char neg_flag = 0x40;
347 for(
int i=0; i<count; ++i)
349 unsigned char byte = 0;
350 long long n = val[i];
357 byte |= n & 0x3F; n >>= 6;
358 byte |= n ? nxt_flag : 0;
363 byte = n & 0x7F; n >>= 7;
364 byte |= n ? nxt_flag : 0;
370 void setIDSet(std::map< std::string, int >* uids) { mIDSet = uids; }
372 std::map< std::string, int >*
uidSet() {
return mIDSet; }
374 const std::map< std::string, int >*
uidSet()
const {
return mIDSet; }
391 std::map< std::string, int >* mIDSet;
VLXRawtextBlock * getRawtextBlock()
bool needsDoublePrecision(const double *in, size_t count)
void setOutputFile(vl::VirtualFile *file)
Wrapper for all VLX value types.
An abstract class representing a file.
long long writeDouble(double data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
virtual void acceptVisitor(Visitor *v)
long long writeUInt16(unsigned short data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
void encodeIntegers(long long *val, int count, std::vector< unsigned char > &out)
const std::map< std::string, int > * uidSet() const
long long writeUInt8(unsigned char data)
Writes a single entry. Returns the number of bytes written.
An array of 64 bits floating point numbers, can also have a tag.
void setIDSet(std::map< std::string, int > *uids)
const vl::VirtualFile * outputFile() const
long long writeSInt64(long long data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
const std::string & getID() const
virtual void acceptVisitor(Visitor *v)
long long writeFloat(float data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
VLXStructure * getStructure()
bool isUsed(const std::string &uid)
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
virtual void close()=0
Closes the file.
long long writeUInt32(unsigned int data, bool little_endian_data=true)
Writes a single entry. Returns the number of bytes written.
std::vector< VLXValue > & value()
std::map< std::string, int > * uidSet()
VisitorExportToVLB(vl::VirtualFile *file=NULL)
long long getInteger() const
A list of key/VLXValue pairs, can also have a tag.
virtual void visitList(VLXList *list)
A simple sequence of VLXValue objects, can also have a tag.
#define VL_SERIALIZER_VERSION
const std::string & tag() const
Translates a VLX hierarchy into VLB format writing to the provided VirtualFile.
void writeValue(VLXValue &value)
virtual void visitStructure(VLXStructure *obj)
long long write(const void *buffer, long long byte_count)
Writes byte_count bytes to a file. Returns the number of bytes actually written.
virtual bool open(EOpenMode mode)=0
Opens the file in the specified mode.
virtual void visitArray(VLXArrayInteger *arr)
virtual void acceptVisitor(Visitor *v)
std::vector< KeyValue > & value()
An array of 64 bits integers, can also have a tag.
void writeInteger(long long n)
std::vector< T > & value()
Base class for all visitors visiting a VLX hierarchy.
const std::string & uid() const
vl::VirtualFile * outputFile()
VLXArrayInteger * getArrayInteger()
bool isVisited(void *node)
const std::string & getString() const
virtual void acceptVisitor(Visitor *v)
VLXArrayReal * getArrayReal()
virtual void visitArray(VLXArrayReal *arr)
bool compress(const void *data, size_t size, std::vector< unsigned char > &out, int level)
void writeString(const char *str)
const std::string & getIdentifier() const