13#include <pv/pvIntrospect.h>
15namespace epics {
namespace nt {
39 std::ostream&
dump(std::ostream& os)
const {
40 os <<
"Error(path=" << (
path.empty() ?
"<root>" :
path) <<
": ";
52 epics::pvData::FieldConstPtr
field;
61 Result(
const epics::pvData::FieldConstPtr&
field,
const std::string&
path = std::string())
90 if (!
dynamic_cast<T
const *
>(
field.get())) {
109 T
const *s =
dynamic_cast<T
const *
>(
field.get());
113 }
else if (s->getID() !=
id) {
131 template<Result& (*fn)(Result&)>
145 template<Result& (*fn)(Result&)>
164 template<Result& (*fn)(Result&),
typename T>
166 return has<T>(name,
false, fn);
181 template<Result& (*fn)(Result&),
typename T>
183 return has<T>(name,
true, fn);
201 return has<T>(name,
false, NULL);
217 return has<T>(name,
true, NULL);
220 std::ostream&
dump(std::ostream& os)
const {
221 os <<
"Result(valid=" << (
result ==
Pass) <<
", errors=[ ";
223 std::vector<Error>::const_iterator it;
235 epics::pvData::FieldConstPtr subField;
237 switch(
field->getType()) {
238 case epics::pvData::structure:
239 subField =
static_cast<epics::pvData::Structure
const *
>(
field.get())->getField(name);
241 case epics::pvData::structureArray:
242 subField =
static_cast<epics::pvData::StructureArray
const *
>(
field.get())->getStructure()->getField(name);
244 case epics::pvData::union_:
245 subField =
static_cast<epics::pvData::Union
const *
>(
field.get())->getField(name);
247 case epics::pvData::unionArray:
248 subField =
static_cast<epics::pvData::UnionArray
const *
>(
field.get())->getUnion()->getField(name);
257 std::string subFieldPath(
path.empty() ? name :
path +
"." + name);
264 }
else if (!
dynamic_cast<T
const *
>(subField.get())) {
268 Result r(subField, subFieldPath);
std::ostream & dump(std::ostream &os) const
Error(std::string const &path, Type type)
bool operator==(const Error &other) const
enum epics::nt::Result::Error::Type type
Validation methods for NT types.
Result(const epics::pvData::FieldConstPtr &field, const std::string &path=std::string())
Result & maybeHas(const std::string &name)
Result & is(const std::string &id)
Result & operator|=(const Result &other)
Result & has(const std::string &name)
std::vector< Error > errors
epics::pvData::FieldConstPtr field
enum epics::nt::Result::result_t result
std::ostream & dump(std::ostream &os) const
Result & maybeHas(const std::string &name)
Result & has(const std::string &name)