10#define epicsExportSharedSymbols
15using namespace epics::pvData;
17namespace epics {
namespace nt {
26 if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
27 throw std::runtime_error(
"duplicate query field name");
29 queryFieldNames.push_back(name);
30 queryTypes.push_back(pvString);
32 return shared_from_this();
37 if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
38 throw std::runtime_error(
"duplicate query field name");
40 queryFieldNames.push_back(name);
41 queryTypes.push_back(pvDouble);
43 return shared_from_this();
48 if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
49 throw std::runtime_error(
"duplicate query field name");
51 queryFieldNames.push_back(name);
52 queryTypes.push_back(pvInt);
54 return shared_from_this();
59 FieldBuilderPtr builder = getFieldCreate()->
60 createFieldBuilder()->
62 add(
"scheme", pvString);
65 builder->add(
"authority", pvString);
67 builder->add(
"path", pvString);
69 if (!queryFieldNames.empty())
71 FieldBuilderPtr nestedBuilder = builder->
72 addNestedStructure(
"query");
74 vector<string>::size_type len = queryFieldNames.size();
75 for (vector<string>::size_type i = 0; i < len; i++)
76 nestedBuilder->add(queryFieldNames[i], queryTypes[i]);
78 builder = nestedBuilder->endNested();
81 size_t extraCount = extraFieldNames.size();
82 for (
size_t i = 0; i< extraCount; i++)
83 builder->add(extraFieldNames[i], extraFields[i]);
85 StructureConstPtr s = builder->createStructure();
94 return shared_from_this();
107NTURIBuilder::NTURIBuilder()
112void NTURIBuilder::reset()
114 queryFieldNames.clear();
121 extraFields.push_back(field);
122 extraFieldNames.push_back(name);
123 return shared_from_this();
128const std::string
NTURI::URI(
"epics:nt/NTURI:1.0");
130NTURI::shared_pointer
NTURI::wrap(PVStructurePtr
const & pvStructure)
138 return shared_pointer(
new NTURI(pvStructure));
141bool NTURI::is_a(StructureConstPtr
const & structure)
146bool NTURI::is_a(PVStructurePtr
const & pvStructure)
148 return is_a(pvStructure->getStructure());
156 Result result(structure);
160 .has<Scalar>(
"scheme")
162 .maybeHas<Scalar>(
"authority")
163 .maybeHas<Structure>(
"query");
165 StructureConstPtr query(structure->getField<Structure>(
"query"));
168 StringArray
const & names(query->getFieldNames());
169 StringArray::const_iterator it;
171 for (it = names.begin(); it != names.end(); ++it)
172 r.has<ScalarArray>(*it);
177 return result.valid();
183 if(!pvStructure)
return false;
207 return pvNTURI->getSubField<PVString>(
"scheme");
212 return pvNTURI->getSubField<PVString>(
"authority");
217 return pvNTURI->getSubField<PVString>(
"path");
222 return pvNTURI->getSubField<PVStructure>(
"query");
227 return pvNTURI->getSubField<PVStructure>(
"query")->getStructure()->getFieldNames();
232 return pvNTURI->getSubField(
"query." + name);
235NTURI::NTURI(PVStructurePtr
const & pvStructure) :
Convenience Class for NTURI.
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
epics::pvData::PVStringPtr getPath() const
epics::pvData::PVStringPtr getAuthority() const
static const std::string URI
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
static bool is_a(epics::pvData::StructureConstPtr const &structure)
epics::pvData::PVFieldPtr getQueryField(std::string const &name) const
static NTURIBuilderPtr createBuilder()
epics::pvData::PVStringPtr getScheme() const
static shared_pointer wrap(epics::pvData::PVStructurePtr const &pvStructure)
epics::pvData::PVStructurePtr getQuery() const
epics::pvData::PVStructurePtr getPVStructure() const
epics::pvData::StringArray const & getQueryNames() const
static bool is_a(const std::string &u1, const std::string &u2)
Interface for in-line creating of NTURI.
epics::pvData::PVStructurePtr createPVStructure()
shared_pointer addQueryInt(std::string const &name)
shared_pointer addAuthority()
shared_pointer add(std::string const &name, epics::pvData::FieldConstPtr const &field)
friend class ::epics::nt::NTURI
shared_pointer addQueryString(std::string const &name)
shared_pointer addQueryDouble(std::string const &name)
epics::pvData::StructureConstPtr createStructure()
std::tr1::shared_ptr< NTField > NTFieldPtr
std::tr1::shared_ptr< detail::NTURIBuilder > NTURIBuilderPtr
std::tr1::shared_ptr< NTURI > NTURIPtr