diff options
| -rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 2 | ||||
| -rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 2 | ||||
| -rw-r--r-- | slicer/json/serializer.cpp | 4 | ||||
| -rw-r--r-- | slicer/slicer/modelParts.cpp | 2 | ||||
| -rw-r--r-- | slicer/slicer/modelPartsTypes.impl.h | 5 | ||||
| -rw-r--r-- | slicer/xml/serializer.cpp | 18 | 
6 files changed, 20 insertions, 13 deletions
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index e90fbf2..39925cd 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -96,7 +96,7 @@ namespace Slicer {  	void  	SqlInsertSerializer::bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand * ins, Slicer::ModelPartPtr cmp, HookCommonPtr) const  	{ -		if (cmp) { +		if (cmp->HasValue()) {  			cmp->GetValue(new SqlBinder(*ins, paramNo++));  		}  		else { diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index ce9d868..0289a90 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -52,7 +52,7 @@ namespace Slicer {  		int paramNo = 0;  		cmp->OnEachChild([&upd, ¶mNo](const std::string &, ModelPartPtr cmp, HookCommonPtr h) {  				if (metaDataFlagNotSet(h->GetMetadata(), md_pkey)) { -					if (cmp) { +					if (cmp->HasValue()) {  						cmp->GetValue(new SqlBinder(*upd, paramNo++));  					}  					else { diff --git a/slicer/json/serializer.cpp b/slicer/json/serializer.cpp index 8101a9b..5402cbf 100644 --- a/slicer/json/serializer.cpp +++ b/slicer/json/serializer.cpp @@ -194,6 +194,7 @@ namespace Slicer {  	void  	JsonSerializer::ModelTreeIterateSeq(json::Value * n, ModelPartPtr mp)  	{ +		if (!mp->HasValue()) return;  		auto arr = boost::get<json::Array>(n);  		arr->push_back(json::ValuePtr(new json::Value()));  		ModelTreeIterateRoot(arr->back().get(), mp); @@ -202,6 +203,7 @@ namespace Slicer {  	void  	JsonSerializer::ModelTreeIterateDictObj(json::Value * n, ModelPartPtr mp)  	{ +		if (!mp->HasValue()) return;  		auto obj = boost::get<json::Object>(n);  		json::Object::key_type k;  		auto v = json::ValuePtr(new json::Value()); @@ -219,7 +221,7 @@ namespace Slicer {  		if (name.empty() || !n) {  			return;  		} -		if (mp) { +		if (mp && mp->HasValue()) {  			switch (mp->GetType()) {  				case mpt_Null:  					boost::get<json::Object>(*n).insert({name, json::ValuePtr(new json::Value())}); diff --git a/slicer/slicer/modelParts.cpp b/slicer/slicer/modelParts.cpp index 2a9594b..e33d110 100644 --- a/slicer/slicer/modelParts.cpp +++ b/slicer/slicer/modelParts.cpp @@ -144,7 +144,7 @@ namespace Slicer {  	void  	HookCommon::apply(const ChildHandler & ch, const ModelPartPtr & modelPart)  	{ -		ch(this->name, modelPart && modelPart->HasValue() ? modelPart : ModelPartPtr(), this); +		ch(this->name, modelPart, this);  	}  } diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index 9b9a5a7..98dba9d 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -164,7 +164,7 @@ namespace Slicer {  	ModelPartForOptional<T>::ModelPartForOptional(IceUtil::Optional< typename T::element_type > * h) :  		ModelPartModel<IceUtil::Optional< typename T::element_type> >(h)  	{ -		if (hasModel()) { +		if (this->Model && *this->Model) {  			modelPart = new T(&**this->Model);  		}  	} @@ -172,7 +172,8 @@ namespace Slicer {  	template<typename T>  	bool ModelPartForOptional<T>::hasModel() const  	{ -		return this->Model && *this->Model; +		BOOST_ASSERT(this->Model); +		return *this->Model;  	}  	template<typename T> diff --git a/slicer/xml/serializer.cpp b/slicer/xml/serializer.cpp index 4c0c7c2..899b789 100644 --- a/slicer/xml/serializer.cpp +++ b/slicer/xml/serializer.cpp @@ -294,7 +294,7 @@ namespace Slicer {  	void  	XmlSerializer::ModelTreeIterate(xmlpp::Element * n, const std::string & name, ModelPartPtr mp, HookCommonPtr hp, const ElementCreator & ec)  	{ -		if (!mp || name.empty()) { +		if (!mp->HasValue() || name.empty()) {  			return;  		}  		if (hp && metaDataFlagSet(hp->GetMetadata(), md_attribute)) { @@ -323,9 +323,11 @@ namespace Slicer {  	XmlSerializer::ModelTreeIterateDictAttrs(xmlpp::Element * element, ModelPartPtr dict)  	{  		dict->OnEachChild([element](const auto &, const auto & mp, const auto &) { -			mp->GetChild(keyName)->GetValue(new XmlValueTarget([&mp,element](const auto & name) { -				mp->GetChild(valueName)->GetValue(new XmlAttributeValueTarget(element, name)); -			})); +			if (mp->HasValue()) { +				mp->GetChild(keyName)->GetValue(new XmlValueTarget([&mp,element](const auto & name) { +					mp->GetChild(valueName)->GetValue(new XmlAttributeValueTarget(element, name)); +				})); +			}  		});  	} @@ -333,9 +335,11 @@ namespace Slicer {  	XmlSerializer::ModelTreeIterateDictElements(xmlpp::Element * element, ModelPartPtr dict)  	{  		dict->OnEachChild([element](const auto &, const auto & mp, const auto &) { -			mp->GetChild(keyName)->GetValue(new XmlValueTarget([&mp,element](const auto & name) { -				ModelTreeProcessElement(element->add_child_element(name), mp->GetChild(valueName), defaultElementCreator); -			})); +			if (mp->HasValue()) { +				mp->GetChild(keyName)->GetValue(new XmlValueTarget([&mp,element](const auto & name) { +					ModelTreeProcessElement(element->add_child_element(name), mp->GetChild(valueName), defaultElementCreator); +				})); +			}  		});  	}  | 
