~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgPlugins/osgSim/IO_ShapeAttribute.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <osgSim/ShapeAttribute>
 
2
 
 
3
#include <iostream>
 
4
#include <string>
 
5
 
 
6
#include <osgDB/Registry>
 
7
#include <osgDB/Input>
 
8
#include <osgDB/Output>
 
9
#include <osgDB/ParameterOutput>
 
10
 
 
11
using namespace osgSim;
 
12
 
 
13
bool ShapeAttributeList_readLocalData(osg::Object &obj, osgDB::Input &fr);
 
14
bool ShapeAttributeList_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
 
15
 
 
16
osgDB::RegisterDotOsgWrapperProxy ShapeAttributeList_Proxy
 
17
(
 
18
    new ShapeAttributeList,
 
19
    "ShapeAttributeList",
 
20
    "Object ShapeAttributeList",
 
21
    &ShapeAttributeList_readLocalData,
 
22
    &ShapeAttributeList_writeLocalData,
 
23
    osgDB::DotOsgWrapper::READ_AND_WRITE
 
24
);
 
25
 
 
26
bool ShapeAttributeList_readLocalData(osg::Object &obj, osgDB::Input &fr)
 
27
{
 
28
    bool iteratorAdvanced = false;
 
29
    ShapeAttributeList &sal = static_cast<ShapeAttributeList &>(obj);
 
30
 
 
31
    
 
32
    int entry = fr[0].getNoNestedBrackets();
 
33
    
 
34
    while (!fr.eof() && fr[0].getNoNestedBrackets()>=entry)
 
35
    {
 
36
        if (fr.matchSequence("string %s %s"))
 
37
        {
 
38
            sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), fr[2].getStr()));
 
39
            fr += 3;
 
40
            iteratorAdvanced = true;
 
41
        }
 
42
        else if (fr.matchSequence("double %s %f"))
 
43
        {
 
44
            double value;
 
45
            fr[2].getFloat(value);
 
46
            sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), value));
 
47
            fr += 3;
 
48
            iteratorAdvanced = true;
 
49
        }
 
50
        else if (fr.matchSequence("int %s %i"))
 
51
        {
 
52
            int value;
 
53
            fr[2].getInt(value);
 
54
            sal.push_back(osgSim::ShapeAttribute(fr[1].getStr(), value));
 
55
            fr += 3;
 
56
            iteratorAdvanced = true;
 
57
        }
 
58
        else ++fr;
 
59
    }
 
60
 
 
61
    return iteratorAdvanced;
 
62
}
 
63
 
 
64
    
 
65
bool ShapeAttributeList_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
 
66
{
 
67
    const ShapeAttributeList &sal = static_cast<const ShapeAttributeList &>(obj);
 
68
 
 
69
    for (ShapeAttributeList::const_iterator it = sal.begin(); it != sal.end(); ++it)
 
70
    {
 
71
        switch (it->getType())
 
72
        {
 
73
            case osgSim::ShapeAttribute::STRING:
 
74
            {
 
75
                fw.indent()<<"string "<< fw.wrapString(it->getName())<<" "<<fw.wrapString(it->getString()) << std::endl;
 
76
                break;
 
77
            }
 
78
            case osgSim::ShapeAttribute::INTEGER:
 
79
            {
 
80
                fw.indent()<<"int    "<< fw.wrapString(it->getName())<<" "<<it->getInt() << std::endl;
 
81
                break;
 
82
            }
 
83
            case osgSim::ShapeAttribute::DOUBLE:
 
84
            {
 
85
                fw.indent()<<"double "<< fw.wrapString(it->getName())<<" "<<it->getDouble() << std::endl;
 
86
                break;
 
87
            }
 
88
            case osgSim::ShapeAttribute::UNKNOW:
 
89
                default: break;
 
90
        }
 
91
    }
 
92
    return true;
 
93
}