From: <edu...@us...> - 2010-08-01 20:03:07
|
Revision: 34648 http://crystal.svn.sourceforge.net/crystal/?rev=34648&view=rev Author: eduardorp Date: 2010-08-01 20:03:01 +0000 (Sun, 01 Aug 2010) Log Message: ----------- Another attempt to save Modified Paths: -------------- CS/branches/soc2010/lod/apps/tools/lod/lod.cpp CS/branches/soc2010/lod/apps/tools/lod/lod.h Modified: CS/branches/soc2010/lod/apps/tools/lod/lod.cpp =================================================================== --- CS/branches/soc2010/lod/apps/tools/lod/lod.cpp 2010-08-01 18:36:06 UTC (rev 34647) +++ CS/branches/soc2010/lod/apps/tools/lod/lod.cpp 2010-08-01 20:03:01 UTC (rev 34648) @@ -481,6 +481,61 @@ vfs->Sync(); } +#if 0 +// TODO +void Lod::Save(const char* filename) +{ + csRef<iVFS> vfs; + vfs = csQueryRegistry<iVFS> (GetObjectRegistry()); + if (!vfs) + { + cout << "No iVFS!" << endl; + return; + } + csRef<iFile> file = vfs->Open(filename, VFS_FILE_READ); + + + csRef<iDocumentSystem> xml(new csTinyDocumentSystem()); + csRef<iDocument> doc = xml->CreateDocument(); + const char* result = doc->Parse(file); + if (result) + { + cout << "Error parsing file: " << result << endl; + return; + } + + // ... + + scfString str; + doc->Write(&str); + vfs->WriteFile(filename, str.GetData(), str.Length()); + vfs->Sync(); +} +#endif + +void Lod::CloneNode (iDocumentNode* from, iDocumentNode* to) +{ + to->SetValue (from->GetValue ()); + csRef<iDocumentNodeIterator> it = from->GetNodes (); + while (it->HasNext ()) + { + csRef<iDocumentNode> child = it->Next (); + csRef<iDocumentNode> child_clone = to->CreateNodeBefore (child->GetType (), 0); + CloneNode (child, child_clone); + } + CloneAttributes (from, to); +} + +void Lod::CloneAttributes (iDocumentNode* from, iDocumentNode* to) +{ + csRef<iDocumentAttributeIterator> atit = from->GetAttributes (); + while (atit->HasNext ()) + { + csRef<iDocumentAttribute> attr = atit->Next (); + to->SetAttribute (attr->GetName (), attr->GetValue ()); + } +} + bool Lod::SetupModules () { // Now get the pointer to various modules we need. We fetch them Modified: CS/branches/soc2010/lod/apps/tools/lod/lod.h =================================================================== --- CS/branches/soc2010/lod/apps/tools/lod/lod.h 2010-08-01 18:36:06 UTC (rev 34647) +++ CS/branches/soc2010/lod/apps/tools/lod/lod.h 2010-08-01 20:03:01 UTC (rev 34648) @@ -83,7 +83,10 @@ csRef<iThreadReturn> loading; void CreateLODs(const char* filename_in, const char* filename_out); void Save(const char* filename); + void CloneNode (iDocumentNode* from, iDocumentNode* to); + void CloneAttributes (iDocumentNode* from, iDocumentNode* to); + /// Here we will create our little, simple world. void CreateRoom (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |