Mercurial > hg > svcore
comparison base/PropertyContainer.cpp @ 689:573d45e9487b
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:47:59 +0100 |
parents | 06f13a3b9e9e |
children | 1424aa29ae95 |
comparison
equal
deleted
inserted
replaced
688:be43b2fe68e8 | 689:573d45e9487b |
---|---|
66 } | 66 } |
67 | 67 |
68 void | 68 void |
69 PropertyContainer::setProperty(const PropertyName &name, int) | 69 PropertyContainer::setProperty(const PropertyName &name, int) |
70 { | 70 { |
71 std::cerr << "WARNING: PropertyContainer[" << getPropertyContainerName().toStdString() << "]::setProperty(" << name.toStdString() << "): no implementation in subclass!" << std::endl; | 71 std::cerr << "WARNING: PropertyContainer[" << getPropertyContainerName() << "]::setProperty(" << name << "): no implementation in subclass!" << std::endl; |
72 } | 72 } |
73 | 73 |
74 Command * | 74 Command * |
75 PropertyContainer::getSetPropertyCommand(const PropertyName &name, int value) | 75 PropertyContainer::getSetPropertyCommand(const PropertyName &name, int value) |
76 { | 76 { |
84 { | 84 { |
85 PropertyName name; | 85 PropertyName name; |
86 int value; | 86 int value; |
87 if (!convertPropertyStrings(nameString, valueString, name, value)) { | 87 if (!convertPropertyStrings(nameString, valueString, name, value)) { |
88 std::cerr << "WARNING: PropertyContainer::setProperty(\"" | 88 std::cerr << "WARNING: PropertyContainer::setProperty(\"" |
89 << nameString.toStdString() << "\", \"" | 89 << nameString << "\", \"" |
90 << valueString.toStdString() | 90 << valueString.toStdString() |
91 << "\"): Name and value conversion failed" << std::endl; | 91 << "\"): Name and value conversion failed" << std::endl; |
92 return; | 92 return; |
93 } | 93 } |
94 setProperty(name, value); | 94 setProperty(name, value); |
99 { | 99 { |
100 PropertyName name; | 100 PropertyName name; |
101 int value; | 101 int value; |
102 if (!convertPropertyStrings(nameString, valueString, name, value)) { | 102 if (!convertPropertyStrings(nameString, valueString, name, value)) { |
103 std::cerr << "WARNING: PropertyContainer::getSetPropertyCommand(\"" | 103 std::cerr << "WARNING: PropertyContainer::getSetPropertyCommand(\"" |
104 << nameString.toStdString() << "\", \"" | 104 << nameString << "\", \"" |
105 << valueString.toStdString() | 105 << valueString.toStdString() |
106 << "\"): Name and value conversion failed" << std::endl; | 106 << "\"): Name and value conversion failed" << std::endl; |
107 return 0; | 107 return 0; |
108 } | 108 } |
109 return getSetPropertyCommand(name, value); | 109 return getSetPropertyCommand(name, value); |
133 break; | 133 break; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 if (name == "") { | 137 if (name == "") { |
138 std::cerr << "PropertyContainer::convertPropertyStrings: Unable to match name string \"" << nameString.toStdString() << "\"" << std::endl; | 138 std::cerr << "PropertyContainer::convertPropertyStrings: Unable to match name string \"" << nameString << "\"" << std::endl; |
139 return false; | 139 return false; |
140 } | 140 } |
141 | 141 |
142 value = 0; | 142 value = 0; |
143 bool success = false; | 143 bool success = false; |
190 if (value >= 0) success = true; | 190 if (value >= 0) success = true; |
191 else value = 0; | 191 else value = 0; |
192 break; | 192 break; |
193 | 193 |
194 case InvalidProperty: | 194 case InvalidProperty: |
195 std::cerr << "PropertyContainer::convertPropertyStrings: Invalid property name \"" << name.toStdString() << "\"" << std::endl; | 195 DEBUG << "PropertyContainer::convertPropertyStrings: Invalid property name \"" << name << "\"" << endl; |
196 return false; | 196 return false; |
197 } | 197 } |
198 | 198 |
199 if (success) return true; | 199 if (success) return true; |
200 | 200 |
202 getPropertyRangeAndValue(name, &min, &max, 0); | 202 getPropertyRangeAndValue(name, &min, &max, 0); |
203 | 203 |
204 bool ok = false; | 204 bool ok = false; |
205 int i = valueString.toInt(&ok); | 205 int i = valueString.toInt(&ok); |
206 if (!ok) { | 206 if (!ok) { |
207 std::cerr << "PropertyContainer::convertPropertyStrings: Unable to parse value string \"" << valueString.toStdString() << "\"" << std::endl; | 207 std::cerr << "PropertyContainer::convertPropertyStrings: Unable to parse value string \"" << valueString << "\"" << std::endl; |
208 return false; | 208 return false; |
209 } else if (i < min || i > max) { | 209 } else if (i < min || i > max) { |
210 std::cerr << "PropertyContainer::convertPropertyStrings: Property value \"" << i << "\" outside valid range " << min << " to " << max << std::endl; | 210 DEBUG << "PropertyContainer::convertPropertyStrings: Property value \"" << i << "\" outside valid range " << min << " to " << max << endl; |
211 return false; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 value = i; | 214 value = i; |
215 return true; | 215 return true; |