1
#include <osgSim/ShapeAttribute>
6
#include <osgDB/Registry>
8
#include <osgDB/Output>
9
#include <osgDB/ParameterOutput>
11
using namespace osgSim;
13
bool ShapeAttributeList_readLocalData(osg::Object &obj, osgDB::Input &fr);
14
bool ShapeAttributeList_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
16
osgDB::RegisterDotOsgWrapperProxy ShapeAttributeList_Proxy
18
new ShapeAttributeList,
20
"Object ShapeAttributeList",
21
&ShapeAttributeList_readLocalData,
22
&ShapeAttributeList_writeLocalData,
23
osgDB::DotOsgWrapper::READ_AND_WRITE
26
bool ShapeAttributeList_readLocalData(osg::Object &obj, osgDB::Input &fr)
28
bool iteratorAdvanced = false;
29
ShapeAttributeList &sal = static_cast<ShapeAttributeList &>(obj);
32
int entry = fr[0].getNoNestedBrackets();
34
while (!fr.eof() && fr[0].getNoNestedBrackets()>=entry)
36
if (fr.matchSequence("string %s %s"))
38
sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), fr[2].getStr()));
40
iteratorAdvanced = true;
42
else if (fr.matchSequence("double %s %f"))
45
fr[2].getFloat(value);
46
sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), value));
48
iteratorAdvanced = true;
50
else if (fr.matchSequence("int %s %i"))
54
sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), value));
56
iteratorAdvanced = true;
61
return iteratorAdvanced;
65
bool ShapeAttributeList_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
67
const ShapeAttributeList &sal = static_cast<const ShapeAttributeList &>(obj);
69
for (ShapeAttributeList::const_iterator it = sal.begin(); it != sal.end(); ++it)
71
switch (it->getType())
73
case osgSim::ShapeAttribute::STRING:
75
fw.indent()<<"string "<< fw.wrapString(it->getName())<<" "<<fw.wrapString(it->getString()) << std::endl;
78
case osgSim::ShapeAttribute::INTEGER:
80
fw.indent()<<"int "<< fw.wrapString(it->getName())<<" "<<it->getInt() << std::endl;
83
case osgSim::ShapeAttribute::DOUBLE:
85
fw.indent()<<"double "<< fw.wrapString(it->getName())<<" "<<it->getDouble() << std::endl;
88
case osgSim::ShapeAttribute::UNKNOW: