root/ossiedev/trunk/system/ossie/parser/PRFSimpleProperty.cpp @ 10171

Revision 10171, 3.0 KB (checked in by Snyder.Jason, 3 years ago)

bools, chars, and octals have to be treated differently than other data types. See Advanced CORBA Programming in C++ by Henning and Vinoski, chapter 15.3 for more details

  • Property svn:eol-style set to native
Line 
1/*******************************************************************************
2
3Copyright 2004, 2005, 2006, 2007 Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Parser.
6
7OSSIE Parser is free software; you can redistribute it and/or modify
8it under the terms of the Lesser GNU General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or
10(at your option) any later version.
11
12OSSIE Parser is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Lesser GNU General Public License for more details.
16
17You should have received a copy of the Lesser GNU General Public License
18along with OSSIE Parser; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21Even though all code is original, the architecture of the OSSIE Parser is based
22on the architecture of the CRCs SCA Reference Implementation (SCARI)
23see: http://www.crc.ca/en/html/rmsc/home/sdr/projects/scari
24
25*********************************************************************************/
26
27#include "ossie/PRFSimpleProperty.h"
28#include "ossie/prop_helpers.h"
29
30PRFSimpleProperty::PRFSimpleProperty (TiXmlElement *elem) : PRFProperty(elem)
31{
32
33    extract_strings_from_element(elem, value);
34
35    if (isBoolean()) {
36        CORBA::Boolean b = ossieSupport::strings_to_boolean(value);
37        dataType->value <<= CORBA::Any::from_boolean(b);
38        //dataType->value <<= ossieSupport::strings_to_boolean(CORBA::Any::from_boolean(value));
39    } else if (isChar()) {
40        CORBA::Char c = ossieSupport::strings_to_char(value);
41        dataType->value <<= CORBA::Any::from_char(c);
42        //dataType->value <<= ossieSupport::strings_to_char(value);
43    } else if (isDouble()) {
44        dataType->value <<= ossieSupport::strings_to_double(value);
45    } else if (isFloat()) {
46        dataType->value <<= ossieSupport::strings_to_float(value);
47    } else if (isShort()) {
48        dataType->value <<= ossieSupport::strings_to_short(value);
49    } else if (isLong()) {
50        dataType->value <<= ossieSupport::strings_to_long(value);
51    } else if (isOctet()) {
52                CORBA::Octet o = ossieSupport::strings_to_octet(value);
53                dataType->value <<= CORBA::Any::from_octet(o);
54        //dataType->value <<= ossieSupport::strings_to_octet(value);
55    } else if (isUShort()) {
56        dataType->value <<= ossieSupport::strings_to_unsigned_short(value);
57    } else if (isULong()) {
58        dataType->value <<= ossieSupport::strings_to_unsigned_long(value);
59    } else if (isString()) {
60        //dataType->value <<= CORBA::string_dup(value[0].c_str());
61        dataType->value <<= ossieSupport::strings_to_string(value);
62    }
63
64}
65
66
67
68PRFSimpleProperty::~PRFSimpleProperty()
69{
70
71}
72
73void PRFSimpleProperty::extract_strings_from_element(TiXmlElement *elem, std::vector<std::string> &value)
74{
75    TiXmlElement * val = elem->FirstChildElement("value");
76
77    if (val) {
78        std::string str = val->GetText();
79        value.push_back(str);
80    }
81}
Note: See TracBrowser for help on using the browser.