Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

LoadSave Class Reference

Intended as an interface to allow easy and portable serialization operations. More...

#include <LoadSave.h>

Inheritance diagram for LoadSave:

Detailed Description

Intended as an interface to allow easy and portable serialization operations.

Generally, for triggering serialization of a LoadSave subclass, all you need to know is to call saveFile() / saveBuffer() in order to have the class serialize itself, and loadFile() / loadBuffer() in order to reload the data.

When saveFile() is called, it checks that it can open the specified file, and then calls saveFileStream() with the open file. This will then check getBinSize(), create a buffer of that size, and call saveBuffer() to do the actual work of serialization into that buffer. If saveBuffer is successful, saveFileStream() copies the buffer out to the file, and then finally, saveFile() will close the file.

This means when writing a class which requires serialization, you need only define 3 functions: loadBuffer(), saveBuffer(), and getBinSize(). If you are saving directly into a file and need the highest possible performance, overriding loadFileStream and saveFileStream and reimplementing the serialization operations into the file stream can save a buffer copy. Usually this is not a performance issue, but the interface is there if you need it.

The recommended style for using LoadSave in classes with multiple levels of inheritance is to have each subclass first call the superclass's implementation (e.g. of loadBuffer/saveBuffer), and then save their own data afterward. This compartmentalizes the data access and makes it easy to maintain - the code that serializes is right in with the code that defines the structure. If you change one, it's easy to see where to change the other. And protection between levels of inheritance is retained. (This is why I say it's highly flexible/maintainable, but poor readability since the serialization is all broken up.)

I also recommend putting a little string header at the beginning of each class's info via saveCreator() and checkCreator(). This will allow polymorphism when loading files (you can look at the string and create the appropriate type) but also is handy for checking field alignment... it's a lot easier to tell how much you're offset within a string than to do the same with a stream of binary values. Further, you can use the string as version information if you want to be backward compatible in future versions of your code.

LoadSave provides a series of encode() and decode() functions for all the primitive types. This will handle copying the value into the buffer or file, and can provide platform independence through byte swapping if needed (there's a compiler flag you can set for platforms that have the opposite byte order, although this should be autodetected from the system headers). Most of these are pretty straightfoward - an int is just 4 bytes and so on.

However, there's one caveat that I want to make sure to point out if you have to write parsing code in say, Java. Strings are encoded by first storing an int to hold the string's length, then the string itself, and then a null character. This adds 5 bytes to the length of any string, but makes loading the files much easier/faster - you can call string library functions directly on the buffer if it's already in memory since the string is null terminated, or can allocate memory to hold the string with one pass from a file because you'll know the size of the string before you get to it.

Of course, the string serialization format is transparent if you just stick to using LoadSave's encode/decode functions to parse it.

Definition at line 99 of file LoadSave.h.

List of all members.

Public Member Functions

Constructors/Destructors

 LoadSave ()
 constructor
virtual ~LoadSave ()
 destructor
Buffer Operations

These are useful for sending the data across a network as well as to a file.
These three functions (getBinSize(), loadBuffer(), saveBuffer() ) are the only ones that MUST be overridden, as the file stream versions can be based on calling these. However, you can override the file stream versions as well if speed or temp. memory is tight.

virtual unsigned int getBinSize () const =0
 Calculates space needed to save - if you can't precisely add up the size, just make sure to overestimate and things will still work.
virtual unsigned int loadBuffer (const char buf[], unsigned int len, const char *filename=NULL)=0
 Load from a saved buffer in memory.
virtual unsigned int saveBuffer (char buf[], unsigned int len) const =0
 Save to a given buffer in memory.
File Operations

These are called to load and save to files

virtual unsigned int loadFile (const char *filename)
 initiate opening of the specified file and loading/saving of all appropriate information.
virtual unsigned int saveFile (const char *filename) const
 initiate opening of the specified file and loading/saving of all appropriate information.
virtual unsigned int loadFileStream (FILE *f, const char *filename=NULL)
 Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.
virtual unsigned int saveFileStream (FILE *f) const
 Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.
virtual unsigned int saveStream (std::ostream &os) const
 Writes into a std::ostream, does not flush.
virtual unsigned int LoadFile (const char *filename) ATTR_deprecated
 deprecated, use loadFile() instead (refactored to standardize capitalization style)
virtual unsigned int SaveFile (const char *filename) const ATTR_deprecated
 deprecated, use saveFile() instead (refactored to standardize capitalization style)
Creator Utilities

These are for putting creator codes (a uniquely identifying string, e.g. the name of the class) at the beginning of your data -- doing so is a good idea to allow polymorphism, version detection (backward compatability), or just a sanity check

virtual unsigned int creatorSize (const char creator[]) const
 Returns size of the creator code.
virtual unsigned int checkCreator (const char *creator, const char buf[], unsigned int len, bool isLoading=true) const throw ()
 Compares the creator code in the buffer to the one given.
virtual bool checkCreatorInc (const char *creator, const char *&buf, unsigned int &len, bool isLoading=true) const throw ()
 Compares the creator code in the buffer to the one given, increments buf and decrements len if it matches.
virtual void checkCreatorIncT (const char *creator, const char *&buf, unsigned int &len, bool isLoading=true) const throw (std::runtime_error)
 Compares the creator code in the buffer to the one given, increments buf and decrements len if it matches, throws std::runtime_error if it doesn't match.
virtual unsigned int checkCreator (const char *creator, FILE *f, bool isLoading=true) const throw ()
 Compares the creator code in the file to the one given, will attempt to reset the file position if fails (so you can check for one of several types).
virtual unsigned int saveCreator (const char *creator, char buf[], unsigned int len) const throw ()
 Saves a creator code to a buffer.
virtual bool saveCreatorInc (const char *creator, char *&buf, unsigned int &len) const throw ()
 Saves a creator code to a buffer, increments buf and decrements len by the amount used.
virtual void saveCreatorIncT (const char *creator, char *&buf, unsigned int &len) const throw (std::runtime_error)
 Saves a creator code to a buffer, increments buf and decrements len by the amount used.
virtual unsigned int saveCreator (const char *creator, FILE *f) const throw ()
 Saves a creator code directly to a file.

Static Public Member Functions

static bool checkInc (int res, const char *&buf, unsigned int &len) throw ()
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, returns false.
static bool checkInc (int res, const char *&buf, unsigned int &len, const char *msg,...) __attribute__((format(printf throw ()
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, displays the specified message on stderr and returns false.
static bool static bool checkInc (int res, char *&buf, unsigned int &len) throw ()
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, returns false.
static bool checkInc (int res, char *&buf, unsigned int &len, const char *msg,...) __attribute__((format(printf throw ()
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, displays the specified message on stderr and returns false.
static bool static void checkIncT (int res, const char *&buf, unsigned int &len, const char *msg="LoadSave::check underflow",...) __attribute__((format(printf throw (std::length_error)
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, throws a std::length_error with the specified message.
static bool static void static void checkIncT (int res, char *&buf, unsigned int &len, const char *msg="LoadSave::check underflow",...) __attribute__((format(printf throw (std::length_error)
 Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, throws a std::length_error with the specified message.
template<class T >
static bool static void static
void static bool 
encodeInc (const T &value, char *&buf, unsigned int &cap) throw ()
 Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.
template<class T >
static bool encodeInc (const T &value, char *&buf, unsigned int &cap, const char *msg,...) __attribute__((format(printf throw ()
 Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.
template<class T >
static bool static bool decodeInc (T &value, const char *&buf, unsigned int &cap) throw ()
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.
template<class T >
static bool decodeInc (T &value, const char *&buf, unsigned int &cap, const char *msg,...) __attribute__((format(printf throw ()
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.
template<class T >
static bool static bool decodeInc (T &value, char *&buf, unsigned int &cap) throw ()
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.
template<class T >
static bool decodeInc (T &value, char *&buf, unsigned int &cap, const char *msg,...) __attribute__((format(printf throw ()
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.
template<class T >
static bool static void encodeIncT (const T &value, char *&buf, unsigned int &cap, const char *msg="LoadSave::encode overflow",...) __attribute__((format(printf throw (std::length_error)
 Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.
template<class T >
static bool static void static void decodeIncT (T &value, const char *&buf, unsigned int &cap, const char *msg="LoadSave::decode underflow",...) __attribute__((format(printf throw (std::length_error)
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.
template<class T >
static bool static void static
void static void 
decodeIncT (T &value, char *&buf, unsigned int &cap, const char *msg="LoadSave::decode underflow",...) __attribute__((format(printf throw (std::length_error)
 Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.
static bool static void static
void static void static bool 
chkAdvance (int res, const char **buf, unsigned int *len, const char *msg,...) ATTR_deprecated __attribute__((format(printf
 deprecated, use checkInc() instead (provides less error-prone interface (NULL not allowed), mixes better with other new *Inc varients)
Methods to detect the size member fields

These are expected to be called from within your own getBinSize implementation in order to add up the size of all the member fields. Use these instead of sizeof() because this allows proper handling of some oddball conditions (bool isn't 1 byte on some platforms, use strlen on char*, etc.)

static unsigned int getSerializedSize (const LoadSave &x) throw ()
 returns the serialized size of the argument
static unsigned int getSerializedSize (const std::string &x) throw ()
 returns the serialized size of the argument
static unsigned int getSerializedSize (const char *x) throw ()
 returns the serialized size of the argument
static unsigned int getSerializedSize (const void *) throw ()
 returns the serialized size of the argument
static unsigned int getSerializedSize (const bool &) throw ()
 returns the serialized size of the argument
template<class T >
static unsigned int getSerializedSize (const T &x) throw ()
 returns the serialized size of the argument
template<class T >
static unsigned int getSerializedSize ()
 this version lets you get the theoretical size of a type, but beware it will throw invalid_argument if you pass a string type! (can't tell the size of the string without an actual instance...)
Encode/Decode Utils

encode/decode cross-platform compatable (byte order consistancy)

static unsigned int encode (const LoadSave &x, char buf[], unsigned int cap)
 encode or decode with byte order consistency
static unsigned int decode (LoadSave &x, const char buf[], unsigned int cap)
 encode or decode with byte order consistency
static unsigned int encode (const LoadSave &x, FILE *f)
 encode or decode with byte order consistency
static unsigned int decode (LoadSave &x, FILE *f)
 encode or decode with byte order consistency
static unsigned int encode (const double x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (double &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const double x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (double &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const float x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (float &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const float x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (float &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const long long x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (long long &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const long long x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (long long &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned long long x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned long long &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned long long x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned long long &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const long x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (long &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const long x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (long &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned long x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned long &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned long x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned long &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const int x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (int &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const int x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (int &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned int x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned int &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned int x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned int &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const short x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (short &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const short x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (short &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned short x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned short &x, const char buf[], unsigned int cap)
 encode or decode with byte order consistency
static unsigned int encode (const unsigned short x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned short &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const std::string &x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (std::string &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const std::string &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (std::string &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const char *x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (char *&x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const char *x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (char *&x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const char x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (char &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const char x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (char &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const unsigned char x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned char &x, const char buf[], unsigned int cap)
 encode or decode with byte order consistency
static unsigned int encode (const unsigned char x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (unsigned char &x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const bool x, char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int decode (bool &x, const char buf[], unsigned int cap) throw ()
 encode or decode with byte order consistency
static unsigned int encode (const bool x, FILE *f) throw ()
 encode or decode with byte order consistency
static unsigned int decode (bool &x, FILE *f) throw ()
 encode or decode with byte order consistency

Static Public Attributes

static const unsigned int stringpad = sizeof(unsigned int)+1
 This is the amount of extra space needed to store a string (int for len of string plus 1 for.

Static Protected Member Functions

template<class T >
static void byteswap (T &dstc, const T &srcc) throw ()
 templated function to swap byte ordering, should allow compiler to unroll the loop; warning don't use this if src==dst!!!

Constructor & Destructor Documentation

LoadSave::LoadSave (  ) 

constructor

Definition at line 106 of file LoadSave.h.

LoadSave::~LoadSave (  )  [virtual]

destructor

Definition at line 7 of file LoadSave.cc.


Member Function Documentation

template<class T >
static void LoadSave::byteswap ( T &  dstc,
const T &  srcc 
) throw () [static, protected]

templated function to swap byte ordering, should allow compiler to unroll the loop; warning don't use this if src==dst!!!

Definition at line 499 of file LoadSave.h.

Referenced by EventBase::makeClassTypeID().

unsigned int LoadSave::checkCreator ( const char *  creator,
FILE *  f,
bool  isLoading = true 
) const throw () [virtual]

Compares the creator code in the file to the one given, will attempt to reset the file position if fails (so you can check for one of several types).

Parameters:
creator what the creator should be
f the file pointer to check
isLoading set this to true if you want to output a warning if it doesn't match
Returns:
the number of bytes consumed by the creator code, or 0 if it didn't match

Definition at line 34 of file LoadSave.cc.

unsigned int LoadSave::checkCreator ( const char *  creator,
const char  buf[],
unsigned int  len,
bool  isLoading = true 
) const throw () [virtual]

Compares the creator code in the buffer to the one given.

Parameters:
creator what the creator should be
buf the buffer to check
len the size remaining in the buffer
isLoading set this to true if you want to output a warning if it doesn't match
Returns:
the number of bytes used by the creator, or 0 if it didn't match

Definition at line 9 of file LoadSave.cc.

Referenced by RemoteRouter::forwardEvent(), KoduEventBase::getInstance(), LookoutIREvent::loadBinaryBuffer(), and LookoutPointAtEvent::loadBinaryBuffer().

bool LoadSave::checkCreatorInc ( const char *  creator,
const char *&  buf,
unsigned int &  len,
bool  isLoading = true 
) const throw () [virtual]

Compares the creator code in the buffer to the one given, increments buf and decrements len if it matches.

Parameters:
creator what the creator should be
buf the buffer to check
len the size remaining in the buffer
isLoading set this to true if you want to output a warning if it doesn't match
Returns:
true if it matched, false otherwise

Definition at line 20 of file LoadSave.cc.

Referenced by VisionObjectEvent::loadBinaryBuffer(), TimerEvent::loadBinaryBuffer(), TextMsgEvent::loadBinaryBuffer(), PitchEvent::loadBinaryBuffer(), LocomotionEvent::loadBinaryBuffer(), KoduSayEvent::loadBinaryBuffer(), KoduGiveEvent::loadBinaryBuffer(), KoduEventBase::loadBinaryBuffer(), EventBase::loadBinaryBuffer(), DataEvent< T, TID >::loadBinaryBuffer(), SegmentedColorGenerator::loadBuffer(), and FilterBankGenerator::loadBuffer().

void LoadSave::checkCreatorIncT ( const char *  creator,
const char *&  buf,
unsigned int &  len,
bool  isLoading = true 
) const throw (std::runtime_error) [virtual]

Compares the creator code in the buffer to the one given, increments buf and decrements len if it matches, throws std::runtime_error if it doesn't match.

Parameters:
creator what the creator should be
buf the buffer to check
len the size remaining in the buffer
isLoading set this to true if you want to output a warning if it doesn't match

Definition at line 24 of file LoadSave.cc.

bool LoadSave::checkInc ( int  res,
char *&  buf,
unsigned int &  len,
const char *  msg,
  ... 
) throw () [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, displays the specified message on stderr and returns false.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
msg Error to display if res is less than or equal to zero
Returns:
true if everything worked, false otherwise

Definition at line 579 of file LoadSave.h.

bool LoadSave::checkInc ( int  res,
char *&  buf,
unsigned int &  len 
) throw () [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, returns false.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
Returns:
true if everything worked, false otherwise

Definition at line 571 of file LoadSave.h.

bool LoadSave::checkInc ( int  res,
const char *&  buf,
unsigned int &  len,
const char *  msg,
  ... 
) throw () [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, displays the specified message on stderr and returns false.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
msg Error to display if res is less than or equal to zero
Returns:
true if everything worked, false otherwise

Definition at line 557 of file LoadSave.h.

bool LoadSave::checkInc ( int  res,
const char *&  buf,
unsigned int &  len 
) throw () [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, returns false.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
Returns:
true if everything worked, false otherwise

Definition at line 549 of file LoadSave.h.

Referenced by checkInc(), chkAdvance(), RemoteRouter::forwardEvent(), KoduEventBase::getInstance(), VisionObjectEvent::loadBinaryBuffer(), TimerEvent::loadBinaryBuffer(), TextMsgEvent::loadBinaryBuffer(), PitchEvent::loadBinaryBuffer(), LocomotionEvent::loadBinaryBuffer(), KoduSayEvent::loadBinaryBuffer(), KoduGiveEvent::loadBinaryBuffer(), KoduEventBase::loadBinaryBuffer(), DataEvent< T, TID >::loadBinaryBuffer(), WaypointEngine::loadBuffer(), SegmentedColorGenerator::loadBuffer(), RLEGenerator::loadBuffer(), RegionGenerator::loadBuffer(), RawCameraGenerator::loadBuffer(), MotionSequenceEngine::loadBuffer(), JPEGGenerator::loadBuffer(), InterleavedYUVGenerator::loadBuffer(), BufferedImageGenerator::loadBuffer(), VisionObjectEvent::saveBinaryBuffer(), TimerEvent::saveBinaryBuffer(), TextMsgEvent::saveBinaryBuffer(), PitchEvent::saveBinaryBuffer(), LocomotionEvent::saveBinaryBuffer(), KoduSayEvent::saveBinaryBuffer(), KoduGiveEvent::saveBinaryBuffer(), KoduEventBase::saveBinaryBuffer(), DataEvent< T, TID >::saveBinaryBuffer(), WaypointEngine::saveBuffer(), SegmentedColorGenerator::saveBuffer(), RLEGenerator::saveBuffer(), RegionGenerator::saveBuffer(), RawCameraGenerator::saveBuffer(), PostureEngine::saveBuffer(), PNGGenerator::saveBuffer(), MotionSequenceEngine::saveBuffer(), JPEGGenerator::saveBuffer(), InterleavedYUVGenerator::saveBuffer(), BufferedImageGenerator::saveBuffer(), RawCam::writeColor(), DepthCam::writeDepth(), RegionCam::writeRegions(), SegCam::writeRLE(), SegCam::writeSeg(), and RawCam::writeSingleChannel().

void LoadSave::checkIncT ( int  res,
char *&  buf,
unsigned int &  len,
const char *  msg = "LoadSave::check underflow",
  ... 
) throw (std::length_error) [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ). If res is 0, throws a std::length_error with the specified message.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
msg Error message to throw in the std::length_error if res is less than or equal to zero

Definition at line 615 of file LoadSave.h.

void LoadSave::checkIncT ( int  res,
const char *&  buf,
unsigned int &  len,
const char *  msg = "LoadSave::check underflow",
  ... 
) throw (std::length_error) [static]

Handy for checking results from functions which manipulate a buffer (see also encodeInc()/decodeInc() ) If res is 0, throws a std::length_error with the specified message.

Doesn't have to be used with encode/decode, also handy with snprintf, sscanf type operations using n

Parameters:
res number of bytes used, or 0 if error
buf pointer to current position in buffer, will be incremented by res bytes
len number of bytes remaining between current place and end of buffer, will be decremented by res bytes
msg Error message to throw in the std::length_error if res is less than or equal to zero

Definition at line 593 of file LoadSave.h.

bool LoadSave::chkAdvance ( int  res,
const char **  buf,
unsigned int *  len,
const char *  msg,
  ... 
) [static]

deprecated, use checkInc() instead (provides less error-prone interface (NULL not allowed), mixes better with other new *Inc varients)

Definition at line 189 of file LoadSave.cc.

virtual unsigned int LoadSave::creatorSize ( const char  creator[]  )  const [virtual]
static unsigned int LoadSave::decode ( bool &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 495 of file LoadSave.h.

static unsigned int LoadSave::decode ( bool &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 493 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned char &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 490 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned char &  x,
const char  buf[],
unsigned int  cap 
) [static]

encode or decode with byte order consistency

Definition at line 488 of file LoadSave.h.

static unsigned int LoadSave::decode ( char &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 486 of file LoadSave.h.

static unsigned int LoadSave::decode ( char &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 484 of file LoadSave.h.

static unsigned int LoadSave::decode ( char *&  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 481 of file LoadSave.h.

Referenced by decode().

static unsigned int LoadSave::decode ( char *&  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 479 of file LoadSave.h.

Referenced by decode().

static unsigned int LoadSave::decode ( std::string &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 476 of file LoadSave.h.

Referenced by decode().

static unsigned int LoadSave::decode ( std::string &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 474 of file LoadSave.h.

Referenced by decode().

static unsigned int LoadSave::decode ( unsigned short &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 461 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned short &  x,
const char  buf[],
unsigned int  cap 
) [static]

encode or decode with byte order consistency

Definition at line 459 of file LoadSave.h.

static unsigned int LoadSave::decode ( short &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 457 of file LoadSave.h.

static unsigned int LoadSave::decode ( short &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 455 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned int &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 452 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned int &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 450 of file LoadSave.h.

static unsigned int LoadSave::decode ( int &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 448 of file LoadSave.h.

static unsigned int LoadSave::decode ( int &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 446 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned long &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 443 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned long &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 441 of file LoadSave.h.

static unsigned int LoadSave::decode ( long &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 439 of file LoadSave.h.

static unsigned int LoadSave::decode ( long &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 437 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned long long &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 434 of file LoadSave.h.

static unsigned int LoadSave::decode ( unsigned long long &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 432 of file LoadSave.h.

static unsigned int LoadSave::decode ( long long &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 430 of file LoadSave.h.

static unsigned int LoadSave::decode ( long long &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 428 of file LoadSave.h.

static unsigned int LoadSave::decode ( float x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 425 of file LoadSave.h.

static unsigned int LoadSave::decode ( float x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 423 of file LoadSave.h.

static unsigned int LoadSave::decode ( double &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 420 of file LoadSave.h.

static unsigned int LoadSave::decode ( double &  x,
const char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 418 of file LoadSave.h.

static unsigned int LoadSave::decode ( LoadSave x,
FILE *  f 
) [static]

encode or decode with byte order consistency

Definition at line 365 of file LoadSave.h.

static unsigned int LoadSave::decode ( LoadSave x,
const char  buf[],
unsigned int  cap 
) [static]

encode or decode with byte order consistency

Definition at line 363 of file LoadSave.h.

Referenced by decodeIncT(), LookoutIREvent::loadBinaryBuffer(), LookoutPointAtEvent::loadBinaryBuffer(), and BufferedImageGenerator::loadBuffer().

template<class T >
bool LoadSave::decodeInc ( T &  value,
char *&  buf,
unsigned int &  cap,
const char *  msg,
  ... 
) throw () [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity
Returns:
true if everything worked, false otherwise

Definition at line 707 of file LoadSave.h.

template<class T >
bool LoadSave::decodeInc ( T &  value,
char *&  buf,
unsigned int &  cap 
) throw () [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
Returns:
true if everything worked, false otherwise

Definition at line 692 of file LoadSave.h.

template<class T >
bool LoadSave::decodeInc ( T &  value,
const char *&  buf,
unsigned int &  cap,
const char *  msg,
  ... 
) throw () [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity
Returns:
true if everything worked, false otherwise

Definition at line 680 of file LoadSave.h.

template<class T >
bool LoadSave::decodeInc ( T &  value,
const char *&  buf,
unsigned int &  cap 
) throw () [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
Returns:
true if everything worked, false otherwise

Definition at line 665 of file LoadSave.h.

Referenced by SegmentedColorGenerator::decodeColorsInc(), EventTranslator::decodeEvent(), decodeInc(), VisionObjectEvent::loadBinaryBuffer(), TimerEvent::loadBinaryBuffer(), TextMsgEvent::loadBinaryBuffer(), PitchEvent::loadBinaryBuffer(), LocomotionEvent::loadBinaryBuffer(), KoduSayEvent::loadBinaryBuffer(), KoduGiveEvent::loadBinaryBuffer(), KoduEventBase::loadBinaryBuffer(), EventBase::loadBinaryBuffer(), RLEGenerator::loadBuffer(), RegionGenerator::loadBuffer(), RawCameraGenerator::loadBuffer(), PNGGenerator::loadBuffer(), JPEGGenerator::loadBuffer(), InterleavedYUVGenerator::loadBuffer(), and FilterBankGenerator::loadBuffer().

template<class T >
void LoadSave::decodeIncT ( T &  value,
char *&  buf,
unsigned int &  cap,
const char *  msg = "LoadSave::decode underflow",
  ... 
) throw (std::length_error) [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity

Definition at line 778 of file LoadSave.h.

template<class T >
void LoadSave::decodeIncT ( T &  value,
const char *&  buf,
unsigned int &  cap,
const char *  msg = "LoadSave::decode underflow",
  ... 
) throw (std::length_error) [static]

Decodes value from the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.

Parameters:
value the value to decode into, must be a primitive or a LoadSave subclass (i.e. a value for which decode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity

Definition at line 749 of file LoadSave.h.

static unsigned int LoadSave::encode ( const bool  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 494 of file LoadSave.h.

static unsigned int LoadSave::encode ( const bool  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 492 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned char  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 489 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned char  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 487 of file LoadSave.h.

static unsigned int LoadSave::encode ( const char  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 485 of file LoadSave.h.

static unsigned int LoadSave::encode ( const char  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 483 of file LoadSave.h.

static unsigned int LoadSave::encode ( const char *  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 480 of file LoadSave.h.

Referenced by encode().

static unsigned int LoadSave::encode ( const char *  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 478 of file LoadSave.h.

Referenced by encode().

static unsigned int LoadSave::encode ( const std::string &  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 475 of file LoadSave.h.

Referenced by encode().

static unsigned int LoadSave::encode ( const std::string &  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 473 of file LoadSave.h.

Referenced by encode().

static unsigned int LoadSave::encode ( const unsigned short  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 460 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned short  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 458 of file LoadSave.h.

static unsigned int LoadSave::encode ( const short  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 456 of file LoadSave.h.

static unsigned int LoadSave::encode ( const short  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 454 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned int  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 451 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned int  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 449 of file LoadSave.h.

static unsigned int LoadSave::encode ( const int  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 447 of file LoadSave.h.

static unsigned int LoadSave::encode ( const int  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 445 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned long  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 442 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned long  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 440 of file LoadSave.h.

static unsigned int LoadSave::encode ( const long  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 438 of file LoadSave.h.

static unsigned int LoadSave::encode ( const long  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 436 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned long long  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 433 of file LoadSave.h.

static unsigned int LoadSave::encode ( const unsigned long long  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 431 of file LoadSave.h.

static unsigned int LoadSave::encode ( const long long  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 429 of file LoadSave.h.

static unsigned int LoadSave::encode ( const long long  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 427 of file LoadSave.h.

static unsigned int LoadSave::encode ( const float  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 424 of file LoadSave.h.

static unsigned int LoadSave::encode ( const float  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 422 of file LoadSave.h.

static unsigned int LoadSave::encode ( const double  x,
FILE *  f 
) throw () [static]

encode or decode with byte order consistency

Definition at line 419 of file LoadSave.h.

static unsigned int LoadSave::encode ( const double  x,
char  buf[],
unsigned int  cap 
) throw () [static]

encode or decode with byte order consistency

Definition at line 417 of file LoadSave.h.

static unsigned int LoadSave::encode ( const LoadSave x,
FILE *  f 
) [static]

encode or decode with byte order consistency

Definition at line 364 of file LoadSave.h.

static unsigned int LoadSave::encode ( const LoadSave x,
char  buf[],
unsigned int  cap 
) [static]
template<class T >
bool LoadSave::encodeInc ( const T &  value,
char *&  buf,
unsigned int &  cap,
const char *  msg,
  ... 
) throw () [static]

Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, displays the specified message on stderr and returns false.

Parameters:
value the value to encode, must be a primitive or a LoadSave subclass (i.e. a value for which encode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity
Returns:
true if everything worked, false otherwise

Definition at line 653 of file LoadSave.h.

template<class T >
bool LoadSave::encodeInc ( const T &  value,
char *&  buf,
unsigned int &  cap 
) throw () [static]

Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, returns false.

Parameters:
value the value to encode, must be a primitive or a LoadSave subclass (i.e. a value for which encode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
Returns:
true if everything worked, false otherwise

Definition at line 638 of file LoadSave.h.

Referenced by WorldStateSerializerBehavior::doEvent(), SegmentedColorGenerator::encodeColorsInc(), EventTranslator::encodeEvent(), encodeInc(), SegCam::openPacket(), RegionCam::openPacket(), RawCam::openPacket(), DepthCam::openPacket(), VisionObjectEvent::saveBinaryBuffer(), TimerEvent::saveBinaryBuffer(), TextMsgEvent::saveBinaryBuffer(), PitchEvent::saveBinaryBuffer(), LocomotionEvent::saveBinaryBuffer(), KoduSayEvent::saveBinaryBuffer(), KoduGiveEvent::saveBinaryBuffer(), KoduEventBase::saveBinaryBuffer(), EventBase::saveBinaryBuffer(), RLEGenerator::saveBuffer(), RegionGenerator::saveBuffer(), RawCameraGenerator::saveBuffer(), PNGGenerator::saveBuffer(), JPEGGenerator::saveBuffer(), InterleavedYUVGenerator::saveBuffer(), FilterBankGenerator::saveBuffer(), BufferedImageGenerator::saveBuffer(), and RawCam::writeColor().

template<class T >
void LoadSave::encodeIncT ( const T &  value,
char *&  buf,
unsigned int &  cap,
const char *  msg = "LoadSave::encode overflow",
  ... 
) throw (std::length_error) [static]

Encodes value into the buffer and if successful, increments the the buffer position and decrements the capacity. If unsuccessful, throws a std::length_error with the specified message.

Parameters:
value the value to encode, must be a primitive or a LoadSave subclass (i.e. a value for which encode() is defined)
buf pointer to current position in buffer, will be incremented by the serialized size of value
cap number of bytes remain between current place and end of buffer, will be decremented by the serialized size of value
msg Error to display if buf did not have enough capacity

Definition at line 720 of file LoadSave.h.

virtual unsigned int LoadSave::getBinSize (  )  const [pure virtual]

Calculates space needed to save - if you can't precisely add up the size, just make sure to overestimate and things will still work.

getBinSize is used for reserving buffers during serialization, but does not necessarily determine the actual size of what is written -- the return value of saveBuffer() specifies that after the data actually has been written. If getBinSize overestimates, the extra memory allocation is only temporary, no extra filler bytes are actually stored.

Returns:
number of bytes read/written, 0 if error (or empty)

Implemented in DataEvent< T, TID >, EventBase, KoduEventBase, KoduGiveEvent, KoduSayEvent, LocomotionEvent, LookoutPointAtEvent, LookoutIREvent, PitchEvent, TextMsgEvent, TimerEvent, VisionObjectEvent, CMPackWalkMC, MotionSequenceEngine, PostureEngine, WaypointEngine, XMLLoadSave, BufferedImageGenerator, CDTGenerator, FilterBankGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, SegmentedColorGenerator, and DataEvent< T >.

Referenced by saveFileStream(), and saveStream().

template<class T >
static unsigned int LoadSave::getSerializedSize (  )  [static]

this version lets you get the theoretical size of a type, but beware it will throw invalid_argument if you pass a string type! (can't tell the size of the string without an actual instance...)

Definition at line 290 of file LoadSave.h.

Referenced by EventTranslator::encodeEvent(), VisionObjectEvent::getBinSize(), TimerEvent::getBinSize(), TextMsgEvent::getBinSize(), PitchEvent::getBinSize(), LocomotionEvent::getBinSize(), KoduSayEvent::getBinSize(), KoduEventBase::getBinSize(), EventBase::getBinSize(), DataEvent< T, TID >::getBinSize(), BufferedImageGenerator::getBinSize(), and CameraStreamBehavior::sendSensors().

template<class T >
static unsigned int LoadSave::getSerializedSize ( const T &  x  )  throw () [static]

returns the serialized size of the argument

Definition at line 288 of file LoadSave.h.

static unsigned int LoadSave::getSerializedSize ( const bool &   )  throw () [static]

returns the serialized size of the argument

Definition at line 287 of file LoadSave.h.

static unsigned int LoadSave::getSerializedSize ( const void *   )  throw () [static]

returns the serialized size of the argument

Definition at line 286 of file LoadSave.h.

static unsigned int LoadSave::getSerializedSize ( const char *  x  )  throw () [static]

returns the serialized size of the argument

Definition at line 285 of file LoadSave.h.

static unsigned int LoadSave::getSerializedSize ( const std::string &  x  )  throw () [static]

returns the serialized size of the argument

Definition at line 284 of file LoadSave.h.

static unsigned int LoadSave::getSerializedSize ( const LoadSave x  )  throw () [static]

returns the serialized size of the argument

Definition at line 283 of file LoadSave.h.

virtual unsigned int LoadSave::loadBuffer ( const char  buf[],
unsigned int  len,
const char *  filename = NULL 
) [pure virtual]

Load from a saved buffer in memory.

Parameters:
buf pointer to the memory where you should begin loading
len length of buf available (this isn't necessarily all yours, there might be other things following your data)
Returns:
the number of bytes actually used

Implemented in EventBase, CMPackWalkMC, MotionSequenceEngine, PostureEngine, PostureMC, WaypointEngine, Config, XMLLoadSave, BufferedImageGenerator, CDTGenerator, FilterBankGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator.

Referenced by decode(), and loadFileStream().

unsigned int LoadSave::LoadFile ( const char *  filename  )  [virtual]

deprecated, use loadFile() instead (refactored to standardize capitalization style)

Definition at line 187 of file LoadSave.cc.

unsigned int LoadSave::loadFile ( const char *  filename  )  [virtual]

initiate opening of the specified file and loading/saving of all appropriate information.

Parameters:
filename the file to load/save
Returns:
number of bytes read/written, 0 if error (or empty)

Reimplemented in EventBase, KoduConfig, CMPackWalkMC, WaypointEngine, Config, and XMLLoadSave.

Definition at line 73 of file LoadSave.cc.

Referenced by LoadFile().

unsigned int LoadSave::loadFileStream ( FILE *  f,
const char *  filename = NULL 
) [virtual]

Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.

Parameters:
f a pointer to the file to load
Returns:
number of bytes read, 0 if error (or empty)

Reimplemented in EventBase, Config, and XMLLoadSave.

Definition at line 111 of file LoadSave.cc.

Referenced by decode(), and loadFile().

virtual unsigned int LoadSave::saveBuffer ( char  buf[],
unsigned int  len 
) const [pure virtual]

Save to a given buffer in memory.

Parameters:
buf pointer to the memory where you should begin writing
len length of buf available. (this isn't necessarily all yours, constrain yourself to what you returned in getBinSize() )
Returns:
the number of bytes actually used

Implemented in EventBase, CMPackWalkMC, MotionSequenceEngine, PostureEngine, WaypointEngine, XMLLoadSave, BufferedImageGenerator, CDTGenerator, FilterBankGenerator, InterleavedYUVGenerator, JPEGGenerator, PNGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator.

Referenced by saveFileStream(), and saveStream().

unsigned int LoadSave::saveCreator ( const char *  creator,
FILE *  f 
) const throw () [virtual]

Saves a creator code directly to a file.

Parameters:
creator the string to use for the creator code
f the file to save the code into
Returns:
the number of bytes consumed

Definition at line 69 of file LoadSave.cc.

unsigned int LoadSave::saveCreator ( const char *  creator,
char  buf[],
unsigned int  len 
) const throw () [virtual]

Saves a creator code to a buffer.

Parameters:
creator the string to use for the creator code
buf the buffer to save the code into
len the space available in the buffer
Returns:
the number of bytes consumed

Definition at line 54 of file LoadSave.cc.

Referenced by LookoutIREvent::saveBinaryBuffer(), and LookoutPointAtEvent::saveBinaryBuffer().

bool LoadSave::saveCreatorInc ( const char *  creator,
char *&  buf,
unsigned int &  len 
) const throw () [virtual]

Saves a creator code to a buffer, increments buf and decrements len by the amount used.

Parameters:
creator the string to use for the creator code
buf the buffer to save the code into
len the space available in the buffer
Returns:
true if successful, false otherwise

Definition at line 57 of file LoadSave.cc.

Referenced by VisionObjectEvent::saveBinaryBuffer(), TimerEvent::saveBinaryBuffer(), TextMsgEvent::saveBinaryBuffer(), PitchEvent::saveBinaryBuffer(), LocomotionEvent::saveBinaryBuffer(), KoduSayEvent::saveBinaryBuffer(), KoduGiveEvent::saveBinaryBuffer(), KoduEventBase::saveBinaryBuffer(), EventBase::saveBinaryBuffer(), DataEvent< T, TID >::saveBinaryBuffer(), SegmentedColorGenerator::saveBuffer(), and FilterBankGenerator::saveBuffer().

void LoadSave::saveCreatorIncT ( const char *  creator,
char *&  buf,
unsigned int &  len 
) const throw (std::runtime_error) [virtual]

Saves a creator code to a buffer, increments buf and decrements len by the amount used.

Parameters:
creator the string to use for the creator code
buf the buffer to save the code into
len the space available in the buffer

Definition at line 61 of file LoadSave.cc.

unsigned int LoadSave::SaveFile ( const char *  filename  )  const [virtual]

deprecated, use saveFile() instead (refactored to standardize capitalization style)

Definition at line 188 of file LoadSave.cc.

unsigned int LoadSave::saveFile ( const char *  filename  )  const [virtual]

initiate opening of the specified file and loading/saving of all appropriate information.

Parameters:
filename the file to load/save
Returns:
number of bytes read/written, 0 if error (or empty)

Reimplemented in EventBase, CMPackWalkMC, WaypointEngine, and XMLLoadSave.

Definition at line 92 of file LoadSave.cc.

Referenced by SaveFile().

unsigned int LoadSave::saveFileStream ( FILE *  f  )  const [virtual]

Used recursively on member objects once a file is already open - DON'T CLOSE the file in your overridden functions.

Parameters:
f a pointer to the file to save
Returns:
number of bytes written, 0 if error (or empty)

Reimplemented in EventBase, XMLLoadSave, BufferedImageGenerator, and RawCameraGenerator.

Definition at line 148 of file LoadSave.cc.

Referenced by CameraBehavior::doEvent(), encode(), saveFile(), and LogNode::writeSensor().

unsigned int LoadSave::saveStream ( std::ostream &  os  )  const [virtual]

Writes into a std::ostream, does not flush.

Reimplemented in XMLLoadSave.

Definition at line 166 of file LoadSave.cc.


Member Data Documentation


The documentation for this class was generated from the following files:

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:12 2016 by Doxygen 1.6.3