void Serialiser::Serialise(const char *name, ImageRegionState &el) { ScopedContext scope(this, name, "ImageRegionState", 0, true); Serialise("range", el.subresourceRange); Serialise("prevstate", el.oldLayout); Serialise("state", el.newLayout); }
void SaveTask(WritableDataNode &node, const OrderedTask &task) { node.SetAttribute(_T("type"), GetTaskFactoryType(task.GetFactoryType())); Serialise(node, task.GetOrderedTaskSettings()); for (const auto &tp : task.GetPoints()) Serialise(node, tp, false); for (const auto &tp : task.GetOptionalStartPoints()) Serialise(node, tp, true); }
void Serialiser::Serialise(const OrderedTask &task) { node.SetAttribute(_T("type"), GetTaskFactoryType(task.GetFactoryType())); Serialise(task.GetOrderedTaskBehaviour()); mode_optional_start = false; for (const auto &tp : task.GetPoints()) Serialise(tp); mode_optional_start = true; for (const auto &tp : task.GetOptionalStartPoints()) Serialise(tp); }
bool TMFObject::Initialise(FILE* fp, const MaterialList& materialList ) { if ( Serialise( fp, materialList ) && BuildVbos() ) return true; else return false; }
void Serialiser::Serialise(const OrderedTaskPoint &tp) { const TCHAR *name = GetName(tp, mode_optional_start); assert(name != nullptr); Serialise(tp, name); }
static void Serialise(WritableDataNode &node, const OrderedTaskPoint &tp, bool mode_optional_start) { const TCHAR *name = GetName(tp, mode_optional_start); assert(name != nullptr); Serialise(node, tp, name); }
void Serialiser::Serialise(const OrderedTask &task) { node.SetAttribute(_T("type"), GetTaskFactoryType(task.GetFactoryType())); Serialise(task.GetOrderedTaskBehaviour()); mode_optional_start = false; task.AcceptTaskPointVisitor(*this); mode_optional_start = true; task.AcceptStartPointVisitor(*this); }
static void Serialise(WritableDataNode &node, const OrderedTaskPoint &data, const TCHAR *name) { // do nothing std::unique_ptr<WritableDataNode> child(node.AppendChild(_T("Point"))); child->SetAttribute(_T("type"), name); std::unique_ptr<WritableDataNode> wchild(child->AppendChild(_T("Waypoint"))); Serialise(*wchild, data.GetWaypoint()); std::unique_ptr<WritableDataNode> ochild(child->AppendChild(_T("ObservationZone"))); Serialise(*ochild, data.GetObservationZone()); if (data.GetType() == TaskPointType::AST) { const ASTPoint &ast = (const ASTPoint &)data; if (ast.GetScoreExit()) child->SetAttribute(_T("score_exit"), true); } }
static void Serialise(WritableDataNode &node, const Waypoint &data) { node.SetAttribute(_T("name"), data.name.c_str()); node.SetAttribute(_T("id"), data.id); node.SetAttribute(_T("comment"), data.comment.c_str()); node.SetAttribute(_T("altitude"), data.elevation); std::unique_ptr<WritableDataNode> child(node.AppendChild(_T("Location"))); Serialise(*child, data.location); }
bool DataNodeXML::Save(const TCHAR *path) { /// @todo make xml writing portable (unicode etc) TextWriter writer(path); if (writer.error()) return false; Serialise(writer); return true; }
void VZipFileReader::Seek(int InPos) { guard(VZipFileReader::Seek); check(InPos >= 0); check(InPos <= (int)Info.uncompressed_size); if (bError) return; // If seeking backwards, reset input stream to the begining of the file. if (InPos < Tell()) { if (Info.compression_method == Z_DEFLATED) { check(stream_initialised); inflateEnd(&stream); memset(&stream, 0, sizeof(stream)); verify(inflateInit2(&stream, -MAX_WBITS) == Z_OK); } else { memset(&stream, 0, sizeof(stream)); } Crc32 = 0; rest_read_compressed = Info.compressed_size; rest_read_uncompressed = Info.uncompressed_size; pos_in_zipfile = start_pos; } // Read data into a temporary buffer untill we reach needed position. int ToSkip = InPos - Tell(); while (ToSkip > 0) { int Count = ToSkip > 1024 ? 1024 : ToSkip; ToSkip -= Count; vuint8 TmpBuf[1024]; Serialise(TmpBuf, Count); } unguard; }
void XMLNode::Serialise(const Data &data, BufferedOutputStream &os, int format) { bool has_children = false; // If the element has no name then assume this is the head node. if (!data.name.empty()) { // "<elementname " const unsigned cb = format == -1 ? 0 : format; WriteIndent(os, cb); os.Write('<'); if (data.is_declaration) os.Write('?'); os.Write(data.name.c_str()); // Enumerate attributes and add them to the string for (auto i = data.attributes.begin(), end = data.attributes.end(); i != end; ++i) { const Data::Attribute *pAttr = &*i; os.Write(' '); os.Write(pAttr->name.c_str()); os.Write('='); os.Write('"'); WriteXMLString(os, pAttr->value); os.Write('"'); pAttr++; } has_children = data.HasChildren(); if (data.is_declaration) { os.Write('?'); os.Write('>'); if (format != -1) os.Write('\n'); } else // If there are child nodes we need to terminate the start tag if (has_children) { os.Write('>'); if (format != -1) os.Write('\n'); } } // Calculate the child format for when we recurse. This is used to // determine the number of spaces used for prefixes. int child_format = -1; if (format != -1) { if (!data.name.empty()) child_format = format + 1; else child_format = format; } /* write the child elements */ for (auto i = data.begin(), end = data.end(); i != end; ++i) Serialise(*i->d, os, child_format); /* write the text */ if (!data.text.empty()) { if (format != -1) { WriteIndent(os, format + 1); WriteXMLString(os, data.text); os.Write('\n'); } else { WriteXMLString(os, data.text); } } if (!data.name.empty() && !data.is_declaration) { // If we have child entries we need to use long XML notation for // closing the element - "<elementname>blah blah blah</elementname>" if (has_children) { // "</elementname>\0" if (format != -1) WriteIndent(os, format); os.Write("</"); os.Write(data.name.c_str()); os.Write('>'); } else { // If there are no children we can use shorthand XML notation - // "<elementname/>" // "/>\0" os.Write("/>"); } if (format != -1) os.Write('\n'); } }
void XMLNode::Serialise(BufferedOutputStream &os, bool format) const { Serialise(*d, os, format ? 0 : -1); }
void Serialiser::Visit(const StartPoint &data) { Serialise(data, mode_optional_start ? _T("OptionalStart"): _T("Start")); }
void Serialiser::Visit(const ASTPoint &data) { Serialise(data, _T("Turn")); }
void Serialiser::Visit(const AATPoint &data) { Serialise(data, _T("Area")); }
void Serialiser::Visit(const FinishPoint &data) { Serialise(data, _T("Finish")); }