39 #ifndef OME_XML_MODEL_DETAIL_PARSE_H
40 #define OME_XML_MODEL_DETAIL_PARSE_H
42 #include <ome/xml/model/OMEModelObject.h>
44 #include <boost/mpl/bool.hpp>
45 #include <boost/type_traits.hpp>
66 const std::string& klass,
67 const std::string& property);
72 : boost::false_type {};
77 : boost::true_type {};
92 const std::string& klass,
93 const std::string& property)
95 std::istringstream is(text);
96 is.imbue(std::locale::classic());
115 const std::string& klass,
116 const std::string& property)
118 std::istringstream is(text);
119 is.imbue(std::locale::classic());
121 if (!(is >> std::boolalpha >> value))
129 # pragma GCC diagnostic push
130 # pragma GCC diagnostic ignored "-Wunused-parameter"
144 parse_value<std::string>(
const std::string& text,
146 const std::string& klass,
147 const std::string& property)
153 # pragma GCC diagnostic pop
166 inline typename boost::disable_if_c<
167 is_shared_ptr<T>::value,
168 typename boost::remove_const<typename boost::remove_reference<T>::type>::type
171 const std::string& klass,
172 const std::string& property)
174 typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type raw_type;
191 inline typename boost::enable_if_c<
192 is_shared_ptr<T>::value,
193 typename boost::remove_const<typename boost::remove_reference<T>::type>::type
196 const std::string& klass,
197 const std::string& property)
199 typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type raw_type;
201 raw_type attr(ome::compat::make_shared<typename raw_type::element_type>());
220 template<
class C,
typename T>
224 void (C::* setter)(T value),
225 const std::string& klass,
226 const std::string& property)
228 typedef typename boost::remove_const<typename boost::remove_reference<T>::type>::type raw_type;
230 raw_type attr(parse_value<raw_type>(text, klass, property));
232 (
object.*setter)(attr);
240 #endif // OME_XML_MODEL_DETAIL_PARSE_H
void parse_value< bool >(const std::string &text, bool &value, const std::string &klass, const std::string &property)
Parse a Boolean value.
Definition: Parse.h:113
void parse_value(const std::string &text, T &value, const std::string &klass, const std::string &property)
Parse an arbitrary value.
Definition: Parse.h:90
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
void set_value(const std::string &text, C &object, void(C::*setter)(T value), const std::string &klass, const std::string &property)
Set an arbitrary value.
Definition: Parse.h:222
Type trait for shared_ptr.
Definition: Parse.h:71
void parse_value_fail(const std::string &text, const std::string &klass, const std::string &property)
Throw a model exception with an informative message.
Definition: Parse.cpp:54
Xerces-C modern C++ wrapper.
Definition: Base.h:53