| 1 | /******************************************************************************* |
|---|
| 2 | |
|---|
| 3 | Copyright 2004, 2005, 2006, 2007 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE Parser. |
|---|
| 6 | |
|---|
| 7 | OSSIE Parser is free software; you can redistribute it and/or modify |
|---|
| 8 | it under the terms of the Lesser GNU General Public License as published by |
|---|
| 9 | the Free Software Foundation; either version 2.1 of the License, or |
|---|
| 10 | (at your option) any later version. |
|---|
| 11 | |
|---|
| 12 | OSSIE Parser is distributed in the hope that it will be useful, |
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | Lesser GNU General Public License for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the Lesser GNU General Public License |
|---|
| 18 | along with OSSIE Parser; if not, write to the Free Software |
|---|
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | Even though all code is original, the architecture of the OSSIE Parser is based |
|---|
| 22 | on the architecture of the CRCs SCA Reference Implementation (SCARI) |
|---|
| 23 | see: 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 | |
|---|
| 30 | PRFSimpleProperty::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 | |
|---|
| 68 | PRFSimpleProperty::~PRFSimpleProperty() |
|---|
| 69 | { |
|---|
| 70 | |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | void 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 | } |
|---|