equal
deleted
inserted
replaced
41 |
41 |
42 #define ATTRIBUTE_CHECKER_DEFINE(type) \ |
42 #define ATTRIBUTE_CHECKER_DEFINE(type) \ |
43 class type##Checker : public AttributeChecker {}; \ |
43 class type##Checker : public AttributeChecker {}; \ |
44 Ptr<const AttributeChecker> Make##type##Checker (void); \ |
44 Ptr<const AttributeChecker> Make##type##Checker (void); \ |
45 |
45 |
46 #define ATTRIBUTE_VALUE_IMPLEMENT(type) \ |
46 #define ATTRIBUTE_VALUE_IMPLEMENT_NO_SERIALIZE(type) \ |
47 type##Value::type##Value (const type &value) \ |
47 type##Value::type##Value (const type &value) \ |
48 : m_value (value) {} \ |
48 : m_value (value) {} \ |
49 void type##Value::Set (const type &v) { \ |
49 void type##Value::Set (const type &v) { \ |
50 m_value = v; \ |
50 m_value = v; \ |
51 } \ |
51 } \ |
53 return m_value; \ |
53 return m_value; \ |
54 } \ |
54 } \ |
55 Attribute \ |
55 Attribute \ |
56 type##Value::Copy (void) const { \ |
56 type##Value::Copy (void) const { \ |
57 return Attribute::Create<type##Value> (*this); \ |
57 return Attribute::Create<type##Value> (*this); \ |
58 } \ |
|
59 std::string \ |
|
60 type##Value::SerializeToString (Ptr<const AttributeChecker> checker) const { \ |
|
61 std::ostringstream oss; \ |
|
62 oss << m_value; \ |
|
63 return oss.str (); \ |
|
64 } \ |
|
65 bool \ |
|
66 type##Value::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) { \ |
|
67 std::istringstream iss; \ |
|
68 iss.str (value); \ |
|
69 iss >> m_value; \ |
|
70 return !iss.bad () && !iss.fail (); \ |
|
71 } \ |
58 } \ |
72 type##Value::type##Value (Attribute value) \ |
59 type##Value::type##Value (Attribute value) \ |
73 { \ |
60 { \ |
74 type##Value *v = value.DynCast<type##Value *> (); \ |
61 type##Value *v = value.DynCast<type##Value *> (); \ |
75 if (v == 0) \ |
62 if (v == 0) \ |
80 } \ |
67 } \ |
81 type##Value::operator Attribute () const \ |
68 type##Value::operator Attribute () const \ |
82 { \ |
69 { \ |
83 return Attribute::Create<type##Value> (*this); \ |
70 return Attribute::Create<type##Value> (*this); \ |
84 } |
71 } |
|
72 |
|
73 #define ATTRIBUTE_VALUE_IMPLEMENT(type) \ |
|
74 std::string \ |
|
75 type##Value::SerializeToString (Ptr<const AttributeChecker> checker) const { \ |
|
76 std::ostringstream oss; \ |
|
77 oss << m_value; \ |
|
78 return oss.str (); \ |
|
79 } \ |
|
80 bool \ |
|
81 type##Value::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) { \ |
|
82 std::istringstream iss; \ |
|
83 iss.str (value); \ |
|
84 iss >> m_value; \ |
|
85 return !iss.bad () && !iss.fail (); \ |
|
86 } \ |
|
87 ATTRIBUTE_VALUE_IMPLEMENT_NO_SERIALIZE (type) |
85 |
88 |
86 #define ATTRIBUTE_CHECKER_IMPLEMENT(type) \ |
89 #define ATTRIBUTE_CHECKER_IMPLEMENT(type) \ |
87 Ptr<const AttributeChecker> Make##type##Checker (void) \ |
90 Ptr<const AttributeChecker> Make##type##Checker (void) \ |
88 { \ |
91 { \ |
89 return MakeSimpleAttributeChecker<type##Value,type##Checker> (); \ |
92 return MakeSimpleAttributeChecker<type##Value,type##Checker> (); \ |