| GL Studio C++ Runtime API

Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GlsGloFile::Writer Class Reference

`#include <gls_glo_file.h>`

## Public Member Functions
| Writer (const std::string &filename, const bool open, const unsigned char *timestamp)
std::string | Filename ()
std::string | BaseFilename ()
unsigned char * | Timestamp ()
void | OpenForWriting ()
| Open file and prepare to write.
void | DefaultChecking (bool val)
void | StartObjectRecord ()
| Start writing an object record.
void | AddObjectAttribute (const unsigned int enumeration, const unsigned int size, const void *data)
void | AddBoolean (const unsigned int enumerator, const bool value)
void | AddU8 (const unsigned int enumerator, const unsigned char value)
void | AddU16 (const unsigned int enumerator, const unsigned short value)
void | AddS16 (const unsigned int enumerator, const short value)
void | AddU32 (const unsigned int enumerator, const unsigned int value)
void | AddS32 (const unsigned int enumerator, const int value)
void | AddString (const unsigned int enumerator, const std::string &value)
void | AddCString (const unsigned int enumerator, const char *value)
void | AddFloat (const unsigned int enumerator, const float value)
void | AddDouble (const unsigned int enumerator, const double value)
void | AddVector (const unsigned int enumerator, const Vector &value)
void | AddGlsColor (const unsigned int enumerator, const glsColor &value)
void | AddMatrix (const unsigned int enumerator, const GlsMatrixAffineD &value)
void | AddVertexArray (const unsigned int enumerator, const unsigned int nVertices, const Vertex verts[])
void | AddVectorArray (const unsigned int enumerator, const unsigned int nVertices, const Vector verts[])
void | AddFloatArray (const unsigned int enumerator, const unsigned int nVertices, const float verts[])
void | AddDoubleArray (const unsigned int enumerator, const unsigned int nVertices, const double verts[])
void | AddMaterialIndices (const unsigned int enumerator, DynamicArray< int > &values)
void | AddVector2DArray (const unsigned int enumerator, const unsigned int nVertices, const Vector verts[])
unsigned int | AddExtendedAttributeHeader (unsigned int enumerator, unsigned int size=0)
unsigned int | AddAttributeHeader (unsigned int enumerator, unsigned char size=0)
void | AddBoolean (const unsigned int enumerator, const bool value, const bool defVal)
void | AddU8 (const unsigned int enumerator, const unsigned char value, const unsigned char defVal)
void | AddU16 (const unsigned int enumerator, const unsigned short value, const unsigned short defVal)
void | AddS16 (const unsigned int enumerator, const short value, const short defVal)
void | AddU32 (const unsigned int enumerator, const unsigned int value, const unsigned int defVal)
void | AddS32 (const unsigned int enumerator, const int value, const int defVal)
void | AddGlsColor (const unsigned int enumerator, const glsColor &value, const glsColor &defVal)
void | AddFloat (const unsigned int enumerator, const float value, const float defVal)
void | AddDouble (const unsigned int enumerator, const double value, const double defVal)
void | WriteU8 (const unsigned char val)
void | WriteS8 (const char val)
void | WriteU16 (const unsigned short val)
void | WriteS16 (const short val)
void | WriteU32 (const unsigned int val)
void | WriteS32 (const int val)
void | WriteFloat (const float val)
void | WriteDouble (const double val)
void | WriteGlsColor (const glsColor &value)
void | WriteU8 (const unsigned char val, const unsigned int offset)
void | WriteU32 (const unsigned int val, const unsigned int offset)
void | AddMatrix (const unsigned int enumerator, const GlsMatrixAffineD &value, const bool checkForIdentity)
void | EndObjectRecord ()
| End the current object record.
void | Flush ()
| Flush the current buffer to disk and rewind.
void | Close ()
| Close the file.

## Static Public Attributes
static const unsigned int | MAX_STANDARD_ATTR_SIZE = 255
| Maximum size for a standard attribute, extended attributes beyond this size.
static const unsigned int | ATTR_SIZE_EXTENDED = 0
| Value to indicate that a size is extended.

## Protected Member Functions
void | WriteFileHeader ()
| Writes the file header data to the GLO file.

## Protected Attributes
std::string | _filename
| The file name of the GLO file to write.
bool | _initialized
| If true, the file is ready for writing.
FILE * | _out
| The OS file handle to the file to be written.
bool | _defaultChecking
| If true, will not write values to file that match default values.
unsigned char | _timestamp [GLO_FILE_TIMESTAMP_SIZE]
| Storage for the file generation timestamp.
GloFileHeader | _header
| File header information to be written to the file.
unsigned int | _numObjects
| Current count of the number of objects in the file.
short | _numParams
| Current count of the number of params in the current object.
WriteBuffer * | _buffer
| Byte buffer to store params in.

## Detailed Description

The Writer class. Handles output of GLS property values to the GLO file format.

## Constructor & Destructor Documentation

