00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "UAPAttribute.hpp"
00025
00026 namespace BU = BasicUtilities;
00027 using namespace std;
00028
00029 UAPAttribute::UAPAttribute(const string& _name, const string& _value)
00030 : name(_name),value(_value) {}
00031
00032 void UAPAttribute::setName(const string& _name)
00033 {
00034 name = _name;
00035 }
00036
00037 void UAPAttribute::setValue(const string& _value)
00038 {
00039 value = _value;
00040 }
00041
00042 string UAPAttribute::getName() const
00043 {
00044 return name;
00045 }
00046
00047 string UAPAttribute::getValue() const
00048 {
00049 return value;
00050 }
00051
00052 string UAPAttribute::toString() const
00053 {
00054 return (name+" = \""+value+"\"");
00055 }
00056
00057 bool UAPAttribute::getInt(int& num) {
00058 bool ok;
00059 num = BU::string_to_int(value, ok);
00060 return ok;
00061 }
00062
00063 bool UAPAttribute::getDouble(double& num) {
00064 bool ok;
00065 num = BU::string_to_double(value, ok);
00066 return ok;
00067 }
00068
00069 bool UAPAttribute::getBool(bool& num) {
00070 bool ok;
00071 num = BU::string_to_bool(value, ok);
00072 return ok;
00073 }
00074
00075 std::ostream& operator << (std::ostream& os, const UAPAttribute& attr)
00076 {
00077 os<<attr.toString();
00078 return os;
00079 }
00080
00081 std::ostream& operator << (std::ostream& os, const UAPAttribute* attr)
00082 {
00083 os<<attr->toString();
00084 return os;
00085 }