This commit is contained in:
Michael Davidsaver
2013-04-30 15:20:17 -04:00
parent 659ce13e98
commit ee5a370c01
3 changed files with 13 additions and 16 deletions

View File

@@ -45,10 +45,7 @@ static std::vector<String> split(String commaSeparatedList) {
}
Convert::Convert()
: pvDataCreate(getPVDataCreate()),
trueString("true"),
falseString("false"),
illegalScalarType("Illegal ScalarType")
: pvDataCreate(getPVDataCreate())
{}
@@ -298,8 +295,7 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const &
{
if(to->isImmutable()) {
if(from==to) return;
String message("Convert.copyStructure destination is immutable");
throw std::invalid_argument(message);
throw std::invalid_argument("Convert.copyStructure destination is immutable");
}
if(from==to) return;
PVFieldPtrArray const & fromDatas = from->getPVFields();
@@ -343,6 +339,10 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const &
String message("Convert.copyStructure Illegal copyStructure");
throw std::invalid_argument(message);
}
if(toData->isImmutable()) {
if(fromData==toData) return;
throw std::invalid_argument("Convert.copyStructure destination is immutable");
}
switch(fromType) {
case scalar:
{
@@ -415,8 +415,4 @@ ConvertPtr Convert::getConvert()
return convert;
}
ConvertPtr getConvert() {
return Convert::getConvert();
}
}}

View File

@@ -89,7 +89,7 @@ public:
* @param Second field
* @return (false, true) if the fields (are not, are) the same.
*/
bool equals(PVFieldPtr const &a,PVFieldPtr const &b)
inline bool equals(PVFieldPtr const &a,PVFieldPtr const &b)
{
return *a==*b;
}
@@ -101,7 +101,7 @@ public:
* @param Second field
* @return (false, true) if the fields (are not, are) the same.
*/
bool equals(PVField &a,PVField &b)
inline bool equals(PVField &a,PVField &b)
{
return a==b;
}
@@ -820,12 +820,9 @@ public:
private:
Convert();
PVDataCreatePtr pvDataCreate;
String trueString;
String falseString;
String illegalScalarType;
};
extern ConvertPtr getConvert();
static inline ConvertPtr getConvert() { return Convert::getConvert(); }
}}
#endif /* CONVERT_H */

View File

@@ -501,6 +501,10 @@ protected:
}
virtual void assign(const PVScalar& scalar)
{
if(this==&scalar)
return;
if(isImmutable())
throw std::invalid_argument("Destination is immutable");
T result;
scalar.getAs((void*)&result, typeCode);
put(result);