## ◆ Writer()

Writer | ( | const std::string & | filename,
|  | const bool | open,
|  | const unsigned char * | timestamp
| ) |  |

Create a GLO file writer for the given file

Parameters

  filename | The filename to write the GLO file to.
  open | If true, open the file on construction.
  timestamp | The timestamp to write to the file.

## Member Function Documentation

## ◆ AddAttributeHeader()

unsigned int AddAttributeHeader | ( | unsigned int | enumerator,
|  | unsigned char | size = `0`
| ) |  |

Write a standard header to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  size | The size of this attribute.

Returns
  offset Of extended size for later to allow caller to modify size.

## ◆ AddBoolean() [1/2]

void AddBoolean | ( | const unsigned int | enumerator,
|  | const bool | value
| ) |  |

Write a boolean value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddBoolean() [2/2]

void AddBoolean | ( | const unsigned int | enumerator,
|  | const bool | value,
|  | const bool | defVal
| ) |  |

Same as AddBoolean(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddCString()

void AddCString | ( | const unsigned int | enumerator,
|  | const char * | value
| ) |  |

Write a C string value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddDouble() [1/2]

void AddDouble | ( | const unsigned int | enumerator,
|  | const double | value
| ) |  |

Write a double value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddDouble() [2/2]

void AddDouble | ( | const unsigned int | enumerator,
|  | const double | value,
|  | const double | defVal
| ) |  |

Same as AddDouble(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddDoubleArray()

void AddDoubleArray | ( | const unsigned int | enumerator,
|  | const unsigned int | nVertices,
|  | const double | verts[]
| ) |  |

Write a list of doubles to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  nVertices | The number of doubles to write.
  verts | A list containing the doubles to write.

## ◆ AddExtendedAttributeHeader()

unsigned int AddExtendedAttributeHeader | ( | unsigned int | enumerator,
|  | unsigned int | size = `0`
| ) |  |

Use these to write custom data structures to the file. Can write structures larger than 255 bytes to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  size | The size of this attribute.

Returns
  offset Of extended size for later to allow caller to modify size.

## ◆ AddFloat() [1/2]

void AddFloat | ( | const unsigned int | enumerator,
|  | const float | value
| ) |  |

Write a float value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddFloat() [2/2]

void AddFloat | ( | const unsigned int | enumerator,
|  | const float | value,
|  | const float | defVal
| ) |  |

Same as AddFloat(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddFloatArray()

void AddFloatArray | ( | const unsigned int | enumerator,
|  | const unsigned int | nVertices,
|  | const float | verts[]
| ) |  |

Write a list of floats to the GLO file.

Parameters

  enumerator | the identifier for this attribute
  nVertices | the number of floats to write
  verts | a list containing the floats to write

## ◆ AddGlsColor() [1/2]

void AddGlsColor | ( | const unsigned int | enumerator,
|  | const glsColor & | value
| ) |  |

Write a color value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddGlsColor() [2/2]

void AddGlsColor | ( | const unsigned int | enumerator,
|  | const glsColor & | value,
|  | const glsColor & | defVal
| ) |  |

Same as AddGlsColor(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddMaterialIndices()

void AddMaterialIndices | ( | const unsigned int | enumerator,
|  | DynamicArray< int > & | values
| ) |  |

Write a list of material indices to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  values | The material indices list to write.

## ◆ AddMatrix() [1/2]

void AddMatrix | ( | const unsigned int | enumerator,
|  | const GlsMatrixAffineD & | value
| ) |  |

Write a 4x4 matrix value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddMatrix() [2/2]

void AddMatrix | ( | const unsigned int | enumerator,
|  | const GlsMatrixAffineD & | value,
|  | const bool | checkForIdentity
| ) |  |

Method to add matrix, but only if it isn't identity.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  checkForIdentity | If true, will check for identify before writing to file.

## ◆ AddObjectAttribute()

void AddObjectAttribute | ( | const unsigned int | enumeration,
|  | const unsigned int | size,
|  | const void * | data
| ) |  |

Add an object attribute to the file for the current object.

Parameters

  enumeration | Identifier for this attribute.
  size | The size to be written in bytes.
  data | The data to be written.

## ◆ AddS16() [1/2]

void AddS16 | ( | const unsigned int | enumerator,
|  | const short | value
| ) |  |

Write a signed 16 bit value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddS16() [2/2]

void AddS16 | ( | const unsigned int | enumerator,
|  | const short | value,
|  | const short | defVal
| ) |  |

Same as AddS16(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddS32() [1/2]

void AddS32 | ( | const unsigned int | enumerator,
|  | const int | value
| ) |  |

Write a signed 32 bit value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddS32() [2/2]

void AddS32 | ( | const unsigned int | enumerator,
|  | const int | value,
|  | const int | defVal
| ) |  |

Same as AddS32(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddString()

void AddString | ( | const unsigned int | enumerator,
|  | const std::string & | value
| ) |  |

Write a std::string value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddU16() [1/2]

void AddU16 | ( | const unsigned int | enumerator,
|  | const unsigned short | value
| ) |  |

Write an unsigned 16 bit value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddU16() [2/2]

void AddU16 | ( | const unsigned int | enumerator,
|  | const unsigned short | value,
|  | const unsigned short | defVal
| ) |  |

Same as AddU16(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddU32() [1/2]

void AddU32 | ( | const unsigned int | enumerator,
|  | const unsigned int | value
| ) |  |

Write an unsigned 32 bit value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddU32() [2/2]

void AddU32 | ( | const unsigned int | enumerator,
|  | const unsigned int | value,
|  | const unsigned int | defVal
| ) |  |

Same as AddU32(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddU8() [1/2]

void AddU8 | ( | const unsigned int | enumerator,
|  | const unsigned char | value
| ) |  |

Write an unsigned 8 bit value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddU8() [2/2]

void AddU8 | ( | const unsigned int | enumerator,
|  | const unsigned char | value,
|  | const unsigned char | defVal
| ) |  |

Same as AddU8(), but check against the default value, unless _defaultChecking is false. If the value matches the default value, it will not be written to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.
  defVal | The default value for this attribute.

## ◆ AddVector()

void AddVector | ( | const unsigned int | enumerator,
|  | const Vector & | value
| ) |  |

Write a Vector value to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  value | The value for this attribute.

## ◆ AddVector2DArray()

void AddVector2DArray | ( | const unsigned int | enumerator,
|  | const unsigned int | nVertices,
|  | const Vector | verts[]
| ) |  |

Same as AddVectorArray but only writes X & Y coordinates

Parameters

  enumerator | The identifier for this attribute.
  nVertices | The number of vectors to write.
  verts | A list containing the vectors to write.

## ◆ AddVectorArray()

void AddVectorArray | ( | const unsigned int | enumerator,
|  | const unsigned int | nVertices,
|  | const Vector | verts[]
| ) |  |

Write a list of vectors to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  nVertices | The number of vectors to write.
  verts | A list containing the vectors to write.

## ◆ AddVertexArray()

void AddVertexArray | ( | const unsigned int | enumerator,
|  | const unsigned int | nVertices,
|  | const Vertex | verts[]
| ) |  |

Write a list of vertices to the GLO file.

Parameters

  enumerator | The identifier for this attribute.
  nVertices | The number of vertices to write.
  verts | A list containing the vertices to write.

## ◆ BaseFilename()

std::string BaseFilename | ( |  | ) |

Returns
  The file name component of the GLO file.

## ◆ DefaultChecking()

void DefaultChecking | ( | bool | val | ) |
| inline

If true, values will be written to the GLO file only if they are different from the default value.

Parameters

  val | The new default checking flag to set.

## ◆ Filename()

std::string Filename | ( |  | ) |

Returns
  The full file path to the GLO file.

## ◆ Timestamp()

unsigned char * Timestamp | ( |  | ) |
| inline

Returns
  The timestamp to be written to the file.

## ◆ WriteDouble()

void WriteDouble | ( | const double | val | ) |

Write a double value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteFloat()

void WriteFloat | ( | const float | val | ) |

Write a float value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteGlsColor()

void WriteGlsColor | ( | const glsColor & | value | ) |

Write a color value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  value | The value to write.

## ◆ WriteS16()

void WriteS16 | ( | const short | val | ) |

Write a signed 16 bit value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteS32()

void WriteS32 | ( | const int | val | ) |

Write a signed 32 bit value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteS8()

void WriteS8 | ( | const char | val | ) |

Write a signed 8 bit value directly to the GLO file.

Parameters

  val | The value to write.

## ◆ WriteU16()

void WriteU16 | ( | const unsigned short | val | ) |

Write an unsigned 16 bit value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteU32() [1/2]

void WriteU32 | ( | const unsigned int | val | ) |

Write an unsigned 32 bit value directly to the GLO file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.

## ◆ WriteU32() [2/2]

void WriteU32 | ( | const unsigned int | val,
|  | const unsigned int | offset
| ) |  |

Write an unsigned 8 bit value directly to the GLO file. Writes at the specified offset into the file.

Note
  Data is byte swapped into Big Endian format.

Parameters

  val | The value to write.
  offset | The offset at which to write the value.

## ◆ WriteU8() [1/2]

void WriteU8 | ( | const unsigned char | val | ) |

Write an unsigned 8 bit value directly to the GLO file.

Parameters

  val | The value to write.

## ◆ WriteU8() [2/2]

void WriteU8 | ( | const unsigned char | val,
|  | const unsigned int | offset
| ) |  |

Write an unsigned 8 bit value directly to the GLO file. Writes at the specified offset into the file.

Parameters

  val | The value to write.
  offset | The offset at which to write the value.

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

- gls_glo_file.h