diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md
index 61ca2d7..2076f68 100644
--- a/documentation/RELEASE_NOTES.md
+++ b/documentation/RELEASE_NOTES.md
@@ -7,7 +7,7 @@ The main changes since release 4.0 are:
* Convert::copyUnion now always copies between subfields.
* CreateRequest prevents a possible SEGFAULT.
* New stream operators for Field and PVField are provided.
-* New method getAs that is like getSubField except that it throws exception
+* New method getSubFieldT that is like getSubField except that it throws exception
Convert copy methods and equals operators
-----------------------------------------
@@ -73,10 +73,10 @@ Now it can be done as follows:
cout << pv << endl;
}
-New method getAs that is like getSubField except that it throws exception
+New method getSubFieldT that is like getSubField except that it throws exception
--------------------
-PVStructure has a new template member getAs(const char *name)
+PVStructure has a new template member getSubFieldT(std::string const &fieldName)
that is like getSubField except that it throws a runtime_error
instead of returning null.
diff --git a/documentation/pvDataCPP.html b/documentation/pvDataCPP.html
index 6ea31bd..8618d59 100644
--- a/documentation/pvDataCPP.html
+++ b/documentation/pvDataCPP.html
@@ -465,10 +465,10 @@ structure
PVStructurePtr doubleValue = getPVDataCreate()->createPVStructure(
getStandardField()->scalar(pvDouble,"alarm,timeStamp"));
PVDoublePtr pvdouble =
- doubleValue->getAs<PVDouble>("value");
+ doubleValue->getSubField<PVDouble>("value");
pvdouble->put(1e5);
cout << *doubleValue << endl;
- double value = doubleValue->getAs<PVDouble>("value")->get();
+ double value = doubleValue->getSubField<PVDouble>("value")->get();
cout << "from get " << value << "\n\n";
This produces:
@@ -491,7 +491,7 @@ from get 100000
PVStructurePtr doubleArrayValue = pvDataCreate->createPVStructure(
standardField->scalarArray(pvDouble,"alarm,timeStamp"));
PVDoubleArrayPtr pvDoubleArray =
- doubleArrayValue->getAs<PVDoubleArray>("value");
+ doubleArrayValue->getSubField<PVDoubleArray>("value");
size_t len = 10;
shared_vector<double> xxx(len);
for(size_t i=0; i< len; ++i) xxx[i] = i;
@@ -605,10 +605,10 @@ structure
createUnion(),
"alarm,timeStamp"));
PVStructurePtr pvTimeStamp =
- pvStructure->getAs<PVUnion>("value")->select<PVStructure>(2);
- pvTimeStamp->getAs<PVLong>("secondsPastEpoch")->put(1000);
+ pvStructure->getSubField<PVUnion>("value")->select<PVStructure>(2);
+ pvTimeStamp->getSubField<PVLong>("secondsPastEpoch")->put(1000);
cout << *pvStructure) << "\n";
- pvStructure->getAs<PVUnion>("value")->select<PVDouble>(0)->put(1e5);
+ pvStructure->getSubField<PVUnion>("value")->select<PVDouble>(0)->put(1e5);
cout << *pvStructure << "\n\n";
This produces:
@@ -648,13 +648,13 @@ epics:nt/NTUnion:1.0
standardField->variantUnion("alarm,timeStamp"));
PVStructurePtr pvTimeStamp =
pvDataCreate->createPVStructure(standardField->timeStamp());
- pvStructure->getAs<PVUnion>("value")->set(pvTimeStamp);
- pvTimeStamp->getAs<PVLong>("secondsPastEpoch")->put(1000);
+ pvStructure->getSubField<PVUnion>("value")->set(pvTimeStamp);
+ pvTimeStamp->getSubField<PVLong>("secondsPastEpoch")->put(1000);
cout << *pvStructure << "\n";
- pvStructure->getAs<PVUnion>("value")->set(
+ pvStructure->getSubField<PVUnion>("value")->set(
pvDataCreate->createPVScalar(pvDouble));
PVDoublePtr pvValue = static_pointer_cast<PVDouble>(
- pvStructure->getAs<PVUnion>("value")->get());
+ pvStructure->getSubField<PVUnion>("value")->get());
pvValue->put(1e5);
cout << *pvStructure << "\n\n";
@@ -718,7 +718,7 @@ epics:nt/NTUnion:1.0
cout << *pvStructure->getStructure() << endl;
cout << "data\n";
cout << *pvStructure << "\n";
- PVUnionPtr pvUnion = pvStructure->getAs<PVUnion>("value");;
+ PVUnionPtr pvUnion = pvStructure->getSubField<PVUnion>("value");;
pvUnion->select("doubleValue");
PVDoublePtr pvDouble = pvUnion->get<PVDouble>();
pvDouble->put(1.55);
@@ -726,7 +726,7 @@ epics:nt/NTUnion:1.0
cout << *pvStructure << "\n";
cout << "value = " << pvDouble->get() << "\n";
pvUnion->select("structValue");
- pvDouble = pvUnion->get<PVStructure>()->getAs<PVDouble>("doubleValue");
+ pvDouble = pvUnion->get<PVStructure>()->getSubField<PVDouble>("doubleValue");
pvDouble->put(1.65);
cout << "select structValue\n";
cout << *pvStructure << "\n";
@@ -2304,14 +2304,14 @@ public:
template<typename PVT>
std::tr1::shared_ptr<PVT> getSubField(std::string const &fieldName) const
- template<typename PVT>
- PVT& getAs(const char *name) const;
-
PVFieldPtr getSubField(std::size_t fieldOffset) const;
template<typename PVT>
std::tr1::shared_ptr<PVT> getSubField(std::size_t fieldOffset) const
+ template<typename PVT>
+ PVT& getSubFieldT(std::string const &fieldName) const;
+
virtual void serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher) const ;
virtual void deserialize(
@@ -2332,9 +2332,6 @@ public:
getPVFields
Returns the array of subfields. The set of subfields must all have
different field names.
- getAs(const char *name)
- Like the getSubField except that it throws std::runtime_error if
- the field does not exists or has the wrong type.
getSubField(std::string fieldName)
Get a subField of a field.d
@@ -2353,6 +2350,9 @@ public:
Note The template version replaces getBooleanField, etc.
+ getSubFieldT(std::string const &fieldName)
+ Like getSubField except that it throws std::runtime_error if
+ the field does not exists or has the wrong type.
dumpValue
Method for streams I/O.
@@ -5414,7 +5414,7 @@ public:
raiseMonitor = true;
if(pvFieldOptions!=NULL) {
PVStringPtr pvString =
- pvFieldOptions->getAs<PVString>("raiseMonitor");
+ pvFieldOptions->getSubField<PVString>("raiseMonitor");
if(pvString!=NULL) {
std::string value = pvString->get();
if(value.compare("false")==0) raiseMonitor = false;
diff --git a/documentation/pvDataCPP_20150623.html b/documentation/pvDataCPP_20150623.html
index 6ea31bd..8618d59 100644
--- a/documentation/pvDataCPP_20150623.html
+++ b/documentation/pvDataCPP_20150623.html
@@ -465,10 +465,10 @@ structure
PVStructurePtr doubleValue = getPVDataCreate()->createPVStructure(
getStandardField()->scalar(pvDouble,"alarm,timeStamp"));
PVDoublePtr pvdouble =
- doubleValue->getAs<PVDouble>("value");
+ doubleValue->getSubField<PVDouble>("value");
pvdouble->put(1e5);
cout << *doubleValue << endl;
- double value = doubleValue->getAs<PVDouble>("value")->get();
+ double value = doubleValue->getSubField<PVDouble>("value")->get();
cout << "from get " << value << "\n\n";
This produces:
@@ -491,7 +491,7 @@ from get 100000
PVStructurePtr doubleArrayValue = pvDataCreate->createPVStructure(
standardField->scalarArray(pvDouble,"alarm,timeStamp"));
PVDoubleArrayPtr pvDoubleArray =
- doubleArrayValue->getAs<PVDoubleArray>("value");
+ doubleArrayValue->getSubField<PVDoubleArray>("value");
size_t len = 10;
shared_vector<double> xxx(len);
for(size_t i=0; i< len; ++i) xxx[i] = i;
@@ -605,10 +605,10 @@ structure
createUnion(),
"alarm,timeStamp"));
PVStructurePtr pvTimeStamp =
- pvStructure->getAs<PVUnion>("value")->select<PVStructure>(2);
- pvTimeStamp->getAs<PVLong>("secondsPastEpoch")->put(1000);
+ pvStructure->getSubField<PVUnion>("value")->select<PVStructure>(2);
+ pvTimeStamp->getSubField<PVLong>("secondsPastEpoch")->put(1000);
cout << *pvStructure) << "\n";
- pvStructure->getAs<PVUnion>("value")->select<PVDouble>(0)->put(1e5);
+ pvStructure->getSubField<PVUnion>("value")->select<PVDouble>(0)->put(1e5);
cout << *pvStructure << "\n\n";
This produces:
@@ -648,13 +648,13 @@ epics:nt/NTUnion:1.0
standardField->variantUnion("alarm,timeStamp"));
PVStructurePtr pvTimeStamp =
pvDataCreate->createPVStructure(standardField->timeStamp());
- pvStructure->getAs<PVUnion>("value")->set(pvTimeStamp);
- pvTimeStamp->getAs<PVLong>("secondsPastEpoch")->put(1000);
+ pvStructure->getSubField<PVUnion>("value")->set(pvTimeStamp);
+ pvTimeStamp->getSubField<PVLong>("secondsPastEpoch")->put(1000);
cout << *pvStructure << "\n";
- pvStructure->getAs<PVUnion>("value")->set(
+ pvStructure->getSubField<PVUnion>("value")->set(
pvDataCreate->createPVScalar(pvDouble));
PVDoublePtr pvValue = static_pointer_cast<PVDouble>(
- pvStructure->getAs<PVUnion>("value")->get());
+ pvStructure->getSubField<PVUnion>("value")->get());
pvValue->put(1e5);
cout << *pvStructure << "\n\n";
@@ -718,7 +718,7 @@ epics:nt/NTUnion:1.0
cout << *pvStructure->getStructure() << endl;
cout << "data\n";
cout << *pvStructure << "\n";
- PVUnionPtr pvUnion = pvStructure->getAs<PVUnion>("value");;
+ PVUnionPtr pvUnion = pvStructure->getSubField<PVUnion>("value");;
pvUnion->select("doubleValue");
PVDoublePtr pvDouble = pvUnion->get<PVDouble>();
pvDouble->put(1.55);
@@ -726,7 +726,7 @@ epics:nt/NTUnion:1.0
cout << *pvStructure << "\n";
cout << "value = " << pvDouble->get() << "\n";
pvUnion->select("structValue");
- pvDouble = pvUnion->get<PVStructure>()->getAs<PVDouble>("doubleValue");
+ pvDouble = pvUnion->get<PVStructure>()->getSubField<PVDouble>("doubleValue");
pvDouble->put(1.65);
cout << "select structValue\n";
cout << *pvStructure << "\n";
@@ -2304,14 +2304,14 @@ public:
template<typename PVT>
std::tr1::shared_ptr<PVT> getSubField(std::string const &fieldName) const
- template<typename PVT>
- PVT& getAs(const char *name) const;
-
PVFieldPtr getSubField(std::size_t fieldOffset) const;
template<typename PVT>
std::tr1::shared_ptr<PVT> getSubField(std::size_t fieldOffset) const
+ template<typename PVT>
+ PVT& getSubFieldT(std::string const &fieldName) const;
+
virtual void serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher) const ;
virtual void deserialize(
@@ -2332,9 +2332,6 @@ public:
getPVFields
Returns the array of subfields. The set of subfields must all have
different field names.
- getAs(const char *name)
- Like the getSubField except that it throws std::runtime_error if
- the field does not exists or has the wrong type.
getSubField(std::string fieldName)
Get a subField of a field.d
@@ -2353,6 +2350,9 @@ public:
Note The template version replaces getBooleanField, etc.
+ getSubFieldT(std::string const &fieldName)
+ Like getSubField except that it throws std::runtime_error if
+ the field does not exists or has the wrong type.
dumpValue
Method for streams I/O.
@@ -5414,7 +5414,7 @@ public:
raiseMonitor = true;
if(pvFieldOptions!=NULL) {
PVStringPtr pvString =
- pvFieldOptions->getAs<PVString>("raiseMonitor");
+ pvFieldOptions->getSubField<PVString>("raiseMonitor");
if(pvString!=NULL) {
std::string value = pvString->get();
if(value.compare("false")==0) raiseMonitor = false;
diff --git a/src/factory/PVStructure.cpp b/src/factory/PVStructure.cpp
index 0b8fb02..5319369 100644
--- a/src/factory/PVStructure.cpp
+++ b/src/factory/PVStructure.cpp
@@ -107,7 +107,7 @@ const PVFieldPtrArray & PVStructure::getPVFields() const
PVFieldPtr PVStructure::getSubField(string const &fieldName) const
{
- PVField * field = GetAsImpl(fieldName.c_str(), false);
+ PVField * field = getSubFieldImpl(fieldName.c_str(), false);
if (field)
return field->shared_from_this();
else
@@ -134,7 +134,7 @@ PVFieldPtr PVStructure::getSubField(size_t fieldOffset) const
throw std::logic_error("PVStructure.getSubField: Logic error");
}
-PVField* PVStructure::GetAsImpl(const char *name, bool throws) const
+PVField* PVStructure::getSubFieldImpl(const char *name, bool throws) const
{
const PVStructure *parent = this;
if(!name)
diff --git a/src/pv/pvData.h b/src/pv/pvData.h
index 797cb04..0e0e6b2 100644
--- a/src/pv/pvData.h
+++ b/src/pv/pvData.h
@@ -712,7 +712,7 @@ public:
}
private:
- PVField *GetAsImpl(const char *name, bool throws = true) const;
+ PVField *getSubFieldImpl(const char *name, bool throws = true) const;
public:
/**
@@ -721,13 +721,13 @@ public:
* @returns A reference to the sub-field (never NULL)
* @throws std::runtime_error if the requested sub-field doesn't exist, or has a different type
* @code
- * PVInt& ref = pvStruct->getAs("substruct.leaffield");
+ * PVInt& ref = pvStruct->getSubFieldT("substruct.leaffield");
* @endcode
*/
template
- PVT& getAs(const char *name) const
+ PVT& getSubFieldT(const char *name) const
{
- PVT *raw = dynamic_cast(GetAsImpl(name));
+ PVT *raw = dynamic_cast(getSubFieldImpl(name));
if(!raw)
{
std::stringstream ss;
@@ -738,9 +738,9 @@ public:
}
template
- FORCE_INLINE PVT& getAs(std::string const &fieldName) const
+ FORCE_INLINE PVT& getSubFieldT(std::string const &fieldName) const
{
- return this->getAs(fieldName.c_str());
+ return this->getSubFieldT(fieldName.c_str());
}
/**
diff --git a/testApp/pv/testPVData.cpp b/testApp/pv/testPVData.cpp
index 12b4092..747d8c6 100644
--- a/testApp/pv/testPVData.cpp
+++ b/testApp/pv/testPVData.cpp
@@ -541,7 +541,7 @@ static void testFieldAccess()
PVIntPtr a = fld->getSubField("test");
testOk1(a!=NULL);
if(a.get()) {
- PVInt& b = fld->getAs("test");
+ PVInt& b = fld->getSubFieldT("test");
testOk(&b==a.get(), "%p == %p", &b, a.get());
} else
testSkip(1, "test doesn't exist?");
@@ -549,7 +549,7 @@ static void testFieldAccess()
a = fld->getSubField("hello.world");
testOk1(a!=NULL);
if(a.get()) {
- PVInt& b = fld->getAs("hello.world");
+ PVInt& b = fld->getSubFieldT("hello.world");
testOk(&b==a.get(), "%p == %p", &b, a.get());
} else
testSkip(1, "hello.world doesn't exist?");
@@ -579,7 +579,7 @@ static void testFieldAccess()
// null string
try{
char * name = NULL;
- fld->getAs(name);
+ fld->getSubFieldT(name);
testFail("missing required exception");
}catch(std::invalid_argument& e){
testPass("caught expected exception: %s", e.what());
@@ -587,7 +587,7 @@ static void testFieldAccess()
// non-existent
try{
- fld->getAs("invalid");
+ fld->getSubFieldT("invalid");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
@@ -595,7 +595,7 @@ static void testFieldAccess()
// wrong type
try{
- fld->getAs("test");
+ fld->getSubFieldT("test");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
@@ -603,7 +603,7 @@ static void testFieldAccess()
// empty leaf field name
try{
- fld->getAs("hello.");
+ fld->getSubFieldT("hello.");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
@@ -611,13 +611,13 @@ static void testFieldAccess()
// empty field name
try{
- fld->getAs("hello..world");
+ fld->getSubFieldT("hello..world");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
}
try{
- fld->getAs(".");
+ fld->getSubFieldT(".");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
@@ -625,7 +625,7 @@ static void testFieldAccess()
// whitespace
try{
- fld->getAs(" test");
+ fld->getSubFieldT(" test");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());
@@ -633,7 +633,7 @@ static void testFieldAccess()
// intermediate field not structure
try{
- fld->getAs("hello.world.invalid");
+ fld->getSubFieldT("hello.world.invalid");
testFail("missing required exception");
}catch(std::runtime_error& e){
testPass("caught expected exception: %s", e.what());