export.C

00001 
00002 
00003       return rootScene->dump();
00004 
00005 
00006 #include <archon/x3d/server/export.H>
00007 
00008 namespace Archon
00009 {
00010   namespace X3D
00011   {
00012     struct VrmlExporter: Exporter
00013     {
00014       string escape(string s)
00015       {
00016         return s;
00017       }
00018 
00019       string indent = "";
00020 
00021       void stepIn()
00022       {
00023         indent += "  ";
00024       }
00025 
00026       void stepOut()
00027       {
00028         indent.erase(indent.size()-2);
00029       }
00030 
00031 
00032       void noNode()
00033       {
00034         out << " NULL\n";
00035       }
00036 
00037       void emptyNode(NodeBase *, string name)
00038       {
00039         out << indent;
00040         if(!name.empty()) out << "DEF " << escape(name) << "\" ";
00041         out << n->getTypeName() << " {}\n";
00042       }
00043 
00044       void resuseNode(NodeBase *, string name)
00045       {
00046         out << indent << "USE \"" << escape(name) << "\"\n";
00047       }
00048 
00049       void nodeBegin(NodeBase *n, string name)
00050       {
00051         out << indent;
00052         if(!name.empty()) out << "DEF " << escape(name) << "\" ";
00053         out << n->getTypeName() << "\n" << indent << "{\n";
00054         stepIn();
00055       }
00056 
00057       void nodeEnd(NodeBase *)
00058       {
00059         stepOut();
00060         out << indent << "}\n";
00061       }
00062 
00063 
00064       void simpleFieldBegin(NodeBase *, const FieldBase *f)
00065       {
00066         out << indent << f->getName();
00067       }
00068 
00069       void simpleFieldEnd()
00070       {
00071         out << "\n";
00072       }
00073 
00074       void emptySimpleSequence()
00075       {
00076         out << " []";
00077       }
00078 
00079       void simpleSequenceBegin()
00080       {
00081         out << " [";
00082       }
00083 
00084       void simpleSequenceEnd()
00085       {
00086         out << " ]";
00087       }
00088 
00089 
00090       void nodeFieldBegin(NodeBase *, const FieldBase *f)
00091       {
00092         out << indent << f->getName();
00093       }
00094 
00095       void nodeFieldEnd()
00096       {
00097       }
00098 
00099       void emptyNodeSequence()
00100       {
00101         out << " []";
00102       }
00103 
00104       void nodeSequenceBegin()
00105       {
00106         out << indent << "[\n";
00107       }
00108 
00109       void simpleSequenceEnd()
00110       {
00111         out << " ]\n";
00112       }
00113 
00114       void Exporter::valueSFString(SFString::ArgType v)
00115       {
00116         out << "\"" << escape(v) << "\"\n";
00117       }
00118 
00119       void Exporter::valueMFString(SFString::ArgType v)
00120       {
00121         out << "\"" << escape(v) << "\"\n";
00122       }
00123     }
00124 
00125 
00126     struct XMLExporter: Exporter
00127     {
00128       string escape(string s)
00129       {
00130         return s;
00131       }
00132 
00133       string containerField = "";
00134 
00135       string indent = "";
00136 
00137       void stepIn()
00138       {
00139         indent += "  ";
00140       }
00141 
00142       void stepOut()
00143       {
00144         indent.erase(indent.size()-2);
00145       }
00146 
00147 
00148       void noNode()
00149       {
00150       }
00151 
00152       void resuseNode(NodeBase *n, string name)
00153       {
00154         out << indent << "<" << n->getTypeName() << " USE=\"" << escape(name) << "\"";
00155         if(!containerField.empty()) out << " containerField=\"" << containerField << "\"";
00156         out << "/>\n";
00157       }
00158 
00159       void nodeBegin(NodeBase *n, string name, bool empty)
00160       {
00161         out << indent << "<" << n->getTypeName();
00162         if(!name.empty()) out << "DEF " << escape(name) << "\" ";
00163         out << n->getTypeName() << "\n" << indent << "{\n";
00164         out << ">\n";
00165         stepIn();
00166       }
00167 
00168       void nodeEnd(NodeBase *n)
00169       {
00170         stepOut();
00171         out << indent << "}\n";
00172       }
00173 
00174 
00175       void simpleFieldBegin(NodeBase *n, const FieldBase *f)
00176       {
00177         out << indent << f->getName();
00178       }
00179 
00180       void simpleFieldEnd()
00181       {
00182         out << "\n";
00183       }
00184 
00185       void emptySimpleSequence()
00186       {
00187         out << " []";
00188       }
00189 
00190       void simpleSequenceBegin()
00191       {
00192         out << " [";
00193       }
00194 
00195       void simpleSequenceEnd()
00196       {
00197         out << " ]";
00198       }
00199 
00200 
00201       void nodeFieldBegin(NodeBase *n, const FieldBase *f)
00202       {
00203         containerField = f->isUnique() ? "" : f->getName();
00204       }
00205 
00206       void nodeFieldEnd()
00207       {
00208       }
00209 
00210       void emptyNodeSequence()
00211       {
00212         out << " []";
00213       }
00214 
00215       void nodeSequenceBegin()
00216       {
00217         out << indent << "[\n";
00218       }
00219 
00220       void simpleSequenceEnd()
00221       {
00222         out << " ]\n";
00223       }
00224 
00225       void Exporter::valueSFString(SFString::ArgType v)
00226       {
00227         out << "\"" << escape(v) << "\"\n";
00228       }
00229 
00230       void Exporter::valueMFString(SFString::ArgType v)
00231       {
00232         out << "\"" << escape(v) << "\"\n";
00233       }
00234     }
00235   }
00236 }

Generated on Sun Jul 30 22:55:49 2006 for Archon by  doxygen 1.4.4