String -> std::string, toString methods removed

This commit is contained in:
Matej Sekoranja
2014-06-19 14:27:48 +02:00
parent 6ec207141f
commit c6eed12139
82 changed files with 1606 additions and 1651 deletions

View File

@@ -17,6 +17,7 @@ using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::cout;
using std::endl;
using std::string;
namespace epics { namespace pvData {
@@ -26,23 +27,23 @@ static FieldCreatePtr fieldCreate = getFieldCreate();
class CreateRequestImpl : public CreateRequest {
private:
void removeBlanks(String& str)
void removeBlanks(string& str)
{
while(true) {
String::size_type pos = str.find_first_of(' ');
if(pos==String::npos) return;
string::size_type pos = str.find_first_of(' ');
if(pos==string::npos) return;
str.erase(pos,1);
}
}
size_t findMatchingBrace(String& request, size_t index, int numOpen) {
size_t findMatchingBrace(string& request, size_t index, int numOpen) {
size_t openBrace = request.find('{', index+1);
size_t closeBrace = request.find('}', index+1);
if(openBrace == String::npos && closeBrace == std::string::npos){
if(openBrace == string::npos && closeBrace == string::npos){
message = request + " missing }";
return std::string::npos;
return string::npos;
}
if (openBrace != String::npos && openBrace!=0) {
if (openBrace != string::npos && openBrace!=0) {
if(openBrace<closeBrace) return findMatchingBrace(request,openBrace,numOpen+1);
if(numOpen==1) return closeBrace;
return findMatchingBrace(request,closeBrace,numOpen-1);
@@ -51,34 +52,34 @@ private:
return findMatchingBrace(request,closeBrace,numOpen-1);
}
size_t findMatchingBracket(String& request, size_t index) {
size_t findMatchingBracket(string& request, size_t index) {
for(size_t i=index+1; i< request.size(); ++i) {
if(request[i] == ']') {
if(i==index+1) {
message = request + " illegal []";
return String::npos;
return string::npos;
}
return i;
}
}
message = request + " missing ]";
return std::string::npos;
return string::npos;
}
size_t findEndField(String& request) {
size_t findEndField(string& request) {
size_t ind = 0;
size_t maxind = request.size() -1;
while(true) {
if(request[ind]==',') return ind;
if(request[ind]=='[') {
size_t closeBracket = findMatchingBracket(request,ind);
if(closeBracket==String::npos) return closeBracket;
if(closeBracket==string::npos) return closeBracket;
ind = closeBracket;
continue;
}
if(request[ind]=='{') {
size_t closeBrace = findMatchingBrace(request,ind,1);
if(closeBrace==String::npos) return closeBrace;
if(closeBrace==string::npos) return closeBrace;
if(ind>=request.size()) return request.size();
ind = closeBrace;
continue;
@@ -89,20 +90,20 @@ private:
return request.size();
}
std::vector<String> split(String const & commaSeparatedList) {
String::size_type numValues = 1;
String::size_type index=0;
std::vector<string> split(string const & commaSeparatedList) {
string::size_type numValues = 1;
string::size_type index=0;
while(true) {
String::size_type pos = commaSeparatedList.find(',',index);
if(pos==String::npos) break;
string::size_type pos = commaSeparatedList.find(',',index);
if(pos==string::npos) break;
numValues++;
index = pos +1;
}
std::vector<String> valueList(numValues,"");
std::vector<string> valueList(numValues,"");
index=0;
for(size_t i=0; i<numValues; i++) {
size_t pos = commaSeparatedList.find(',',index);
String value = commaSeparatedList.substr(index,pos-index);
string value = commaSeparatedList.substr(index,pos-index);
valueList[i] = value;
index = pos +1;
}
@@ -110,17 +111,17 @@ private:
}
StructureConstPtr createRequestOptions(
String request)
string request)
{
if(request.length()<=1) return StructureConstPtr();
std::vector<String> items = split(request);
std::vector<string> items = split(request);
size_t nitems = items.size();
StringArray fieldNames(nitems);
FieldConstPtrArray fields(nitems);
for(size_t j=0; j<nitems; j++) {
String item = items[j];
string item = items[j];
size_t equals = item.find('=');
if(equals==String::npos || equals==0) {
if(equals==string::npos || equals==0) {
message = item + " illegal option";
StructureConstPtr xxx;
return xxx;
@@ -133,16 +134,16 @@ private:
void initRequestOptions(
PVStructurePtr const & pvParent,
String request)
string request)
{
if(request.length()<=1) return;
std::vector<String> items = split(request);
std::vector<string> items = split(request);
size_t nitems = items.size();
for(size_t j=0; j<nitems; j++) {
String item = items[j];
string item = items[j];
size_t equals = item.find('=');
String name = item.substr(0,equals);
String value = item.substr(equals+1);
string name = item.substr(0,equals);
string value = item.substr(equals+1);
PVStringPtr pvValue = pvParent->getSubField<PVString>(name);
pvValue->put(value);
}
@@ -150,7 +151,7 @@ private:
StructureConstPtr createSubFieldRequest(
StructureConstPtr parent,
String request)
string request)
{
if(request.length()<=0) return parent;
size_t period = request.find('.');
@@ -158,9 +159,9 @@ private:
size_t openBrace = request.find('{');
// name only
if(period==String::npos
&& openBracket==String::npos
&& openBrace==String::npos)
if(period==string::npos
&& openBracket==string::npos
&& openBrace==string::npos)
{
StructureConstPtr subField = fieldCreate->createStructure();
parent = fieldCreate->appendField(parent,request,subField);
@@ -168,11 +169,11 @@ private:
}
// period is first
if(period!=String::npos
&& (openBracket==String::npos || period<openBracket)
&& (openBrace==String::npos || period<openBrace) )
if(period!=string::npos
&& (openBracket==string::npos || period<openBracket)
&& (openBrace==string::npos || period<openBrace) )
{
String fieldName = request.substr(0,period);
string fieldName = request.substr(0,period);
StructureConstPtr subField = fieldCreate->createStructure();
subField = createSubFieldRequest(subField,request.substr(period+1));
if(subField==NULL) return subField;
@@ -181,20 +182,20 @@ private:
}
// brace before [ or .
if(openBrace!=String::npos
&& (openBracket==String::npos || openBrace<openBracket) )
if(openBrace!=string::npos
&& (openBracket==string::npos || openBrace<openBracket) )
{
String fieldName = request.substr(0,openBrace);
string fieldName = request.substr(0,openBrace);
size_t closeBrace = findMatchingBrace(request,openBrace,1);
if(closeBrace==String::npos) return StructureConstPtr();
if(closeBrace==string::npos) return StructureConstPtr();
size_t nextChar = closeBrace+1;
if(nextChar>= request.size()) nextChar = String::npos;
if(nextChar!=String::npos) {
if(nextChar>= request.size()) nextChar = string::npos;
if(nextChar!=string::npos) {
message = request + " syntax error " + request[nextChar] + " after } illegal";
return StructureConstPtr();
}
StructureConstPtr subField = fieldCreate->createStructure();
String subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
string subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
subField = createFieldRequest(subField,subRequest);
if(subField==NULL) return subField;
parent = fieldCreate->appendField(parent,fieldName,subField);
@@ -202,15 +203,15 @@ private:
}
// [ is before brace or .
if(openBracket!=String::npos
&& (openBrace==String::npos || openBracket<openBrace) )
if(openBracket!=string::npos
&& (openBrace==string::npos || openBracket<openBrace) )
{
String fieldName = request.substr(0,openBracket);
string fieldName = request.substr(0,openBracket);
size_t closeBracket = findMatchingBracket(request,openBracket);
if(closeBracket==String::npos) return StructureConstPtr();
if(closeBracket==string::npos) return StructureConstPtr();
size_t nextChar = closeBracket+1;
if(nextChar>= request.size()) nextChar = String::npos;
if(nextChar==String::npos) {
if(nextChar>= request.size()) nextChar = string::npos;
if(nextChar==string::npos) {
StringArray fieldNames(1);
FieldConstPtrArray fields(1);
fieldNames[0] = "_options";
@@ -241,9 +242,9 @@ private:
}
if(request[nextChar]=='{') {
size_t closeBrace = findMatchingBrace(request,openBrace,1);
if(closeBrace==String::npos) return StructureConstPtr();
if(closeBrace==string::npos) return StructureConstPtr();
StructureConstPtr subField = fieldCreate->createStructure();
String subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
string subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
subField = createFieldRequest(subField,subRequest);
if(subField==NULL) return subField;
size_t numSub = subField->getNumberFields();
@@ -270,12 +271,12 @@ private:
StructureConstPtr createFieldRequest(
StructureConstPtr parent,
String request)
string request)
{
size_t length = request.length();
if(length<=0) return parent;
size_t end = findEndField(request);
if(end==String::npos) return StructureConstPtr();
if(end==string::npos) return StructureConstPtr();
StringArray fieldNames;
FieldConstPtrArray fields;
StructureConstPtr subField = fieldCreate->createStructure();
@@ -308,24 +309,24 @@ private:
void initSubFieldOptions(
PVStructurePtr const & pvParent,
String request)
string request)
{
if(request.length()<=0) return;
size_t period = request.find('.');
size_t openBracket = request.find('[');
size_t openBrace = request.find('{');
// name only
if(period==String::npos
&& openBracket==String::npos
&& openBrace==String::npos)
if(period==string::npos
&& openBracket==string::npos
&& openBrace==string::npos)
{
return;
}
// period is first
if(period!=String::npos
&& (openBracket==String::npos || period<openBracket)
&& (openBrace==String::npos || period<openBrace) )
if(period!=string::npos
&& (openBracket==string::npos || period<openBracket)
&& (openBrace==string::npos || period<openBrace) )
{
PVStructurePtr pvSubField = static_pointer_cast<PVStructure>(pvParent->getPVFields()[0]);
initSubFieldOptions(pvSubField,request.substr(period+1));
@@ -333,12 +334,12 @@ private:
}
// brace before [ or .
if(openBrace!=String::npos
&& (openBracket==String::npos || openBrace<openBracket) )
if(openBrace!=string::npos
&& (openBracket==string::npos || openBrace<openBracket) )
{
PVStructurePtr pvSubField = static_pointer_cast<PVStructure>(pvParent->getPVFields()[0]);
size_t closeBrace = findMatchingBrace(request,openBrace,1);
String subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
string subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
initFieldOptions(pvSubField,subRequest);
return;
}
@@ -347,8 +348,8 @@ private:
size_t closeBracket = findMatchingBracket(request,openBracket);
initRequestOptions(pvOptions,request.substr(openBracket+1,closeBracket-openBracket-1));
size_t nextChar = closeBracket+1;
if(nextChar>= request.size()) nextChar = String::npos;
if(nextChar==String::npos) return;
if(nextChar>= request.size()) nextChar = string::npos;
if(nextChar==string::npos) return;
if(request[nextChar]=='.') {
PVStructurePtr pvSubField = static_pointer_cast<PVStructure>(pvParent->getPVFields()[1]);
initSubFieldOptions(pvSubField,request.substr(nextChar+1));
@@ -357,7 +358,7 @@ private:
if(request[nextChar]!='{') throw std::logic_error("initSubFieldOptions request[nextChar]!='{'");
size_t closeBrace = findMatchingBrace(request,openBrace,1);
const PVFieldPtrArray &pvFields = pvParent->getPVFields();
String subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
string subRequest = request.substr(openBrace+1,closeBrace-openBrace-1);
for(size_t i=1; i<pvFields.size(); ++i) {
PVStructurePtr pvSubField = static_pointer_cast<PVStructure>(pvFields[i]);
size_t comma = subRequest.find(',');
@@ -368,9 +369,9 @@ private:
void initFieldOptions(
PVStructurePtr const & pvParent,
String request)
string request)
{
if(request.find('[')==String::npos) return;
if(request.find('[')==string::npos) return;
size_t num = pvParent->getStructure()->getNumberFields();
if(num==0) return;
if(num==1) {
@@ -381,11 +382,11 @@ private:
size_t start = 0;
for(size_t i=0; i<num; ++i) {
PVStructurePtr pvSub = static_pointer_cast<PVStructure>(pvParent->getPVFields()[i]);
String subRequest = request.substr(start, end - start);
string subRequest = request.substr(start, end - start);
initSubFieldOptions(pvSub,subRequest);
if(i==num-1) break;
start = end +1;
String xxx = request.substr(start);
string xxx = request.substr(start);
end += findEndField(xxx) + 1;
}
}
@@ -394,9 +395,9 @@ private:
public:
virtual PVStructure::shared_pointer createRequest(
String const & crequest)
string const & crequest)
{
String request = crequest;
string request = crequest;
StructureConstPtr topStructure = fieldCreate->createStructure();
if (!request.empty()) removeBlanks(request);
@@ -410,18 +411,18 @@ public:
size_t offsetField = request.find("field(");
size_t offsetPutField = request.find("putField(");
size_t offsetGetField = request.find("getField(");
if(offsetRecord==String::npos
&& offsetField==String::npos
&& offsetPutField==String::npos
&& offsetGetField==String::npos)
if(offsetRecord==string::npos
&& offsetField==string::npos
&& offsetPutField==string::npos
&& offsetGetField==string::npos)
{
request = "field(" + crequest + ")";
offsetField = request.find("field(");
}
if (offsetRecord != String::npos) {
if (offsetRecord != string::npos) {
size_t openBracket = request.find('[', offsetRecord);
size_t closeBracket = request.find(']', openBracket);
if(closeBracket == String::npos) {
if(closeBracket == string::npos) {
message = request.substr(offsetRecord)
+ " record[ does not have matching ]";
return PVStructurePtr();
@@ -434,10 +435,10 @@ public:
}
topStructure = fieldCreate->appendField(topStructure,"record",structure);
}
if (offsetField != String::npos) {
if (offsetField != string::npos) {
size_t openBrace = request.find('(', offsetField);
size_t closeBrace = request.find(')', openBrace);
if(closeBrace == String::npos) {
if(closeBrace == string::npos) {
message = request.substr(offsetField)
+ " field( does not have matching )";
return PVStructurePtr();
@@ -450,10 +451,10 @@ public:
}
topStructure = fieldCreate->appendField(topStructure,"field",structure);
}
if (offsetPutField != String::npos) {
if (offsetPutField != string::npos) {
size_t openBrace = request.find('(', offsetPutField);
size_t closeBrace = request.find(')', openBrace);
if(closeBrace == String::npos) {
if(closeBrace == string::npos) {
message = request.substr(offsetField)
+ " putField( does not have matching )";
return PVStructurePtr();
@@ -466,10 +467,10 @@ public:
}
topStructure = fieldCreate->appendField(topStructure,"putField",structure);
}
if (offsetGetField != String::npos) {
if (offsetGetField != string::npos) {
size_t openBrace = request.find('(', offsetGetField);
size_t closeBrace = request.find(')', openBrace);
if(closeBrace == String::npos) {
if(closeBrace == string::npos) {
message = request.substr(offsetField)
+ " getField( does not have matching )";
return PVStructurePtr();
@@ -483,14 +484,14 @@ public:
topStructure = fieldCreate->appendField(topStructure,"getField",structure);
}
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(topStructure);
if (offsetRecord != String::npos) {
if (offsetRecord != string::npos) {
size_t openBracket = request.find('[', offsetRecord);
size_t closeBracket = request.find(']', openBracket);
initRequestOptions(
pvStructure->getSubField<PVStructure>("record"),
request.substr(openBracket+1,closeBracket-openBracket-1));
}
if (offsetField != String::npos) {
if (offsetField != string::npos) {
size_t openParam = request.find('(', offsetField);
size_t closeParam = request.find(')', openParam);
PVStructurePtr pvSub = pvStructure->getSubField<PVStructure>("field");
@@ -499,7 +500,7 @@ public:
}
if(pvSub!=NULL) initFieldOptions(pvSub,request.substr(openParam+1,closeParam-openParam-1));
}
if (offsetPutField != String::npos) {
if (offsetPutField != string::npos) {
size_t openParam = request.find('(', offsetPutField);
size_t closeParam = request.find(')', openParam);
PVStructurePtr pvSub = pvStructure->getSubField<PVStructure>("putField");
@@ -508,7 +509,7 @@ public:
}
if(pvSub!=NULL) initFieldOptions(pvSub,request.substr(openParam+1,closeParam-openParam-1));
}
if (offsetGetField != String::npos) {
if (offsetGetField != string::npos) {
size_t openParam = request.find('(', offsetGetField);
size_t closeParam = request.find(')', openParam);
PVStructurePtr pvSub = pvStructure->getSubField<PVStructure>("getField");

View File

@@ -38,15 +38,15 @@ class epicsShareClass CreateRequest {
* If a NULL PVStructure is returned then getMessage will return
* the reason.
*/
virtual PVStructure::shared_pointer createRequest(String const & request) = 0;
virtual PVStructure::shared_pointer createRequest(std::string const & request) = 0;
/**
* Get the error message of createRequest returns NULL
* return the error message
*/
String getMessage() {return message;}
std::string getMessage() {return message;}
protected:
CreateRequest() {}
String message;
std::string message;
};

View File

@@ -20,16 +20,15 @@
#include <pv/pvCopy.h>
#include <pv/convert.h>
namespace epics { namespace pvData {
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::tr1::dynamic_pointer_cast;
using std::string;
using std::size_t;
using std::cout;
using std::endl;
namespace epics { namespace pvData {
static PVCopyPtr NULLPVCopy;
static FieldConstPtr NULLField;
static StructureConstPtr NULLStructure;
@@ -63,7 +62,7 @@ struct CopyStructureNode : public CopyNode {
PVCopyPtr PVCopy::create(
PVStructurePtr const &pvMaster,
PVStructurePtr const &pvRequest,
String const & structureName)
string const & structureName)
{
PVStructurePtr pvStructure(pvRequest);
if(structureName.size()>0) {
@@ -171,12 +170,12 @@ size_t PVCopy::getCopyOffset(PVFieldPtr const &masterPVField)
size_t off = masterPVField->getFieldOffset();
size_t offdiff = off -offsetParent;
if(offdiff<masterNode->nfields) return headNode->structureOffset + offdiff;
return String::npos;
return string::npos;
}
CopyStructureNodePtr node = static_pointer_cast<CopyStructureNode>(headNode);
CopyMasterNodePtr masterNode = getCopyOffset(node,masterPVField);
if(masterNode.get()!=NULL) return masterNode->structureOffset;
return String::npos;
return string::npos;
}
size_t PVCopy::getCopyOffset(
@@ -186,12 +185,12 @@ size_t PVCopy::getCopyOffset(
CopyMasterNodePtr masterNode;
if(!headNode->isStructure) {
masterNode = static_pointer_cast<CopyMasterNode>(headNode);
if(masterNode->masterPVField.get()!=masterPVStructure.get()) return String::npos;
if(masterNode->masterPVField.get()!=masterPVStructure.get()) return string::npos;
} else {
CopyStructureNodePtr node = static_pointer_cast<CopyStructureNode>(headNode);
masterNode = getCopyOffset(node,masterPVField);
}
if(masterNode.get()==NULL) return String::npos;
if(masterNode.get()==NULL) return string::npos;
size_t diff = masterPVField->getFieldOffset()
- masterPVStructure->getFieldOffset();
return masterNode->structureOffset + diff;
@@ -284,14 +283,14 @@ void PVCopy::updateMaster(
}
}
epics::pvData::String PVCopy::dump()
string PVCopy::dump()
{
String builder;
string builder;
dump(&builder,headNode,0);
return builder;
}
void PVCopy::dump(String *builder,CopyNodePtr const &node,int indentLevel)
void PVCopy::dump(string *builder,CopyNodePtr const &node,int indentLevel)
{
getConvert()->newLine(builder,indentLevel);
std::stringstream ss;
@@ -302,12 +301,17 @@ void PVCopy::dump(String *builder,CopyNodePtr const &node,int indentLevel)
PVStructurePtr options = node->options;
if(options.get()!=NULL) {
getConvert()->newLine(builder,indentLevel +1);
options->toString(builder);
// TODO !!! ugly
std::ostringstream oss;
oss << *options;
*builder += oss.str();
getConvert()->newLine(builder,indentLevel);
}
if(!node->isStructure) {
CopyMasterNodePtr masterNode = static_pointer_cast<CopyMasterNode>(node);
String name = masterNode->masterPVField->getFullName();
string name = masterNode->masterPVField->getFullName();
*builder += " masterField " + name;
return;
}
@@ -331,7 +335,7 @@ bool PVCopy::init(epics::pvData::PVStructurePtr const &pvRequest)
PVStructurePtr pvMasterStructure = pvMaster;
size_t len = pvRequest->getPVFields().size();
bool entireMaster = false;
if(len==String::npos) entireMaster = true;
if(len==string::npos) entireMaster = true;
if(len==0) entireMaster = true;
PVStructurePtr pvOptions;
if(len==1 && pvRequest->getSubField("_options")!=NULL) {
@@ -358,12 +362,12 @@ bool PVCopy::init(epics::pvData::PVStructurePtr const &pvRequest)
return true;
}
epics::pvData::String PVCopy::dump(
String const &value,
string PVCopy::dump(
string const &value,
CopyNodePtr const &node,
int indentLevel)
{
throw std::logic_error(String("Not Implemented"));
throw std::logic_error(string("Not Implemented"));
}
@@ -381,7 +385,7 @@ StructureConstPtr PVCopy::createStructure(
FieldConstPtrArray fields; fields.reserve(length);
StringArray fieldNames; fields.reserve(length);
for(size_t i=0; i<length; ++i) {
String const &fieldName = fromRequestFieldNames[i];
string const &fieldName = fromRequestFieldNames[i];
PVFieldPtr pvMasterField = pvMaster->getSubField(fieldName);
if(pvMasterField==NULL) continue;
FieldConstPtr field = pvMasterField->getField();
@@ -425,7 +429,7 @@ CopyNodePtr PVCopy::createStructureNodes(
nodes->reserve(number);
for(size_t i=0; i<number; i++) {
PVFieldPtr copyPVField = copyPVFields[i];
String fieldName = copyPVField->getFieldName();
string fieldName = copyPVField->getFieldName();
PVStructurePtr requestPVStructure = static_pointer_cast<PVStructure>(
pvFromRequest->getSubField(fieldName));
@@ -531,7 +535,7 @@ void PVCopy::updateStructureNodeFromBitSet(
size_t offset = structureNode->structureOffset;
if(!doAll) {
size_t nextSet = bitSet->nextSetBit(offset);
if(nextSet==String::npos) return;
if(nextSet==string::npos) return;
}
if(offset>=pvCopy->getNextFieldOffset()) return;
if(!doAll) doAll = bitSet->get(offset);
@@ -567,7 +571,7 @@ void PVCopy::updateSubFieldFromBitSet(
if(!doAll) {
size_t offset = pvCopy->getFieldOffset();
size_t nextSet = bitSet->nextSetBit(offset);
if(nextSet==String::npos) return;
if(nextSet==string::npos) return;
if(nextSet>=pvCopy->getNextFieldOffset()) return;
}
ConvertPtr convert = getConvert();
@@ -577,7 +581,7 @@ void PVCopy::updateSubFieldFromBitSet(
PVFieldPtrArray const & pvCopyFields = pvCopyStructure->getPVFields();
if(pvMasterField->getField()->getType() !=epics::pvData::structure)
{
throw std::logic_error(String("Logic error"));
throw std::logic_error(string("Logic error"));
}
PVStructurePtr pvMasterStructure =
static_pointer_cast<PVStructure>(pvMasterField);

View File

@@ -71,7 +71,7 @@ public:
static PVCopyPtr create(
PVStructurePtr const &pvMaster,
PVStructurePtr const &pvRequest,
String const & structureName);
std::string const & structureName);
virtual ~PVCopy(){}
virtual void destroy();
/**
@@ -99,13 +99,13 @@ public:
PVStructurePtr createPVStructure();
/**
* Given a field in pvMaster. return the offset in copy for the same field.
* A value of String::npos means that the copy does not have this field.
* A value of std::string::npos means that the copy does not have this field.
* @param masterPVField The field in master.
*/
std::size_t getCopyOffset(PVFieldPtr const &masterPVField);
/**
* Given a field in pvMaster. return the offset in copy for the same field.
* A value of String::npos means that the copy does not have this field.
* A value of std::string::npos means that the copy does not have this field.
* @param masterPVStructure A structure in master that has masterPVField.
* @param masterPVField The field in master.
*/
@@ -166,10 +166,10 @@ public:
/**
* For debugging.
*/
String dump();
std::string dump();
private:
void dump(
String *builder,
std::string *builder,
CopyNodePtr const &node,
int indentLevel);
PVCopyPtr getPtrSelf()
@@ -185,8 +185,8 @@ private:
PVCopy(PVStructurePtr const &pvMaster);
friend class PVCopyMonitor;
bool init(PVStructurePtr const &pvRequest);
String dump(
String const &value,
std::string dump(
std::string const &value,
CopyNodePtr const &node,
int indentLevel);
StructureConstPtr createStructure(

View File

@@ -7,13 +7,15 @@
* @author mes
*/
#define epicsExportSharedSymbols
#include <pv/convert.h>
#include <algorithm>
#include <iterator>
#include <sstream>
#define epicsExportSharedSymbols
#include <pv/convert.h>
using std::string;
namespace epics { namespace pvData {
// Introspection object comparision
@@ -202,7 +204,7 @@ bool compareField(const PVScalarArray* left, const PVScalarArray* right)
OP(pvLong, int64);
OP(pvFloat, float);
OP(pvDouble, double);
OP(pvString, String);
OP(pvString, string);
#undef OP
}
throw std::logic_error("PVScalarArray with invalid element type!");

View File

@@ -22,31 +22,32 @@
using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
static std::vector<String> split(String commaSeparatedList) {
String::size_type numValues = 1;
String::size_type index=0;
static std::vector<string> split(string commaSeparatedList) {
string::size_type numValues = 1;
string::size_type index=0;
while(true) {
String::size_type pos = commaSeparatedList.find(',',index);
if(pos==String::npos) break;
string::size_type pos = commaSeparatedList.find(',',index);
if(pos==string::npos) break;
numValues++;
index = pos +1;
}
std::vector<String> valueList(numValues,"");
std::vector<string> valueList(numValues,"");
index=0;
for(size_t i=0; i<numValues; i++) {
size_t pos = commaSeparatedList.find(',',index);
String value = commaSeparatedList.substr(index,pos);
string value = commaSeparatedList.substr(index,pos);
valueList[i] = value;
index = pos +1;
}
return valueList;
}
void Convert::getString(StringBuilder buf,PVField const *pvField,int /*indentLevel*/)
void Convert::getString(string *buf,PVField const *pvField,int /*indentLevel*/)
{
// TODO indextLevel ignored
std::ostringstream strm;
@@ -88,9 +89,9 @@ size_t Convert::fromString(PVStructurePtr const &pvStructure, StringArray const
}
else {
// union, structureArray, unionArray not supported
String message("Convert::fromString unsupported fieldType ");
TypeFunc::toString(&message,type);
throw std::logic_error(message);
std::ostringstream oss;
oss << "Convert::fromString unsupported fieldType " << type;
throw std::logic_error(oss.str());
}
}
}
@@ -98,13 +99,13 @@ size_t Convert::fromString(PVStructurePtr const &pvStructure, StringArray const
return processed;
}
size_t Convert::fromString(PVScalarArrayPtr const &pv, String from)
size_t Convert::fromString(PVScalarArrayPtr const &pv, string from)
{
if(from[0]=='[' && from[from.length()]==']') {
size_t offset = from.rfind(']');
from = from.substr(1, offset);
}
std::vector<String> valueList(split(from));
std::vector<string> valueList(split(from));
size_t length = valueList.size();
size_t num = fromStringArray(pv,0,length,valueList,0);
if(num<length) length = num;
@@ -129,7 +130,7 @@ size_t Convert::fromStringArray(PVScalarArrayPtr const &pv,
data.begin());
PVStringArray::const_svector temp(freeze(data));
pv->putFrom<String>(temp);
pv->putFrom<string>(temp);
return length;
} else {
@@ -143,7 +144,7 @@ size_t Convert::toStringArray(PVScalarArrayPtr const & pv,
StringArray &to, size_t toOffset)
{
PVStringArray::const_svector data;
pv->getAs<String>(data);
pv->getAs<string>(data);
data.slice(offset, length);
if(toOffset+data.size() > to.size())
to.resize(toOffset+data.size());
@@ -192,7 +193,7 @@ bool Convert::isCopyCompatible(FieldConstPtr const &from, FieldConstPtr const &t
return isCopyUnionArrayCompatible(xxx,yyy);
}
}
String message("Convert::isCopyCompatible should never get here");
string message("Convert::isCopyCompatible should never get here");
throw std::logic_error(message);
}
@@ -259,7 +260,7 @@ void Convert::copyScalar(PVScalarPtr const & from, PVScalarPtr const & to)
{
if(to->isImmutable()) {
if(from==to) return;
String message("Convert.copyScalar destination is immutable");
string message("Convert.copyScalar destination is immutable");
throw std::invalid_argument(message);
}
to->assign(*from.get());
@@ -349,13 +350,13 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const &
PVFieldPtrArray const & toDatas = to->getPVFields();
if(from->getStructure()->getNumberFields()
!= to->getStructure()->getNumberFields()) {
String message("Convert.copyStructure Illegal copyStructure");
string message("Convert.copyStructure Illegal copyStructure");
throw std::invalid_argument(message);
}
size_t numberFields = from->getStructure()->getNumberFields();
if(numberFields>=2) {
String name0 = fromDatas[0]->getFieldName();
String name1 = fromDatas[1]->getFieldName();
string name0 = fromDatas[0]->getFieldName();
string name1 = fromDatas[1]->getFieldName();
// look for enumerated structure and copy choices first
if(name0.compare("index")==0 && name1.compare("choices")==0) {
FieldConstPtr fieldIndex = fromDatas[0]->getField();
@@ -383,7 +384,7 @@ void Convert::copyStructure(PVStructurePtr const & from, PVStructurePtr const &
Type fromType = fromData->getField()->getType();
Type toType = toData->getField()->getType();
if(fromType!=toType) {
String message("Convert.copyStructure Illegal copyStructure");
string message("Convert.copyStructure Illegal copyStructure");
throw std::invalid_argument(message);
}
if(toData->isImmutable()) {
@@ -513,10 +514,10 @@ void Convert::copyUnionArray(
to->replace(from->view());
}
void Convert::newLine(StringBuilder buffer, int indentLevel)
void Convert::newLine(string *buffer, int indentLevel)
{
*buffer += "\n";
*buffer += String(indentLevel*4, ' ');
*buffer += string(indentLevel*4, ' ');
}
ConvertPtr Convert::getConvert()

View File

@@ -27,17 +27,12 @@
using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
static DebugLevel debugLevel = lowDebug;
static void newLine(StringBuilder buffer, int indentLevel)
{
*buffer += "\n";
for(int i=0; i<indentLevel; i++) *buffer += " ";
}
Field::Field(Type type)
: m_fieldType(type)
{
@@ -47,32 +42,11 @@ Field::~Field() {
}
void Field::toString(StringBuilder /*buffer*/,int /*indentLevel*/) const{
}
// TODO move all these to a header file
struct ScalarHashFunction {
size_t operator() (const Scalar& scalar) const { return scalar.getScalarType(); }
std::ostream& operator<<(std::ostream& o, const Field& f)
{
return f.dump(o);
};
struct ScalarArrayHashFunction {
size_t operator() (const ScalarArray& scalarArray) const { return 0x10 | scalarArray.getElementType(); }
};
struct StructureHashFunction {
size_t operator() (const Structure& /*structure*/) const { return 0; }
// TODO hash
// final int PRIME = 31;
// return PRIME * Arrays.hashCode(fieldNames) + Arrays.hashCode(fields);
};
struct StructureArrayHashFunction {
size_t operator() (const StructureArray& structureArray) const { StructureHashFunction shf; return (0x10 | shf(*(structureArray.getStructure()))); }
};
Scalar::Scalar(ScalarType scalarType)
: Field(scalar),scalarType(scalarType)
{
@@ -82,14 +56,14 @@ Scalar::Scalar(ScalarType scalarType)
Scalar::~Scalar(){}
void Scalar::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID();
std::ostream& Scalar::dump(std::ostream& o) const
{
return o << format::indent() << getID();
}
String Scalar::getID() const
string Scalar::getID() const
{
static const String idScalarLUT[] = {
static const string idScalarLUT[] = {
"boolean", // pvBoolean
"byte", // pvByte
"short", // pvShort
@@ -136,15 +110,15 @@ void Scalar::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*contro
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
static String emptyString;
static string emptyStringtring;
static void serializeStructureField(const Structure* structure, ByteBuffer* buffer, SerializableControl* control)
{
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
String id = structure->getID();
string id = structure->getID();
if (id == Structure::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(emptyString, buffer, control);
SerializeHelper::serializeString(emptyStringtring, buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
@@ -161,7 +135,7 @@ static void serializeStructureField(const Structure* structure, ByteBuffer* buff
static StructureConstPtr deserializeStructureField(const FieldCreate* fieldCreate, ByteBuffer* buffer, DeserializableControl* control)
{
String id = SerializeHelper::deserializeString(buffer, control);
string id = SerializeHelper::deserializeString(buffer, control);
const std::size_t size = SerializeHelper::readSize(buffer, control);
FieldConstPtrArray fields; fields.reserve(size);
StringArray fieldNames; fieldNames.reserve(size);
@@ -181,9 +155,9 @@ static void serializeUnionField(const Union* punion, ByteBuffer* buffer, Seriali
{
// to optimize default (non-empty) IDs optimization
// empty IDs are not allowed
String id = punion->getID();
string id = punion->getID();
if (id == Union::DEFAULT_ID) // TODO slow comparison
SerializeHelper::serializeString(emptyString, buffer, control);
SerializeHelper::serializeString(emptyStringtring, buffer, control);
else
SerializeHelper::serializeString(id, buffer, control);
@@ -200,7 +174,7 @@ static void serializeUnionField(const Union* punion, ByteBuffer* buffer, Seriali
static UnionConstPtr deserializeUnionField(const FieldCreate* fieldCreate, ByteBuffer* buffer, DeserializableControl* control)
{
String id = SerializeHelper::deserializeString(buffer, control);
string id = SerializeHelper::deserializeString(buffer, control);
const std::size_t size = SerializeHelper::readSize(buffer, control);
FieldConstPtrArray fields; fields.reserve(size);
StringArray fieldNames; fieldNames.reserve(size);
@@ -251,9 +225,9 @@ int8 ScalarArray::getTypeCodeLUT() const
return typeCodeLUT[elementType];
}
const String ScalarArray::getIDScalarArrayLUT() const
const string ScalarArray::getIDScalarArrayLUT() const
{
static const String idScalarArrayLUT[] = {
static const string idScalarArrayLUT[] = {
"boolean[]", // pvBoolean
"byte[]", // pvByte
"short[]", // pvShort
@@ -270,13 +244,14 @@ const String ScalarArray::getIDScalarArrayLUT() const
return idScalarArrayLUT[elementType];
}
String ScalarArray::getID() const
string ScalarArray::getID() const
{
return getIDScalarArrayLUT();
}
void ScalarArray::toString(StringBuilder buffer,int /*indentLevel*/) const{
*buffer += getID();
std::ostream& ScalarArray::dump(std::ostream& o) const
{
return o << format::indent() << getID();
}
void ScalarArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
@@ -297,15 +272,19 @@ StructureArray::~StructureArray() {
if(debugLevel==highDebug) printf("~StructureArray\n");
}
String StructureArray::getID() const
string StructureArray::getID() const
{
return pstructure->getID() + "[]";
}
void StructureArray::toString(StringBuilder buffer,int indentLevel) const {
*buffer += getID();
newLine(buffer,indentLevel + 1);
pstructure->toString(buffer,indentLevel + 1);
std::ostream& StructureArray::dump(std::ostream& o) const
{
o << format::indent() << getID() << std::endl;
{
format::indent_scope s(o);
o << *pstructure;
}
return o;
}
void StructureArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
@@ -327,15 +306,19 @@ UnionArray::~UnionArray() {
if(debugLevel==highDebug) printf("~UnionArray\n");
}
String UnionArray::getID() const
string UnionArray::getID() const
{
return punion->getID() + "[]";
}
void UnionArray::toString(StringBuilder buffer,int indentLevel) const {
*buffer += getID();
newLine(buffer,indentLevel + 1);
punion->toString(buffer,indentLevel + 1);
std::ostream& UnionArray::dump(std::ostream& o) const
{
o << format::indent() << getID() << std::endl;
{
format::indent_scope s(o);
o << *punion;
}
return o;
}
void UnionArray::serialize(ByteBuffer *buffer, SerializableControl *control) const {
@@ -356,12 +339,12 @@ void UnionArray::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*co
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
String Structure::DEFAULT_ID = "structure";
string Structure::DEFAULT_ID = "structure";
Structure::Structure (
StringArray const & fieldNames,
FieldConstPtrArray const & infields,
String const & inid)
string const & inid)
: Field(structure),
fieldNames(fieldNames),
fields(infields),
@@ -375,7 +358,7 @@ Structure::Structure (
}
size_t number = fields.size();
for(size_t i=0; i<number; i++) {
const String& name = fieldNames[i];
const string& name = fieldNames[i];
if(name.empty()) {
throw std::invalid_argument("fieldNames has a zero length string");
}
@@ -383,10 +366,10 @@ Structure::Structure (
throw std::invalid_argument("Can't construct Structure with NULL Field");
// look for duplicates
for(size_t j=i+1; j<number; j++) {
String otherName = fieldNames[j];
string otherName = fieldNames[j];
int result = name.compare(otherName);
if(result==0) {
String message("duplicate fieldName ");
string message("duplicate fieldName ");
message += name;
throw std::invalid_argument(message);
}
@@ -397,12 +380,12 @@ Structure::Structure (
Structure::~Structure() { }
String Structure::getID() const
string Structure::getID() const
{
return id;
}
FieldConstPtr Structure::getField(String const & fieldName) const {
FieldConstPtr Structure::getField(string const & fieldName) const {
size_t numberFields = fields.size();
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
@@ -412,7 +395,7 @@ FieldConstPtr Structure::getField(String const & fieldName) const {
return FieldConstPtr();
}
size_t Structure::getFieldIndex(String const &fieldName) const {
size_t Structure::getFieldIndex(string const &fieldName) const {
size_t numberFields = fields.size();
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
@@ -422,17 +405,22 @@ size_t Structure::getFieldIndex(String const &fieldName) const {
return -1;
}
void Structure::toString(StringBuilder buffer,int indentLevel) const{
*buffer += getID();
toStringCommon(buffer,indentLevel+1);
std::ostream& Structure::dump(std::ostream& o) const
{
o << format::indent() << getID() << std::endl;
{
format::indent_scope s(o);
dumpFields(o);
}
return o;
}
void Structure::toStringCommon(StringBuilder buffer,int indentLevel) const{
newLine(buffer,indentLevel);
void Structure::dumpFields(std::ostream& o) const
{
size_t numberFields = fields.size();
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
*buffer += pfield->getID() + " " + fieldNames[i];
o << format::indent() << pfield->getID() << ' ' << fieldNames[i] << std::endl;
switch(pfield->getType()) {
case scalar:
case scalarArray:
@@ -441,26 +429,31 @@ void Structure::toStringCommon(StringBuilder buffer,int indentLevel) const{
{
Field const *xxx = pfield.get();
Structure const *pstruct = static_cast<Structure const*>(xxx);
pstruct->toStringCommon(buffer,indentLevel + 1);
format::indent_scope s(o);
pstruct->dumpFields(o);
break;
}
case structureArray:
newLine(buffer,indentLevel +1);
pfield->toString(buffer,indentLevel +1);
{
format::indent_scope s(o);
o << *pfield;
break;
}
case union_:
{
Field const *xxx = pfield.get();
Union const *pstruct = static_cast<Union const*>(xxx);
pstruct->toStringCommon(buffer,indentLevel + 1);
Union const *punion = static_cast<Union const*>(xxx);
format::indent_scope s(o);
punion->dumpFields(o);
break;
}
case unionArray:
newLine(buffer,indentLevel +1);
pfield->toString(buffer,indentLevel +1);
{
format::indent_scope s(o);
o << *pfield;
break;
}
}
if(i<numberFields-1) newLine(buffer,indentLevel);
}
}
@@ -474,10 +467,10 @@ void Structure::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*con
throw std::runtime_error("not valid operation, use FieldCreate::deserialize instead");
}
String Union::DEFAULT_ID = "union";
string Union::DEFAULT_ID = "union";
#define UNION_ANY_ID "any"
String Union::ANY_ID = UNION_ANY_ID;
string Union::ANY_ID = UNION_ANY_ID;
Union::Union ()
: Field(union_),
@@ -492,7 +485,7 @@ Union::Union ()
Union::Union (
StringArray const & fieldNames,
FieldConstPtrArray const & infields,
String const & inid)
string const & inid)
: Field(union_),
fieldNames(fieldNames),
fields(infields),
@@ -510,7 +503,7 @@ Union::Union (
size_t number = fields.size();
for(size_t i=0; i<number; i++) {
const String& name = fieldNames[i];
const string& name = fieldNames[i];
if(name.empty()) {
throw std::invalid_argument("fieldNames has a zero length string");
}
@@ -518,10 +511,10 @@ Union::Union (
throw std::invalid_argument("Can't construct Union with NULL Field");
// look for duplicates
for(size_t j=i+1; j<number; j++) {
String otherName = fieldNames[j];
string otherName = fieldNames[j];
int result = name.compare(otherName);
if(result==0) {
String message("duplicate fieldName ");
string message("duplicate fieldName ");
message += name;
throw std::invalid_argument(message);
}
@@ -532,12 +525,12 @@ Union::Union (
Union::~Union() { }
String Union::getID() const
string Union::getID() const
{
return id;
}
FieldConstPtr Union::getField(String const & fieldName) const {
FieldConstPtr Union::getField(string const & fieldName) const {
size_t numberFields = fields.size();
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
@@ -547,7 +540,7 @@ FieldConstPtr Union::getField(String const & fieldName) const {
return FieldConstPtr();
}
size_t Union::getFieldIndex(String const &fieldName) const {
size_t Union::getFieldIndex(string const &fieldName) const {
size_t numberFields = fields.size();
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
@@ -557,19 +550,22 @@ size_t Union::getFieldIndex(String const &fieldName) const {
return -1;
}
void Union::toString(StringBuilder buffer,int indentLevel) const{
*buffer += getID();
toStringCommon(buffer,indentLevel+1);
std::ostream& Union::dump(std::ostream& o) const
{
o << getID() << std::endl;
{
format::indent_scope s(o);
dumpFields(o);
}
return o;
}
void Union::toStringCommon(StringBuilder buffer,int indentLevel) const{
newLine(buffer,indentLevel);
void Union::dumpFields(std::ostream& o) const
{
size_t numberFields = fields.size();
if (numberFields == 0) // variant support
return;
for(size_t i=0; i<numberFields; i++) {
FieldConstPtr pfield = fields[i];
*buffer += pfield->getID() + " " + fieldNames[i];
o << format::indent() << pfield->getID() << ' ' << fieldNames[i] << std::endl;
switch(pfield->getType()) {
case scalar:
case scalarArray:
@@ -578,26 +574,31 @@ void Union::toStringCommon(StringBuilder buffer,int indentLevel) const{
{
Field const *xxx = pfield.get();
Structure const *pstruct = static_cast<Structure const*>(xxx);
pstruct->toStringCommon(buffer,indentLevel + 1);
format::indent_scope s(o);
pstruct->dumpFields(o);
break;
}
case structureArray:
newLine(buffer,indentLevel +1);
pfield->toString(buffer,indentLevel +1);
{
format::indent_scope s(o);
o << *pfield;
break;
}
case union_:
{
Field const *xxx = pfield.get();
Union const *pstruct = static_cast<Union const*>(xxx);
pstruct->toStringCommon(buffer,indentLevel + 1);
Union const *punion = static_cast<Union const*>(xxx);
format::indent_scope s(o);
punion->dumpFields(o);
break;
}
case unionArray:
newLine(buffer,indentLevel +1);
pfield->toString(buffer,indentLevel +1);
{
format::indent_scope s(o);
o << *pfield;
break;
}
}
if(i<numberFields-1) newLine(buffer,indentLevel);
}
}
@@ -623,7 +624,7 @@ void Union::deserialize(ByteBuffer* /*buffer*/, DeserializableControl* /*control
FieldBuilder::FieldBuilder() : fieldCreate(getFieldCreate()), idSet(false) {}
FieldBuilder::FieldBuilder(FieldBuilderPtr const & _parentBuilder,
std::string const & _nestedName,
string const & _nestedName,
Type _nestedClassToBuild, bool _nestedArray) :
fieldCreate(getFieldCreate()),
idSet(false),
@@ -641,32 +642,32 @@ void FieldBuilder::reset()
fields.clear();
}
FieldBuilderPtr FieldBuilder::setId(std::string const & id)
FieldBuilderPtr FieldBuilder::setId(string const & id)
{
this->id = id;
idSet = true;
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::add(std::string const & name, ScalarType scalarType)
FieldBuilderPtr FieldBuilder::add(string const & name, ScalarType scalarType)
{
fields.push_back(fieldCreate->createScalar(scalarType)); fieldNames.push_back(name);
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::add(std::string const & name, FieldConstPtr const & field)
FieldBuilderPtr FieldBuilder::add(string const & name, FieldConstPtr const & field)
{
fields.push_back(field); fieldNames.push_back(name);
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::addArray(std::string const & name, ScalarType scalarType)
FieldBuilderPtr FieldBuilder::addArray(string const & name, ScalarType scalarType)
{
fields.push_back(fieldCreate->createScalarArray(scalarType)); fieldNames.push_back(name);
return shared_from_this();
}
FieldBuilderPtr FieldBuilder::addArray(std::string const & name, FieldConstPtr const & element)
FieldBuilderPtr FieldBuilder::addArray(string const & name, FieldConstPtr const & element)
{
switch (element->getType())
{
@@ -730,24 +731,24 @@ UnionConstPtr FieldBuilder::createUnion()
return field;
}
FieldBuilderPtr FieldBuilder::addNestedStructure(std::string const & name)
FieldBuilderPtr FieldBuilder::addNestedStructure(string const & name)
{
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, false));
}
FieldBuilderPtr FieldBuilder::addNestedUnion(std::string const & name)
FieldBuilderPtr FieldBuilder::addNestedUnion(string const & name)
{
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, false));
}
FieldBuilderPtr FieldBuilder::addNestedStructureArray(std::string const & name)
FieldBuilderPtr FieldBuilder::addNestedStructureArray(string const & name)
{
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, structure, true));
}
FieldBuilderPtr FieldBuilder::addNestedUnionArray(std::string const & name)
FieldBuilderPtr FieldBuilder::addNestedUnionArray(string const & name)
{
return FieldBuilderPtr(new FieldBuilder(shared_from_this(), name, union_, true));
}
@@ -804,7 +805,7 @@ StructureConstPtr FieldCreate::createStructure (
}
StructureConstPtr FieldCreate::createStructure (
String const & id,
string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const
{
@@ -830,7 +831,7 @@ UnionConstPtr FieldCreate::createUnion (
}
UnionConstPtr FieldCreate::createUnion (
String const & id,
string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const
{
@@ -859,7 +860,7 @@ UnionArrayConstPtr FieldCreate::createVariantUnionArray () const
StructureConstPtr FieldCreate::appendField(
StructureConstPtr const & structure,
String const & fieldName,
string const & fieldName,
FieldConstPtr const & field) const
{
StringArray oldNames = structure->getFieldNames();

View File

@@ -27,6 +27,7 @@
using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
using std::min;
namespace epics { namespace pvData {
@@ -43,7 +44,7 @@ template<> const ScalarType PVUInt::typeCode = pvUInt;
template<> const ScalarType PVULong::typeCode = pvULong;
template<> const ScalarType PVFloat::typeCode = pvFloat;
template<> const ScalarType PVDouble::typeCode = pvDouble;
template<> const ScalarType PVScalarValue<String>::typeCode = pvString;
template<> const ScalarType PVScalarValue<string>::typeCode = pvString;
template<> const ScalarType PVBooleanArray::typeCode = pvBoolean;
template<> const ScalarType PVByteArray::typeCode = pvByte;
@@ -83,7 +84,7 @@ template<typename T>
BasePVScalar<T>::BasePVScalar(ScalarConstPtr const & scalar)
: PVScalarValue<T>(scalar),value(0)
{}
//Note: '0' is a suitable default for all POD types (not String)
//Note: '0' is a suitable default for all POD types (not string)
template<typename T>
BasePVScalar<T>::~BasePVScalar() {}
@@ -128,14 +129,14 @@ typedef BasePVScalar<double> BasePVDouble;
// BasePVString is special case, since it implements SerializableArray
class BasePVString : public PVString {
public:
typedef String value_type;
typedef String* pointer;
typedef const String* const_pointer;
typedef string value_type;
typedef string* pointer;
typedef const string* const_pointer;
BasePVString(ScalarConstPtr const & scalar);
virtual ~BasePVString();
virtual String get() const ;
virtual void put(String val);
virtual string get() const ;
virtual void put(string val);
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher) const;
virtual void deserialize(ByteBuffer *pbuffer,
@@ -143,7 +144,7 @@ public:
virtual void serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, size_t offset, size_t count) const;
private:
String value;
string value;
};
BasePVString::BasePVString(ScalarConstPtr const & scalar)
@@ -152,9 +153,9 @@ BasePVString::BasePVString(ScalarConstPtr const & scalar)
BasePVString::~BasePVString() {}
String BasePVString::get() const { return value;}
string BasePVString::get() const { return value;}
void BasePVString::put(String val)
void BasePVString::put(string val)
{
value = val;
postPut();
@@ -362,10 +363,10 @@ void DefaultPVArray<T>::serialize(ByteBuffer *pbuffer,
}
}
// specializations for String
// specializations for string
template<>
void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
void DefaultPVArray<string>::deserialize(ByteBuffer *pbuffer,
DeserializableControl *pcontrol) {
size_t size = SerializeHelper::readSize(pbuffer, pcontrol);
@@ -378,7 +379,7 @@ void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
nextvalue.slice(0, size);
String * pvalue = nextvalue.data();
string * pvalue = nextvalue.data();
for(size_t i = 0; i<size; i++) {
pvalue[i] = SerializeHelper::deserializeString(pbuffer,
pcontrol);
@@ -389,7 +390,7 @@ void DefaultPVArray<String>::deserialize(ByteBuffer *pbuffer,
}
template<>
void DefaultPVArray<String>::serialize(ByteBuffer *pbuffer,
void DefaultPVArray<string>::serialize(ByteBuffer *pbuffer,
SerializableControl *pflusher, size_t offset, size_t count) const {
const_svector temp(value);
@@ -397,7 +398,7 @@ void DefaultPVArray<String>::serialize(ByteBuffer *pbuffer,
SerializeHelper::writeSize(temp.size(), pbuffer, pflusher);
const String * pvalue = temp.data();
const string * pvalue = temp.data();
for(size_t i = 0; i<temp.size(); i++) {
SerializeHelper::serializeString(pvalue[i], pbuffer, pflusher);
}
@@ -414,7 +415,7 @@ typedef DefaultPVArray<uint32> BasePVUIntArray;
typedef DefaultPVArray<uint64> BasePVULongArray;
typedef DefaultPVArray<float> BasePVFloatArray;
typedef DefaultPVArray<double> BasePVDoubleArray;
typedef DefaultPVArray<String> BasePVStringArray;
typedef DefaultPVArray<string> BasePVStringArray;
// Factory

View File

@@ -20,10 +20,10 @@
using std::tr1::const_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
PVField::PVField(FieldConstPtr field)
: notImplemented("not implemented"),
parent(NULL),field(field),
@@ -79,7 +79,7 @@ void PVField::setPostHandler(PostHandlerPtr const &handler)
postHandler = handler;
}
void PVField::setParentAndName(PVStructure * xxx,String const & name)
void PVField::setParentAndName(PVStructure * xxx,string const & name)
{
parent = xxx;
fieldName = name;
@@ -90,46 +90,14 @@ bool PVField::equals(PVField &pv)
return pv==*this;
}
void PVField::toString(StringBuilder buf)
{
toString(buf,0);
}
void PVField::toString(StringBuilder buf,int indentLevel)
{
Convert().getString(buf,this,indentLevel);
}
std::ostream& operator<<(std::ostream& o, const PVField& f)
{
std::ostream& ro = f.dumpValue(o);
return ro;
return f.dumpValue(o);
};
namespace format
string PVField::getFullName() const
{
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
{
indent_value(os) = indent.level;
return os;
}
std::ostream& operator<<(std::ostream& os, indent const&)
{
long il = indent_value(os);
std::size_t spaces = static_cast<std::size_t>(il) * 4;
return os << std::string(spaces, ' ');
}
array_at_internal operator<<(std::ostream& str, array_at const& manip)
{
return array_at_internal(manip.index, str);
}
};
String PVField::getFullName() const
{
String ret(fieldName);
string ret(fieldName);
for(PVField *fld=getParent(); fld; fld=fld->getParent())
{
if(fld->getFieldName().size()==0) break;

View File

@@ -22,6 +22,7 @@
using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
@@ -45,7 +46,7 @@ PVUnionArrayPtr PVStructure::nullPVUnionArray;
PVScalarArrayPtr PVStructure::nullPVScalarArray;
static PVFieldPtr findSubField(
String const &fieldName,
string const &fieldName,
const PVStructure *pvStructure);
PVStructure::PVStructure(StructureConstPtr const & structurePtr)
@@ -109,7 +110,7 @@ const PVFieldPtrArray & PVStructure::getPVFields() const
return pvFields;
}
PVFieldPtr PVStructure::getSubField(String const &fieldName) const
PVFieldPtr PVStructure::getSubField(string const &fieldName) const
{
return findSubField(fieldName,this);
}
@@ -135,78 +136,78 @@ PVFieldPtr PVStructure::getSubField(size_t fieldOffset) const
}
PVBooleanPtr PVStructure::getBooleanField(String const &fieldName)
PVBooleanPtr PVStructure::getBooleanField(string const &fieldName)
{
return getSubField<PVBoolean>(fieldName);
}
PVBytePtr PVStructure::getByteField(String const &fieldName)
PVBytePtr PVStructure::getByteField(string const &fieldName)
{
return getSubField<PVByte>(fieldName);
}
PVShortPtr PVStructure::getShortField(String const &fieldName)
PVShortPtr PVStructure::getShortField(string const &fieldName)
{
return getSubField<PVShort>(fieldName);
}
PVIntPtr PVStructure::getIntField(String const &fieldName)
PVIntPtr PVStructure::getIntField(string const &fieldName)
{
return getSubField<PVInt>(fieldName);
}
PVLongPtr PVStructure::getLongField(String const &fieldName)
PVLongPtr PVStructure::getLongField(string const &fieldName)
{
return getSubField<PVLong>(fieldName);
}
PVUBytePtr PVStructure::getUByteField(String const &fieldName)
PVUBytePtr PVStructure::getUByteField(string const &fieldName)
{
return getSubField<PVUByte>(fieldName);
}
PVUShortPtr PVStructure::getUShortField(String const &fieldName)
PVUShortPtr PVStructure::getUShortField(string const &fieldName)
{
return getSubField<PVUShort>(fieldName);
}
PVUIntPtr PVStructure::getUIntField(String const &fieldName)
PVUIntPtr PVStructure::getUIntField(string const &fieldName)
{
return getSubField<PVUInt>(fieldName);
}
PVULongPtr PVStructure::getULongField(String const &fieldName)
PVULongPtr PVStructure::getULongField(string const &fieldName)
{
return getSubField<PVULong>(fieldName);
}
PVFloatPtr PVStructure::getFloatField(String const &fieldName)
PVFloatPtr PVStructure::getFloatField(string const &fieldName)
{
return getSubField<PVFloat>(fieldName);
}
PVDoublePtr PVStructure::getDoubleField(String const &fieldName)
PVDoublePtr PVStructure::getDoubleField(string const &fieldName)
{
return getSubField<PVDouble>(fieldName);
}
PVStringPtr PVStructure::getStringField(String const &fieldName)
PVStringPtr PVStructure::getStringField(string const &fieldName)
{
return getSubField<PVString>(fieldName);
}
PVStructurePtr PVStructure::getStructureField(String const &fieldName)
PVStructurePtr PVStructure::getStructureField(string const &fieldName)
{
return getSubField<PVStructure>(fieldName);
}
PVUnionPtr PVStructure::getUnionField(String const &fieldName)
PVUnionPtr PVStructure::getUnionField(string const &fieldName)
{
return getSubField<PVUnion>(fieldName);
}
PVScalarArrayPtr PVStructure::getScalarArrayField(
String const &fieldName,ScalarType elementType)
string const &fieldName,ScalarType elementType)
{
PVFieldPtr pvField = findSubField(fieldName,this);
if(pvField.get()==NULL) {
@@ -226,13 +227,13 @@ PVScalarArrayPtr PVStructure::getScalarArrayField(
}
PVStructureArrayPtr PVStructure::getStructureArrayField(
String const &fieldName)
string const &fieldName)
{
return getSubField<PVStructureArray>(fieldName);
}
PVUnionArrayPtr PVStructure::getUnionArrayField(
String const &fieldName)
string const &fieldName)
{
return getSubField<PVUnionArray>(fieldName);
}
@@ -328,13 +329,13 @@ void PVStructure::deserialize(ByteBuffer *pbuffer,
}
static PVFieldPtr findSubField(
String const & fieldName,
string const & fieldName,
PVStructure const *pvStructure)
{
if( fieldName.length()<1) return PVFieldPtr();
String::size_type index = fieldName.find('.');
String name = fieldName;
String restOfName = String();
string::size_type index = fieldName.find('.');
string name = fieldName;
string restOfName = string();
if(index>0) {
name = fieldName.substr(0, index);
if(fieldName.length()>index) {

View File

@@ -22,6 +22,7 @@
using std::tr1::static_pointer_cast;
using std::size_t;
using std::string;
namespace epics { namespace pvData {
@@ -58,11 +59,11 @@ int32 PVUnion::getSelectedIndex() const
return selector;
}
String PVUnion::getSelectedFieldName() const
string PVUnion::getSelectedFieldName() const
{
// no name for undefined and for variant unions
if (selector == UNDEFINED_INDEX)
return String();
return string();
else
return unionPtr->getFieldName(selector);
}
@@ -91,7 +92,7 @@ PVFieldPtr PVUnion::select(int32 index)
return value;
}
PVFieldPtr PVUnion::select(String const & fieldName)
PVFieldPtr PVUnion::select(string const & fieldName)
{
int32 index = variant ? -1 : static_cast<int32>(unionPtr->getFieldIndex(fieldName));
if (index == -1)
@@ -129,7 +130,7 @@ void PVUnion::set(int32 index, PVFieldPtr const & value)
postPut();
}
void PVUnion::set(String const & fieldName, PVFieldPtr const & value)
void PVUnion::set(string const & fieldName, PVFieldPtr const & value)
{
int32 index = variant ? -1 : static_cast<int32>(unionPtr->getFieldIndex(fieldName));
if (index == -1)

View File

@@ -17,6 +17,7 @@
#include <pv/standardField.h>
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
@@ -49,7 +50,7 @@ void StandardField::init()
StandardField::~StandardField(){}
StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,String properties)
StructureConstPtr StandardField::createProperties(string id,FieldConstPtr field,string properties)
{
bool gotAlarm = false;
bool gotTimeStamp = false;
@@ -57,11 +58,11 @@ StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,
bool gotControl = false;
bool gotValueAlarm = false;
int numProp = 0;
if(properties.find("alarm")!=String::npos) { gotAlarm = true; numProp++; }
if(properties.find("timeStamp")!=String::npos) { gotTimeStamp = true; numProp++; }
if(properties.find("display")!=String::npos) { gotDisplay = true; numProp++; }
if(properties.find("control")!=String::npos) { gotControl = true; numProp++; }
if(properties.find("valueAlarm")!=String::npos) { gotValueAlarm = true; numProp++; }
if(properties.find("alarm")!=string::npos) { gotAlarm = true; numProp++; }
if(properties.find("timeStamp")!=string::npos) { gotTimeStamp = true; numProp++; }
if(properties.find("display")!=string::npos) { gotDisplay = true; numProp++; }
if(properties.find("control")!=string::npos) { gotControl = true; numProp++; }
if(properties.find("valueAlarm")!=string::npos) { gotValueAlarm = true; numProp++; }
StructureConstPtr valueAlarm;
Type type= field->getType();
while(gotValueAlarm) {
@@ -82,7 +83,7 @@ StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,
case pvFloat: valueAlarm = floatAlarmField; break;
case pvDouble: valueAlarm = doubleAlarmField; break;
case pvString:
throw std::logic_error(String("valueAlarm property not supported for pvString"));
throw std::logic_error(string("valueAlarm property not supported for pvString"));
}
break;
}
@@ -93,8 +94,8 @@ StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,
FieldConstPtrArray fields = structurePtr->getFields();
FieldConstPtr first = fields[0];
FieldConstPtr second = fields[1];
String nameFirst = names[0];
String nameSecond = names[1];
string nameFirst = names[0];
string nameSecond = names[1];
int compareFirst = nameFirst.compare("index");
int compareSecond = nameSecond.compare("choices");
if(compareFirst==0 && compareSecond==0) {
@@ -112,7 +113,7 @@ StructureConstPtr StandardField::createProperties(String id,FieldConstPtr field,
}
}
}
throw std::logic_error(String("valueAlarm property for illegal type"));
throw std::logic_error(string("valueAlarm property for illegal type"));
}
size_t numFields = numProp+1;
FieldConstPtrArray fields(numFields);
@@ -499,7 +500,7 @@ void StandardField::createEnumeratedAlarm() {
StructureConstPtr StandardField::scalar(
ScalarType type,String const &properties)
ScalarType type,string const &properties)
{
ScalarConstPtr field = fieldCreate->createScalar(type); // scalar_t
return createProperties("uri:ev4:nt/2012/pwd:NTScalar",field,properties);
@@ -507,20 +508,20 @@ StructureConstPtr StandardField::scalar(
StructureConstPtr StandardField::regUnion(
UnionConstPtr const &field,
String const & properties)
string const & properties)
{
return createProperties("uri:ev4:nt/2012/pwd:NTUnion",field,properties);
}
StructureConstPtr StandardField::variantUnion(
String const & properties)
string const & properties)
{
UnionConstPtr field = fieldCreate->createVariantUnion();
return createProperties("uri:ev4:nt/2012/pwd:NTUnion",field,properties);
}
StructureConstPtr StandardField::scalarArray(
ScalarType elementType, String const &properties)
ScalarType elementType, string const &properties)
{
ScalarArrayConstPtr field = fieldCreate->createScalarArray(elementType); // scalar_t[]
return createProperties("uri:ev4:nt/2012/pwd:NTScalarArray",field,properties);
@@ -528,7 +529,7 @@ StructureConstPtr StandardField::scalarArray(
StructureConstPtr StandardField::structureArray(
StructureConstPtr const & structure,String const &properties)
StructureConstPtr const & structure,string const &properties)
{
StructureArrayConstPtr field = fieldCreate->createStructureArray(
structure);
@@ -536,7 +537,7 @@ StructureConstPtr StandardField::structureArray(
}
StructureConstPtr StandardField::unionArray(
UnionConstPtr const & punion,String const &properties)
UnionConstPtr const & punion,string const &properties)
{
UnionArrayConstPtr field = fieldCreate->createUnionArray(
punion);
@@ -556,7 +557,7 @@ StructureConstPtr StandardField::enumerated()
// NOTE: if this method is used to get NTEnum wihtout properties the ID will be wrong!
}
StructureConstPtr StandardField::enumerated(String const &properties)
StructureConstPtr StandardField::enumerated(string const &properties)
{
StructureConstPtr field = enumerated(); // enum_t
return createProperties("uri:ev4:nt/2012/pwd:NTEnum",field,properties);

View File

@@ -18,6 +18,8 @@
#include <pv/standardField.h>
#include <pv/standardPVField.h>
using std::string;
namespace epics { namespace pvData {
StandardPVField::StandardPVField()
@@ -30,7 +32,7 @@ StandardPVField::StandardPVField()
StandardPVField::~StandardPVField(){}
PVStructurePtr StandardPVField::scalar(
ScalarType type,String const & properties)
ScalarType type,string const & properties)
{
StructureConstPtr field = standardField->scalar(type,properties);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
@@ -38,7 +40,7 @@ PVStructurePtr StandardPVField::scalar(
}
PVStructurePtr StandardPVField::scalarArray(
ScalarType elementType, String const & properties)
ScalarType elementType, string const & properties)
{
StructureConstPtr field = standardField->scalarArray(elementType,properties);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
@@ -46,7 +48,7 @@ PVStructurePtr StandardPVField::scalarArray(
}
PVStructurePtr StandardPVField::structureArray(
StructureConstPtr const & structure,String const & properties)
StructureConstPtr const & structure,string const & properties)
{
StructureConstPtr field = standardField->structureArray(structure,properties);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
@@ -54,7 +56,7 @@ PVStructurePtr StandardPVField::structureArray(
}
PVStructurePtr StandardPVField::unionArray(
UnionConstPtr const & punion,String const & properties)
UnionConstPtr const & punion,string const & properties)
{
StructureConstPtr field = standardField->unionArray(punion,properties);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);
@@ -74,7 +76,7 @@ PVStructurePtr StandardPVField::enumerated(StringArray const &choices)
}
PVStructurePtr StandardPVField::enumerated(
StringArray const &choices,String const & properties)
StringArray const &choices,string const & properties)
{
StructureConstPtr field = standardField->enumerated(properties);
PVStructurePtr pvStructure = pvDataCreate->createPVStructure(field);

View File

@@ -19,6 +19,8 @@
#include "dbDefs.h" // for NELEMENTS
using std::string;
namespace epics { namespace pvData {
namespace TypeFunc {
@@ -30,11 +32,13 @@ namespace TypeFunc {
THROW_EXCEPTION2(std::invalid_argument, "logic error unknown Type");
return names[t];
}
void toString(StringBuilder buf,const Type type) {
*buf += name(type);
}
} // namespace TypeFunc
std::ostream& operator<<(std::ostream& o, const Type& type)
{
return o << TypeFunc::name(type);
}
namespace ScalarTypeFunc {
bool isInteger(ScalarType type) {
@@ -63,7 +67,7 @@ namespace ScalarTypeFunc {
"ubyte", "ushort", "uint", "ulong",
"float", "double", "string",
};
ScalarType getScalarType(const String& pvalue) {
ScalarType getScalarType(const string& pvalue) {
for(size_t i=0; i<NELEMENTS(names); i++)
if(pvalue==names[i])
return ScalarType(i);
@@ -76,10 +80,6 @@ namespace ScalarTypeFunc {
return names[t];
}
void toString(StringBuilder buf,const ScalarType scalarType) {
*buf += name(scalarType);
}
size_t elementSize(ScalarType id)
{
switch(id) {
@@ -95,7 +95,7 @@ namespace ScalarTypeFunc {
OP(pvLong, int64);
OP(pvFloat, float);
OP(pvDouble, double);
OP(pvString, String);
OP(pvString, string);
#undef OP
default:
THROW_EXCEPTION2(std::invalid_argument, "error unknown ScalarType");
@@ -117,7 +117,7 @@ namespace ScalarTypeFunc {
OP(pvLong, int64);
OP(pvFloat, float);
OP(pvDouble, double);
OP(pvString, String);
OP(pvString, string);
#undef OP
default:
throw std::bad_alloc();
@@ -126,4 +126,9 @@ namespace ScalarTypeFunc {
} // namespace ScalarTypeFunc
std::ostream& operator<<(std::ostream& o, const ScalarType& scalarType)
{
return o << ScalarTypeFunc::name(scalarType);
}
}}

View File

@@ -10,6 +10,8 @@
#define epicsExportSharedSymbols
#include <pv/printer.h>
using std::string;
namespace {
void indentN(std::ostream& strm, size_t N)
@@ -22,6 +24,27 @@ void indentN(std::ostream& strm, size_t N)
namespace epics { namespace pvData {
namespace format
{
std::ostream& operator<<(std::ostream& os, indent_level const& indent)
{
indent_value(os) = indent.level;
return os;
}
std::ostream& operator<<(std::ostream& os, indent const&)
{
long il = indent_value(os);
std::size_t spaces = static_cast<std::size_t>(il) * 4;
return os << string(spaces, ' ');
}
array_at_internal operator<<(std::ostream& str, array_at const& manip)
{
return array_at_internal(manip.index, str);
}
};
PrinterBase::PrinterBase()
:strm(NULL)
{}
@@ -239,14 +262,14 @@ void PrinterPlain::encodeScalar(const PVScalar& pv)
indentN(S(), ilvl);
S() << pv.getScalar()->getID() << " "
<< pv.getFieldName() << " "
<< pv.getAs<String>() << std::endl;
<< pv.getAs<string>() << std::endl;
}
void PrinterPlain::encodeArray(const PVScalarArray& pv)
{
indentN(S(), ilvl);
shared_vector<const String> temp;
pv.getAs<String>(temp);
shared_vector<const string> temp;
pv.getAs<string>(temp);
S() << pv.getScalarArray()->getID() << " "
<< pv.getFieldName() << " [";

View File

@@ -14,9 +14,11 @@
#define epicsExportSharedSymbols
#include <pv/pvSubArrayCopy.h>
namespace epics { namespace pvData {
using std::cout;
using std::endl;
using std::string;
namespace epics { namespace pvData {
template<typename T>
void copy(
@@ -141,8 +143,8 @@ void copy(
break;
case pvString:
{
copy(dynamic_cast<PVValueArray<String> &>(from),fromOffset,fromStride,
dynamic_cast<PVValueArray<String>& >(to),
copy(dynamic_cast<PVValueArray<string> &>(from),fromOffset,fromStride,
dynamic_cast<PVValueArray<string>& >(to),
toOffset,toStride,count);
}
break;

View File

@@ -309,21 +309,6 @@ namespace epics { namespace pvData {
return !(*this == set);
}
void BitSet::toString(StringBuilder buffer, int /*indentLevel*/) const
{
*buffer += '{';
int32 i = nextSetBit(0);
char tmp[30];
if (i != -1) {
sprintf(tmp,"%d",(int)i); *buffer += tmp;
for (i = nextSetBit(i+1); i >= 0; i = nextSetBit(i+1)) {
int32 endOfRun = nextClearBit(i);
do { *buffer += ", "; sprintf(tmp,"%d",(int)i); *buffer += tmp; } while (++i < endOfRun);
}
}
*buffer += '}';
}
void BitSet::serialize(ByteBuffer* buffer, SerializableControl* flusher) const {
uint32 n = wordsInUse;

View File

@@ -225,8 +225,6 @@ namespace epics { namespace pvData {
bool operator!=(const BitSet &set) const;
void toString(StringBuilder buffer, int indentLevel = 0) const;
virtual void serialize(ByteBuffer *buffer,
SerializableControl *flusher) const;
virtual void deserialize(ByteBuffer *buffer,

View File

@@ -10,10 +10,12 @@
#include <sstream>
#include <cstdio>
#include <cstring>
#include <string>
#define epicsExportSharedSymbols
#include <pv/epicsException.h>
using std::string;
namespace epics{ namespace pvData {
@@ -32,7 +34,7 @@ ExceptionMixin::print(FILE *fp) const
#endif
}
std::string
string
ExceptionMixin::show() const
{
std::ostringstream out;
@@ -62,7 +64,7 @@ BaseException::what() const throw()
try{
if (base_msg.size()==0) {
const char *base=std::logic_error::what();
std::string out, stack;
string out, stack;
const ExceptionMixin *info=dynamic_cast<const ExceptionMixin*>(this);
if(info) {

View File

@@ -26,6 +26,8 @@
#include <pv/lock.h>
#include <pv/event.h>
using std::string;
namespace epics { namespace pvData {
@@ -43,27 +45,27 @@ Event::Event(bool full)
void Event::signal()
{
if(id==0) throw std::logic_error(String("event was deleted"));
if(id==0) throw std::logic_error(string("event was deleted"));
epicsEventSignal(id);
}
bool Event::wait ()
{
if(id==0) throw std::logic_error(String("event was deleted"));
if(id==0) throw std::logic_error(string("event was deleted"));
epicsEventWaitStatus status = epicsEventWait(id);
return status==epicsEventWaitOK ? true : false;
}
bool Event::wait ( double timeOut )
{
if(id==0) throw std::logic_error(String("event was deleted"));
if(id==0) throw std::logic_error(string("event was deleted"));
epicsEventWaitStatus status = epicsEventWaitWithTimeout(id,timeOut);
return status==epicsEventWaitOK ? true : false;
}
bool Event::tryWait ()
{
if(id==0) throw std::logic_error(String("event was deleted"));
if(id==0) throw std::logic_error(string("event was deleted"));
epicsEventWaitStatus status = epicsEventTryWait(id);
return status==epicsEventWaitOK ? true : false;
}

View File

@@ -46,7 +46,7 @@ public:
bool tryWait (); /* false if empty */
private:
epicsEventId id;
String alreadyOn;
std::string alreadyOn;
};
}}

View File

@@ -16,6 +16,8 @@
#define epicsExportSharedSymbols
#include <pv/executor.h>
using std::string;
namespace epics { namespace pvData {
// special instance to stop the executor thread
@@ -31,7 +33,7 @@ static
std::tr1::shared_ptr<Command> shutdown(new ExecutorShutdown());
Executor::Executor(String threadName,ThreadPriority priority)
Executor::Executor(string const & threadName,ThreadPriority priority)
: thread(threadName,priority,this)
{
}

View File

@@ -40,7 +40,7 @@ private:
class epicsShareClass Executor : public Runnable{
public:
POINTER_DEFINITIONS(Executor);
Executor(String threadName,ThreadPriority priority);
Executor(std::string const & threadName,ThreadPriority priority);
~Executor();
void execute(CommandPtr const &node);
virtual void run();

View File

@@ -12,13 +12,15 @@
#define epicsExportSharedSymbols
#include <pv/messageQueue.h>
using std::string;
namespace epics { namespace pvData {
MessageNode::MessageNode()
: messageType(infoMessage)
{}
String MessageNode::getMessage() const
string MessageNode::getMessage() const
{
return message;
}
@@ -59,7 +61,7 @@ void MessageQueue::release() {
releaseUsed(lastGet);
lastGet.reset();
}
bool MessageQueue::put(String message,MessageType messageType,bool replaceLast)
bool MessageQueue::put(string message,MessageType messageType,bool replaceLast)
{
MessageNodePtr node = getFree();
if(node.get()!= NULL) {

View File

@@ -31,10 +31,10 @@ typedef std::tr1::shared_ptr<MessageQueue> MessageQueuePtr;
class epicsShareClass MessageNode {
public:
MessageNode();
String getMessage() const;
std::string getMessage() const;
MessageType getMessageType() const;
private:
String message;
std::string message;
MessageType messageType;
friend class MessageQueue;
};
@@ -49,7 +49,7 @@ public:
// must call release before next get
void release();
// return (false,true) if message (was not, was) put into queue
bool put(String message,MessageType messageType,bool replaceLast);
bool put(std::string message,MessageType messageType,bool replaceLast);
bool isEmpty() ;
bool isFull() ;
int getClearOverrun();

View File

@@ -14,6 +14,8 @@
#define epicsExportSharedSymbols
#include "typeCast.h"
using std::string;
// need to use "long long" when sizeof(int)==sizeof(long)
#if (ULONG_MAX == 0xfffffffful) || defined(_WIN32) || defined(__rtems__)
#define NEED_LONGLONG
@@ -422,18 +424,18 @@ void handleParseError(int err)
namespace epics { namespace pvData { namespace detail {
void parseToPOD(const std::string & in, boolean *out)
void parseToPOD(const string & in, boolean *out)
{
if(epicsStrCaseCmp(in.c_str(),"true")==0)
*out = 1;
else if(epicsStrCaseCmp(in.c_str(),"false")==0)
*out = 0;
else
throw std::runtime_error("parseToPOD: String no match true/false");
throw std::runtime_error("parseToPOD: string no match true/false");
}
#define INTFN(T, S) \
void parseToPOD(const std::string& in, T *out) { \
void parseToPOD(const string& in, T *out) { \
epics ## S temp; \
int err = epicsParse ## S (in.c_str(), &temp, 0, NULL); \
if(err) handleParseError(err); \
@@ -447,7 +449,7 @@ INTFN(uint16_t, UInt16);
INTFN(int32_t, Int32);
INTFN(uint32_t, UInt32);
void parseToPOD(const std::string& in, int64_t *out) {
void parseToPOD(const string& in, int64_t *out) {
#ifdef NEED_LONGLONG
int err = epicsParseLongLong(in.c_str(), out, 0, NULL);
#else
@@ -456,7 +458,7 @@ void parseToPOD(const std::string& in, int64_t *out) {
if(err) handleParseError(err);
}
void parseToPOD(const std::string& in, uint64_t *out) {
void parseToPOD(const string& in, uint64_t *out) {
#ifdef NEED_LONGLONG
int err = epicsParseULongLong(in.c_str(), out, 0, NULL);
#else
@@ -465,12 +467,12 @@ void parseToPOD(const std::string& in, uint64_t *out) {
if(err) handleParseError(err);
}
void parseToPOD(const std::string& in, float *out) {
void parseToPOD(const string& in, float *out) {
int err = epicsParseFloat(in.c_str(), out, NULL);
if(err) handleParseError(err);
}
void parseToPOD(const std::string& in, double *out) {
void parseToPOD(const string& in, double *out) {
int err = epicsParseDouble(in.c_str(), out, NULL);
if(err) handleParseError(err);
}

View File

@@ -14,11 +14,13 @@
#include <pv/lock.h>
#include <pv/requester.h>
using std::string;
namespace epics { namespace pvData {
static StringArray messageTypeName(MESSAGE_TYPE_COUNT);
String getMessageTypeName(MessageType messageType)
string getMessageTypeName(MessageType messageType)
{
// TODO not thread-safe
static Mutex mutex;

View File

@@ -26,14 +26,14 @@ enum MessageType {
};
#define MESSAGE_TYPE_COUNT 4
epicsShareExtern String getMessageTypeName(MessageType messageType);
epicsShareExtern std::string getMessageTypeName(MessageType messageType);
class epicsShareClass Requester {
public:
POINTER_DEFINITIONS(Requester);
virtual ~Requester(){}
virtual String getRequesterName() = 0;
virtual void message(String const & message,MessageType messageType) = 0;
virtual std::string getRequesterName() = 0;
virtual void message(std::string const & message,MessageType messageType) = 0;
};
}}

View File

@@ -57,7 +57,7 @@ namespace epics {
return (std::size_t)(b<0 ? b+256 : b);
}
void SerializeHelper::serializeString(const String& value,
void SerializeHelper::serializeString(const string& value,
ByteBuffer* buffer, SerializableControl* flusher) {
std::size_t len = value.length();
SerializeHelper::writeSize(len, buffer, flusher);
@@ -74,7 +74,7 @@ namespace epics {
}
}
void SerializeHelper::serializeSubstring(const String& value,
void SerializeHelper::serializeSubstring(const string& value,
std::size_t offset, std::size_t count, ByteBuffer* buffer,
SerializableControl* flusher) {
/*if(offset<0)
@@ -97,9 +97,9 @@ namespace epics {
}
}
static String emptyString;
static string emptyStringtring;
String SerializeHelper::deserializeString(ByteBuffer* buffer,
string SerializeHelper::deserializeString(ByteBuffer* buffer,
DeserializableControl* control) {
std::size_t size = SerializeHelper::readSize(buffer, control);
@@ -109,13 +109,13 @@ namespace epics {
{
// entire string is in buffer, simply create a string out of it (copy)
std::size_t pos = buffer->getPosition();
String str(buffer->getArray()+pos, size);
string str(buffer->getArray()+pos, size);
buffer->setPosition(pos+size);
return str;
}
else
{
String str;
string str;
str.reserve(size);
try {
std::size_t i = 0;
@@ -137,7 +137,7 @@ namespace epics {
}
}
else
return emptyString;
return emptyStringtring;
}
}

View File

@@ -46,30 +46,30 @@ namespace epics {
DeserializableControl* control);
/**
* String serialization helper method.
* std::string serialization helper method.
*
* @param[in] value String to serialize
* @param[in] value std::string to serialize
* @param[in] buffer serialization buffer
* @param[in] flusher flusher
*/
static void serializeString(const String& value, ByteBuffer* buffer,
static void serializeString(const std::string& value, ByteBuffer* buffer,
SerializableControl* flusher);
/**
* String serialization helper method.
* std::string serialization helper method.
*
* @param[in] value String to serialize
* @param[in] value std::string to serialize
* @param[in] offset start of the substring in {@code value}
* @param[in] count the number of characters to write
* @param[in] buffer serialization buffer
* @param[in] flusher flusher
*/
static void serializeSubstring(const String& value, std::size_t offset,
static void serializeSubstring(const std::string& value, std::size_t offset,
std::size_t count, ByteBuffer* buffer,
SerializableControl* flusher);
/**
* String deserialization helper method.
* std::string deserialization helper method.
* TODO This method cannot return "null", but Java implementation
* could have serialized "null" value as well. We need to decide
* how to deserialize "null".
@@ -82,7 +82,7 @@ namespace epics {
* could have serialized "null" value as well. We need to decide
* how to deserialize "null".
*/
static String deserializeString(ByteBuffer* buffer,
static std::string deserializeString(ByteBuffer* buffer,
DeserializableControl* control);
private:

View File

@@ -12,10 +12,12 @@
#include <pv/serializeHelper.h>
#include <pv/status.h>
using std::string;
namespace epics { namespace pvData {
const char* Status::StatusTypeName[] = { "OK", "WARNING", "ERROR", "FATAL" };
epics::pvData::String Status::m_emptyString;
string Status::m_emptyStringtring;
Status Status::Ok;
@@ -26,7 +28,7 @@ Status::Status() :
{
}
Status::Status(StatusType type, String const & message) :
Status::Status(StatusType type, string const & message) :
m_statusType(type), m_message(message)
{
if (type == STATUSTYPE_OK)
@@ -35,7 +37,7 @@ Status::Status(StatusType type, String const & message) :
//PVDATA_REFCOUNT_MONITOR_CONSTRUCT(status);
}
Status::Status(StatusType type, String const & message, String const & stackDump) :
Status::Status(StatusType type, string const & message, string const & stackDump) :
m_statusType(type), m_message(message), m_stackDump(stackDump)
{
if (type == STATUSTYPE_OK)
@@ -54,12 +56,12 @@ Status::StatusType Status::getType() const
}
epics::pvData::String Status::getMessage() const
string Status::getMessage() const
{
return m_message;
}
epics::pvData::String Status::getStackDump() const
string Status::getStackDump() const
{
return m_stackDump;
}
@@ -100,7 +102,7 @@ void Status::deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
if (m_statusType != STATUSTYPE_OK)
{
m_statusType = STATUSTYPE_OK;
m_message = m_stackDump = m_emptyString;
m_message = m_stackDump = m_emptyStringtring;
}
}
else
@@ -111,29 +113,21 @@ void Status::deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
}
}
String Status::toString() const
std::ostream& operator<<(std::ostream& o, const Status& status)
{
String str;
toString(&str, 0);
return str;
o << "Status [type=" << Status::StatusTypeName[status.m_statusType];
if (!status.m_message.empty())
o << ", message=" << status.m_message;
if (!status.m_stackDump.empty())
o << ", stackDump=" << std::endl << status.m_stackDump;
o << ']';
return o;
}
void Status::toString(StringBuilder buffer, int /*indentLevel*/) const
std::ostream& operator<<(std::ostream& o, const Status::StatusType& statusType)
{
*buffer += "Status [type=";
*buffer += StatusTypeName[m_statusType];
if (!m_message.empty())
{
*buffer += ", message=";
*buffer += m_message;
}
if (!m_stackDump.empty())
{
*buffer += ", stackDump=";
*buffer += '\n';
*buffer += m_stackDump;
}
*buffer += ']';
o << Status::StatusTypeName[statusType];
return o;
}
}}

View File

@@ -10,6 +10,8 @@
#ifndef STATUS_H
#define STATUS_H
#include <ostream>
#include <pv/serialize.h>
#include <pv/byteBuffer.h>
#include <pv/sharedPtr.h>
@@ -51,12 +53,12 @@ namespace epics { namespace pvData {
/**
* Create non-OK status.
*/
Status(StatusType type, epics::pvData::String const & message);
Status(StatusType type, std::string const & message);
/**
* Create non-OK status.
*/
Status(StatusType type, epics::pvData::String const & message, epics::pvData::String const & stackDump);
Status(StatusType type, std::string const & message, std::string const & stackDump);
~Status();
@@ -70,13 +72,13 @@ namespace epics { namespace pvData {
* Get error message describing an error. Required if error status.
* @return error message.
*/
epics::pvData::String getMessage() const;
std::string getMessage() const;
/**
* Get stack dump where error (exception) happened. Optional.
* @return stack dump.
*/
epics::pvData::String getStackDump() const;
std::string getStackDump() const;
/**
* Convenient OK test. Same as <code>(getType() == StatusType.OK)</code>.
@@ -93,20 +95,22 @@ namespace epics { namespace pvData {
*/
bool isSuccess() const;
String toString() const;
void toString(StringBuilder buffer, int indentLevel = 0) const;
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const;
void deserialize(ByteBuffer *buffer, DeserializableControl *flusher);
private:
static epics::pvData::String m_emptyString;
static std::string m_emptyStringtring;
StatusType m_statusType;
String m_message;
String m_stackDump;
std::string m_message;
std::string m_stackDump;
friend std::ostream& operator<<(std::ostream& o, const Status& status);
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const Status& status);
epicsShareExtern std::ostream& operator<<(std::ostream& o, const Status::StatusType& statusType);
}}
#endif /* STATUS_H */

View File

@@ -50,7 +50,7 @@ typedef epicsThreadRunable Runnable;
class epicsShareClass Thread : public epicsThread, private NoDefaultMethods {
public:
Thread(String name,
Thread(std::string name,
ThreadPriority priority,
Runnable *runnable,
epicsThreadStackSizeClass stkcls=epicsThreadStackSmall)
@@ -63,7 +63,7 @@ public:
}
Thread(Runnable &runnable,
String name,
std::string name,
unsigned int stksize,
unsigned int priority=lowestPriority)
:epicsThread(runnable,

View File

@@ -13,11 +13,14 @@
#endif
#include <stdexcept>
#include <string>
#define epicsExportSharedSymbols
#include <pv/convert.h>
#include <pv/timer.h>
using std::string;
namespace epics { namespace pvData {
TimerCallback::TimerCallback()
@@ -26,7 +29,7 @@ TimerCallback::TimerCallback()
{
}
Timer::Timer(String threadName,ThreadPriority priority)
Timer::Timer(string threadName,ThreadPriority priority)
: waitForWork(false),
waitForDone(false),
alive(true),
@@ -84,7 +87,7 @@ void Timer::cancel(TimerCallbackPtr const &timerCallback)
prevNode = nextNode;
nextNode = nextNode->next;
}
throw std::logic_error(String(""));
throw std::logic_error(string(""));
}
bool Timer::isScheduled(TimerCallbackPtr const &timerCallback)
@@ -169,7 +172,7 @@ void Timer::schedulePeriodic(
double period)
{
if(isScheduled(timerCallback)) {
throw std::logic_error(String("already queued"));
throw std::logic_error(string("already queued"));
}
{
Lock xx(mutex);
@@ -193,23 +196,23 @@ void Timer::schedulePeriodic(
if(isFirst) waitForWork.signal();
}
void Timer::toString(StringBuilder builder)
std::ostream& operator<<(std::ostream& o, Timer& timer)
{
Lock xx(mutex);
if(!alive) return;
Lock xx(timer.mutex);
if(!timer.alive) return o;
TimeStamp currentTime;
TimerCallbackPtr nodeToCall(head);
TimerCallbackPtr nodeToCall(timer.head);
currentTime.getCurrent();
while(true) {
if(nodeToCall.get()==NULL) return;
if(nodeToCall.get()==NULL) return o;
TimeStamp timeToRun = nodeToCall->timeToRun;
double period = nodeToCall->period;
double diff = TimeStamp::diff(timeToRun,currentTime);
char buffer[50];
sprintf(buffer,"timeToRun %f period %f\n",diff,period);
*builder += buffer;
o << "timeToRun " << diff << " period " << period << std::endl;
nodeToCall = nodeToCall->next;
}
return o;
}
}}

View File

@@ -45,12 +45,13 @@ private:
double period;
bool onList;
friend class Timer;
friend std::ostream& operator<<(std::ostream& o, Timer& timer);
};
class epicsShareClass Timer : public Runnable {
public:
POINTER_DEFINITIONS(Timer);
Timer(String threadName, ThreadPriority priority);
Timer(std::string threadName, ThreadPriority priority);
virtual ~Timer();
virtual void run();
void scheduleAfterDelay(
@@ -62,7 +63,9 @@ public:
double period);
void cancel(TimerCallbackPtr const &timerCallback);
bool isScheduled(TimerCallbackPtr const &timerCallback);
void toString(StringBuilder builder);
friend std::ostream& operator<<(std::ostream& o, Timer& timer);
private:
void addElement(TimerCallbackPtr const &timerCallback);
TimerCallbackPtr head;
@@ -73,5 +76,7 @@ private:
Thread thread;
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, Timer& timer);
}}
#endif /* TIMER_H */

View File

@@ -11,9 +11,9 @@
#include "typeCast.h"
using epics::pvData::castUnsafe;
using epics::pvData::String;
using epics::pvData::ScalarType;
using epics::pvData::pvString;
using std::string;
namespace {
@@ -77,7 +77,7 @@ static convertfn converters[pvString+1][pvString+1] =
&noconvert,
&noconvert,
&noconvert,
&castVTyped<epics::pvData::boolean, String>,
&castVTyped<epics::pvData::boolean, string>,
},
// to pvByte
{&noconvert,
@@ -91,7 +91,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<int8_t, uint64_t>,
&castVTyped<int8_t, float>,
&castVTyped<int8_t, double>,
&castVTyped<int8_t, String>,
&castVTyped<int8_t, string>,
},
// to pvShort
{&noconvert,
@@ -105,7 +105,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<int16_t, uint64_t>,
&castVTyped<int16_t, float>,
&castVTyped<int16_t, double>,
&castVTyped<int16_t, String>,
&castVTyped<int16_t, string>,
},
// to pvInt
{&noconvert,
@@ -119,7 +119,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<int32_t, uint64_t>,
&castVTyped<int32_t, float>,
&castVTyped<int32_t, double>,
&castVTyped<int32_t, String>,
&castVTyped<int32_t, string>,
},
// to pvLong
{&noconvert,
@@ -133,7 +133,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<int64_t, uint64_t>,
&castVTyped<int64_t, float>,
&castVTyped<int64_t, double>,
&castVTyped<int64_t, String>,
&castVTyped<int64_t, string>,
},
// to pvUByte
{&noconvert,
@@ -147,7 +147,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<uint8_t, uint64_t>,
&castVTyped<uint8_t, float>,
&castVTyped<uint8_t, double>,
&castVTyped<uint8_t, String>,
&castVTyped<uint8_t, string>,
},
// to pvUShort
{&noconvert,
@@ -161,7 +161,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<uint16_t, uint64_t>,
&castVTyped<uint16_t, float>,
&castVTyped<uint16_t, double>,
&castVTyped<uint16_t, String>,
&castVTyped<uint16_t, string>,
},
// to pvUInt
{&noconvert,
@@ -175,7 +175,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<uint32_t, uint64_t>,
&castVTyped<uint32_t, float>,
&castVTyped<uint32_t, double>,
&castVTyped<uint32_t, String>,
&castVTyped<uint32_t, string>,
},
// to pvULong
{&noconvert,
@@ -189,7 +189,7 @@ static convertfn converters[pvString+1][pvString+1] =
&copyV<uint64_t>,
&castVTyped<uint64_t, float>,
&castVTyped<uint64_t, double>,
&castVTyped<uint64_t, String>,
&castVTyped<uint64_t, string>,
},
// to pvFloat
{&noconvert,
@@ -203,7 +203,7 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<float, uint64_t>,
&copyV<float>,
&castVTyped<float, double>,
&castVTyped<float, String>,
&castVTyped<float, string>,
},
// to pvDouble
{&noconvert,
@@ -217,21 +217,21 @@ static convertfn converters[pvString+1][pvString+1] =
&castVTyped<double, uint64_t>,
&castVTyped<double, float>,
&copyV<double>,
&castVTyped<double, String>,
&castVTyped<double, string>,
},
// to pvString
{&castVTyped<String, epics::pvData::boolean>,
&castVTyped<String, int8_t>,
&castVTyped<String, int16_t>,
&castVTyped<String, int32_t>,
&castVTyped<String, uint64_t>,
&castVTyped<String, uint8_t>,
&castVTyped<String, uint16_t>,
&castVTyped<String, uint32_t>,
&castVTyped<String, uint64_t>,
&castVTyped<String, float>,
&castVTyped<String, double>,
&copyV<String>,
{&castVTyped<string, epics::pvData::boolean>,
&castVTyped<string, int8_t>,
&castVTyped<string, int16_t>,
&castVTyped<string, int32_t>,
&castVTyped<string, uint64_t>,
&castVTyped<string, uint8_t>,
&castVTyped<string, uint16_t>,
&castVTyped<string, uint32_t>,
&castVTyped<string, uint64_t>,
&castVTyped<string, float>,
&castVTyped<string, double>,
&copyV<string>,
},
};

View File

@@ -30,8 +30,6 @@
namespace epics { namespace pvData {
typedef std::string String;
namespace detail {
// parseToPOD wraps the epicsParse*() functions in one name
// and throws exceptions
@@ -48,12 +46,12 @@ namespace detail {
epicsShareExtern void parseToPOD(const std::string&, double *out);
/* want to pass POD types by value,
* and String by const reference
* and std::string by const reference
*/
template<typename ARG>
struct cast_arg { typedef ARG arg; };
template<>
struct cast_arg<String> { typedef const String& arg; };
struct cast_arg<std::string> { typedef const std::string& arg; };
// Handle mangling of type/value when printing
template<typename T>
@@ -98,10 +96,10 @@ namespace detail {
};
// print POD to string
// when String!=FROM
// when std::string!=FROM
template<typename FROM>
struct cast_helper<String, FROM, typename meta::not_same_type<String,FROM>::type> {
static String op(FROM from) {
struct cast_helper<std::string, FROM, typename meta::not_same_type<std::string,FROM>::type> {
static std::string op(FROM from) {
std::ostringstream strm;
strm << print_convolute<FROM>::op(from);
if(strm.fail())
@@ -111,10 +109,10 @@ namespace detail {
};
// parse POD from string
// TO!=String
// TO!=std::string
template<typename TO>
struct cast_helper<TO, String, typename meta::not_same_type<TO,String>::type> {
static FORCE_INLINE TO op(const String& from) {
struct cast_helper<TO, std::string, typename meta::not_same_type<TO,std::string>::type> {
static FORCE_INLINE TO op(const std::string& from) {
TO ret;
parseToPOD(from, &ret);
return ret;
@@ -127,7 +125,7 @@ namespace detail {
*
* Supported types: uint8_t, int8_t, uint16_t, int16_t,
* uint32_t, int32_t, uint64_t, int64_t,
* float, double, String
* float, double, std::string
*
* As defined in pvType.h
*
@@ -153,9 +151,9 @@ namespace detail {
* Conversions where invalid or out of range inputs result
* in an exception.
*
* - non-String -> String
* - String -> non-String
* - String -> String (throws only std::bad_alloc)
* - non-std::string -> std::string
* - std::string -> non-std::string
* - std::string -> std::string (throws only std::bad_alloc)
*
* Conversions where out of range inputs produce undefined
* results.
@@ -169,7 +167,7 @@ namespace detail {
* too large to be represented by the integer type
* is not defined.
*
@section stringf String formats
@section stringf std::string formats
*
* - Numbers beginning with 1-9 are parsed as base-10.
* - Numbers beginning with '0x' are parsed as base-16

View File

@@ -12,10 +12,12 @@
#include <pv/monitorPlugin.h>
namespace epics { namespace pvData {
using std::string;
using std::cout;
using std::endl;
namespace epics { namespace pvData {
MonitorPluginManagerPtr MonitorPluginManager::get()
{
static MonitorPluginManagerPtr pluginManager;
@@ -28,7 +30,7 @@ MonitorPluginManagerPtr MonitorPluginManager::get()
}
bool MonitorPluginManager::addPlugin(
String const &pluginName,
string const &pluginName,
MonitorPluginCreatorPtr const &creator)
{
mutex.lock();
@@ -53,7 +55,7 @@ bool MonitorPluginManager::addPlugin(
MonitorPluginCreatorPtr MonitorPluginManager::findPlugin(
String const &pluginName)
string const &pluginName)
{
mutex.lock();
std::list<MonitorPluginCreatorPtr>::iterator iter;

View File

@@ -56,7 +56,7 @@ public:
* getName
* @returns The name of the plugin
*/
virtual String const & getName() = 0;
virtual std::string const & getName() = 0;
/**
* Should a monitor be raised?
* @param pvField The field being monitored.
@@ -125,7 +125,7 @@ public:
* getName
* @returns The name of the plugin
*/
virtual String const & getName() = 0;
virtual std::string const & getName() = 0;
};
@@ -152,7 +152,7 @@ public:
* false is returned if a plugin with that name is already present
*/
bool addPlugin(
String const &pluginName,
std::string const &pluginName,
MonitorPluginCreatorPtr const &creator);
/* find plugin
*
@@ -160,7 +160,7 @@ public:
* @returns share pointer to plugin creator.
* If a plugin with that name is not found NULL is returned.
*/
MonitorPluginCreatorPtr findPlugin(String const &pluginName);
MonitorPluginCreatorPtr findPlugin(std::string const &pluginName);
/* showNames
*
*/

View File

@@ -17,12 +17,14 @@
#include <pv/pvData.h>
#include <pv/alarm.h>
using std::string;
namespace epics { namespace pvData {
AlarmSeverity AlarmSeverityFunc::getSeverity(int value)
{
if(value<0 || value>4) {
throw std::logic_error(String("getSeverity value is illegal"));
throw std::logic_error(string("getSeverity value is illegal"));
}
switch (value) {
case 0: return noAlarm;
@@ -31,7 +33,7 @@ AlarmSeverity AlarmSeverityFunc::getSeverity(int value)
case 3: return invalidAlarm;
case 4: return undefinedAlarm;
}
throw std::logic_error(String("should never get here"));
throw std::logic_error(string("should never get here"));
}
StringArrayPtr AlarmSeverityFunc::getSeverityNames()
@@ -61,13 +63,13 @@ AlarmSeverity Alarm::getSeverity() const
case 3: return invalidAlarm;
case 4: return undefinedAlarm;
}
throw std::logic_error(String("should never get here"));
throw std::logic_error(string("should never get here"));
}
AlarmStatus AlarmStatusFunc::getStatus(int value)
{
if(value<0 || value>7) {
throw std::logic_error(String("getStatus value is illegal"));
throw std::logic_error(string("getStatus value is illegal"));
}
switch (value) {
case 0: return noStatus;
@@ -79,7 +81,7 @@ AlarmStatus AlarmStatusFunc::getStatus(int value)
case 6: return undefinedStatus;
case 7: return clientStatus;
}
throw std::logic_error(String("should never get here"));
throw std::logic_error(string("should never get here"));
}
StringArrayPtr AlarmStatusFunc::getStatusNames()
@@ -115,7 +117,7 @@ AlarmStatus Alarm::getStatus() const
case 6: return undefinedStatus;
case 7: return clientStatus;
}
throw std::logic_error(String("should never get here"));
throw std::logic_error(string("should never get here"));
}
}}

View File

@@ -42,10 +42,10 @@ public:
class epicsShareClass Alarm {
public:
Alarm() : severity(0),status(0), message(String("")) {}
Alarm() : severity(0),status(0), message(std::string("")) {}
//default constructors and destructor are OK
String getMessage() const {return message;}
void setMessage(String const &value) {message = value;}
std::string getMessage() const {return message;}
void setMessage(std::string const &value) {message = value;}
AlarmSeverity getSeverity() const;
void setSeverity(AlarmSeverity value) {severity = value;}
AlarmStatus getStatus() const;
@@ -53,7 +53,7 @@ public:
private:
int32 severity;
int32 status;
String message;
std::string message;
};
}}

View File

@@ -22,23 +22,23 @@ namespace epics { namespace pvData {
class epicsShareClass Display {
public:
Display()
: description(String("")),format(String("")),units(String("")),
: description(std::string("")),format(std::string("")),units(std::string("")),
low(0.0),high(0.0) {}
//default constructors and destructor are OK
double getLow() const {return low;}
double getHigh() const{ return high;}
void setLow(double value){low = value;}
void setHigh(double value){high = value;}
String getDescription() const {return description;}
void setDescription(String const & value) {description = value;}
String getFormat() const {return format;}
void setFormat(String const & value) {format = value;}
String getUnits() const {return units;}
void setUnits(String const & value) {units = value;}
std::string getDescription() const {return description;}
void setDescription(std::string const & value) {description = value;}
std::string getFormat() const {return format;}
void setFormat(std::string const & value) {format = value;}
std::string getUnits() const {return units;}
void setUnits(std::string const & value) {units = value;}
private:
String description;
String format;
String units;
std::string description;
std::string format;
std::string units;
double low;
double high;
};

View File

@@ -16,12 +16,13 @@
#include <pv/pvData.h>
#include <pv/pvAlarm.h>
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
String PVAlarm::noAlarmFound("No alarm structure found");
String PVAlarm::notAttached("Not attached to an alarm structure");
string PVAlarm::noAlarmFound("No alarm structure found");
string PVAlarm::notAttached("Not attached to an alarm structure");
bool PVAlarm::attach(PVFieldPtr const & pvField)
{

View File

@@ -37,8 +37,8 @@ private:
PVIntPtr pvSeverity;
PVIntPtr pvStatus;
PVStringPtr pvMessage;
static String noAlarmFound;
static String notAttached;
static std::string noAlarmFound;
static std::string notAttached;
};
}}

View File

@@ -19,9 +19,10 @@
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
using std::string;
String PVControl::noControlFound("No control structure found");
String PVControl::notAttached("Not attached to an control structure");
string PVControl::noControlFound("No control structure found");
string PVControl::notAttached("Not attached to an control structure");
bool PVControl::attach(PVFieldPtr const & pvField)
{
@@ -29,7 +30,7 @@ bool PVControl::attach(PVFieldPtr const & pvField)
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
pvLow = pvStructure->getDoubleField("limitLow");
if(pvLow.get()==NULL) return false;
pvHigh = pvStructure->getDoubleField(String("limitHigh"));
pvHigh = pvStructure->getDoubleField(string("limitHigh"));
if(pvHigh.get()==NULL) {
pvLow.reset();
return false;

View File

@@ -33,8 +33,8 @@ public:
private:
PVDoublePtr pvLow;
PVDoublePtr pvHigh;
static String noControlFound;
static String notAttached;
static std::string noControlFound;
static std::string notAttached;
};
}}

View File

@@ -16,12 +16,13 @@
#include <pv/pvData.h>
#include <pv/pvDisplay.h>
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
String PVDisplay::noDisplayFound("No display structure found");
String PVDisplay::notAttached("Not attached to an display structure");
string PVDisplay::noDisplayFound("No display structure found");
string PVDisplay::notAttached("Not attached to an display structure");
bool PVDisplay::attach(PVFieldPtr const & pvField)
{
@@ -39,12 +40,12 @@ bool PVDisplay::attach(PVFieldPtr const & pvField)
detach();
return false;
}
pvLow = pvStructure->getDoubleField(String("limitLow"));
pvLow = pvStructure->getDoubleField(string("limitLow"));
if(pvLow.get()==NULL) {
detach();
return false;
}
pvHigh = pvStructure->getDoubleField(String("limitHigh"));
pvHigh = pvStructure->getDoubleField(string("limitHigh"));
if(pvHigh.get()==NULL) {
detach();
return false;

View File

@@ -33,8 +33,8 @@ public:
void get(Display &) const;
bool set(Display const & display);
private:
static String noDisplayFound;
static String notAttached;
static std::string noDisplayFound;
static std::string notAttached;
PVStringPtr pvDescription;
PVStringPtr pvFormat;
PVStringPtr pvUnits;

View File

@@ -16,12 +16,13 @@
#include <pv/pvData.h>
#include <pv/pvEnumerated.h>
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
String PVEnumerated::notFound("No enumerated structure found");
String PVEnumerated::notAttached("Not attached to an enumerated structure");
string PVEnumerated::notFound("No enumerated structure found");
string PVEnumerated::notAttached("Not attached to an enumerated structure");
bool PVEnumerated::attach(PVFieldPtr const & pvField)
{
@@ -68,7 +69,7 @@ int32 PVEnumerated::getIndex()
return pvIndex->get();
}
String PVEnumerated::getChoice()
string PVEnumerated::getChoice()
{
if(pvIndex.get()==NULL ) {
throw std::logic_error(notAttached);

View File

@@ -33,14 +33,14 @@ public:
// a set returns false if field is immutable
bool setIndex(int32 index);
int32 getIndex();
String getChoice();
std::string getChoice();
bool choicesMutable();
inline PVStringArray::const_svector getChoices(){return pvChoices->view();}
int32 getNumberChoices();
bool setChoices(const StringArray & choices);
private:
static String notFound;
static String notAttached;
static std::string notFound;
static std::string notAttached;
PVIntPtr pvIndex;
PVStringArrayPtr pvChoices;
};

View File

@@ -16,12 +16,13 @@
#include <pv/pvData.h>
#include <pv/pvTimeStamp.h>
using std::tr1::static_pointer_cast;
using std::string;
namespace epics { namespace pvData {
using std::tr1::static_pointer_cast;
String PVTimeStamp::noTimeStamp("No timeStamp structure found");
String PVTimeStamp::notAttached("Not attached to a timeStamp structure");
string PVTimeStamp::noTimeStamp("No timeStamp structure found");
string PVTimeStamp::notAttached("Not attached to a timeStamp structure");
bool PVTimeStamp::attach(PVFieldPtr const & pvField)
{

View File

@@ -36,8 +36,8 @@ public:
void get(TimeStamp &) const;
bool set(TimeStamp const & timeStamp);
private:
static String noTimeStamp;
static String notAttached;
static std::string noTimeStamp;
static std::string notAttached;
PVLongPtr pvSecs;
PVIntPtr pvUserTag;
PVIntPtr pvNano;

View File

@@ -63,12 +63,12 @@ static inline bool operator!=(const UnionArray& a, const UnionArray& b)
* pvUByte, pvUShort, pvUInt, pvULong,
* pvFloat, or pvDouble.</p>
*
* <p>getString converts any supported type to a String.
* <p>getString converts any supported type to a std::string.
* Code that implements a PVField interface should implement
* method toString by calling this method.</p>
*
* <p>fromString converts a String to a scalar.
* fromStringArray converts an array of Strings
* <p>fromString converts a std::string to a scalar.
* fromStringArray converts an array of std::strings
* to a pvArray, which must have a scaler element type.
* A scalar field is a numeric field or pvBoolean or pvString.</p>
* <p>All from methods put data into a PVField, e.g. from means where the PVField gets it's data.</p>
@@ -85,7 +85,7 @@ public:
* @param builder The builder that will have the result.
* @param pvField The pvField.
*/
void getFullName(StringBuilder buf,PVFieldPtr const & pvField)
void getFullName(std::string *buf,PVFieldPtr const & pvField)
{
*buf = pvField->getFullName();
}
@@ -121,7 +121,7 @@ public:
* If a PVField is a structure or array be prepared for a very long string.
* @param indentLevel indentation level
*/
inline void getString(StringBuilder buf,PVFieldPtr const & pvField,int indentLevel)
inline void getString(std::string *buf,PVFieldPtr const & pvField,int indentLevel)
{getString(buf, pvField.get(), indentLevel);}
/**
* Convert a PVField to a string.
@@ -129,7 +129,7 @@ public:
* @param pv The PVField to convert to a string.
* If the PVField is a structure or array be prepared for a very long string.
*/
inline void getString(StringBuilder buf,PVFieldPtr const & pvField)
inline void getString(std::string * buf,PVFieldPtr const & pvField)
{getString(buf, pvField.get(), 0);}
/**
* Convert a PVField to a string.
@@ -138,49 +138,49 @@ public:
* If a PVField is a structure or array be prepared for a very long string.
* @param indentLevel indentation level
*/
void getString(StringBuilder buf,PVField const * pvField,int indentLevel);
void getString(std::string * buf,PVField const * pvField,int indentLevel);
/**
* Convert a PVField to a string.
* param buf buffer for the result
* @param pv The PVField to convert to a string.
* If the PVField is a structure or array be prepared for a very long string.
*/
inline void getString(StringBuilder buf,PVField const * pvField)
inline void getString(std::string * buf,PVField const * pvField)
{getString(buf, pvField, 0);}
/**
* Convert from an array of String to a PVScalar
* Convert from an array of std::string to a PVScalar
* @param pv The PV.
* @param from The array of String value to convert and put into a PV.
* @param from The array of std::string value to convert and put into a PV.
* @param fromStartIndex The first element if the array of strings.
* @throws std::logic_error if the array of String does not have a valid values.
* @throws std::logic_error if the array of std::string does not have a valid values.
*/
std::size_t fromString(
PVStructurePtr const &pv,
StringArray const & from,
std::size_t fromStartIndex = 0);
/**
* Convert from a String to a PVScalar
* Convert from a std::string to a PVScalar
* @param pv The PV.
* @param from The String value to convert and put into a PV.
* @throws std::logic_error if the String does not have a valid value.
* @param from The std::string value to convert and put into a PV.
* @throws std::logic_error if the std::string does not have a valid value.
*/
void fromString(PVScalarPtr const & pv, String const & from)
void fromString(PVScalarPtr const & pv, std::string const & from)
{
pv->putFrom<String>(from);
pv->putFrom<std::string>(from);
}
/**
* Convert from a String to a PVScalarArray.
* The String must be a comma separated set of values optionally enclosed in []
* Convert from a std::string to a PVScalarArray.
* The std::string must be a comma separated set of values optionally enclosed in []
* @param pv The PV.
* @param from The String value to convert and put into a PV.
* @param from The std::string value to convert and put into a PV.
* @return The number of elements converted.
* @throws std::invalid_argument if the element Type is not a scalar.
* @throws std::logic_error if the String does not have a valid array values.
* @throws std::logic_error if the std::string does not have a valid array values.
*/
std::size_t fromString(PVScalarArrayPtr const & pv, String from);
std::size_t fromString(PVScalarArrayPtr const & pv, std::string from);
/**
* Convert a PVScalarArray from a String array.
* Convert a PVScalarArray from a std::string array.
* The array element type must be a scalar.
* @param pv The PV.
* @param offset Starting element in a PV.
@@ -189,7 +189,7 @@ public:
* @param fromOffset Starting element in the source array.
* @return The number of elements converted.
* @throws std::invalid_argument if the element Type is not a scalar.
* @throws std::logic_error if the String does not have a valid value.
* @throws std::logic_error if the std::string does not have a valid value.
*/
std::size_t fromStringArray(
PVScalarArrayPtr const & pv,
@@ -197,11 +197,11 @@ public:
StringArray const & from,
std::size_t fromOffset);
/**
* Convert a PVScalarArray to a String array.
* Convert a PVScalarArray to a std::string array.
* @param pv The PV.
* @param offset Starting element in the PV array.
* @param length Number of elements to convert to the string array.
* @param to String array to receive the converted PV data.
* @param to std::string array to receive the converted PV data.
* @param toOffset Starting element in the string array.
* @return Number of elements converted.
*/
@@ -401,11 +401,11 @@ public:
*/
inline double toDouble(PVScalarPtr const & pv) { return pv->getAs<double>();}
/**
* Convert a PV to a String
* Convert a PV to a std::string
* @param pv a PV
* @return converted value
*/
inline String toString(PVScalarPtr const & pv) { return pv->getAs<String>();}
inline std::string toString(PVScalarPtr const & pv) { return pv->getAs<std::string>();}
/**
* Convert a PV from a byte
* @param pv a PV
@@ -480,10 +480,10 @@ public:
/**
* Convenience method for implementing toString.
* It generates a newline and inserts blanks at the beginning of the newline.
* @param builder The StringBuilder being constructed.
* @param builder The std::string * being constructed.
* @param indentLevel Indent level, Each level is four spaces.
*/
void newLine(StringBuilder buf, int indentLevel);
void newLine(std::string * buf, int indentLevel);
};
static inline ConvertPtr getConvert() { return Convert::getConvert(); }

View File

@@ -2,6 +2,7 @@
#define PRINTER_H
#include <ostream>
#include <shareLib.h>
#include "pvData.h"

View File

@@ -35,69 +35,6 @@ typedef class std::ios std::ios_base;
namespace epics { namespace pvData {
namespace format {
struct indent_level
{
long level;
indent_level(long l) : level(l) {}
};
inline long& indent_value(std::ios_base& ios)
{
static int indent_index = std::ios_base::xalloc();
return ios.iword(indent_index);
}
epicsShareExtern std::ostream& operator<<(std::ostream& os, indent_level const& indent);
struct indent_scope
{
long saved_level;
std::ios_base& stream;
indent_scope(std::ios_base& ios) :
stream(ios)
{
long& l = indent_value(ios);
saved_level = l;
l = saved_level + 1;
}
~indent_scope()
{
indent_value(stream) = saved_level;
}
};
struct indent
{
};
epicsShareExtern std::ostream& operator<<(std::ostream& os, indent const&);
struct array_at
{
std::size_t index;
array_at(std::size_t ix) : index(ix) {}
};
struct array_at_internal
{
std::size_t index;
std::ostream& stream;
array_at_internal(std::size_t ix, std::ostream& str) : index(ix), stream(str) {}
};
epicsShareExtern array_at_internal operator<<(std::ostream& str, array_at const& manip);
};
class PostHandler;
class PVField;
@@ -223,13 +160,13 @@ public:
* Get the fieldName for this field.
* @return The name or empty string if top level field.
*/
inline const String& getFieldName() const {return fieldName;}
inline const std::string& getFieldName() const {return fieldName;}
/**
* Fully expand the name of this field using the
* names of its parent fields with a dot '.' seperating
* each name.
*/
String getFullName() const;
std::string getFullName() const;
/**
* Get offset of the PVField field within top level structure.
* Every field within the PVStructure has a unique offset.
@@ -287,19 +224,6 @@ public:
* @return (false,true) if (is not,is) equal.
*/
virtual bool equals(PVField &pv);
/**
* Convert the PVField to a string.
* @param buf buffer for the result
*/
virtual void toString(StringBuilder buf) ;
/**
* Convert the PVField to a string.
* Each line is indented.
* @param buf buffer for the result
* @param indentLevel The indentation level.
*/
virtual void toString(StringBuilder buf,int indentLevel) ;
/**
* Puts the PVField raw value to the stream.
* @param o output stream.
@@ -307,19 +231,18 @@ public:
*/
virtual std::ostream& dumpValue(std::ostream& o) const = 0;
protected:
PVField::shared_pointer getPtrSelf()
{
return shared_from_this();
}
PVField(FieldConstPtr field);
void setParentAndName(PVStructure *parent, String const & fieldName);
void setParentAndName(PVStructure *parent, std::string const & fieldName);
private:
static void computeOffset(const PVField *pvField);
static void computeOffset(const PVField *pvField,std::size_t offset);
String notImplemented;
String fieldName;
std::string notImplemented;
std::string fieldName;
PVStructure *parent;
FieldConstPtr field;
size_t fieldOffset;
@@ -516,7 +439,7 @@ typedef std::tr1::shared_ptr<PVDouble> PVDoublePtr;
/**
* PVString is special case, since it implements SerializableArray
*/
class epicsShareClass PVString : public PVScalarValue<String>, SerializableArray {
class epicsShareClass PVString : public PVScalarValue<std::string>, SerializableArray {
public:
/**
* Destructor
@@ -524,7 +447,7 @@ public:
virtual ~PVString() {}
protected:
PVString(ScalarConstPtr const & scalar)
: PVScalarValue<String>(scalar) {}
: PVScalarValue<std::string>(scalar) {}
};
typedef std::tr1::shared_ptr<PVString> PVStringPtr;
@@ -709,10 +632,10 @@ public:
* @param fieldName The name of the field.
* @return Pointer to the field or null if field does not exist.
*/
PVFieldPtr getSubField(String const &fieldName) const;
PVFieldPtr getSubField(std::string const &fieldName) const;
template<typename PVT>
std::tr1::shared_ptr<PVT> getSubField(String const &fieldName) const
std::tr1::shared_ptr<PVT> getSubField(std::string const &fieldName) const
{
PVFieldPtr pvField = getSubField(fieldName);
if (pvField.get())
@@ -744,84 +667,84 @@ public:
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVBooleanPtr getBooleanField(String const &fieldName) ;
PVBooleanPtr getBooleanField(std::string const &fieldName) ;
/**
* Get a byte field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVBytePtr getByteField(String const &fieldName) ;
PVBytePtr getByteField(std::string const &fieldName) ;
/**
* Get a short field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVShortPtr getShortField(String const &fieldName) ;
PVShortPtr getShortField(std::string const &fieldName) ;
/**
* Get a int field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVIntPtr getIntField(String const &fieldName) ;
PVIntPtr getIntField(std::string const &fieldName) ;
/**
* Get a long field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVLongPtr getLongField(String const &fieldName) ;
PVLongPtr getLongField(std::string const &fieldName) ;
/**
* Get an unsigned byte field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVUBytePtr getUByteField(String const &fieldName) ;
PVUBytePtr getUByteField(std::string const &fieldName) ;
/**
* Get an unsigned short field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVUShortPtr getUShortField(String const &fieldName) ;
PVUShortPtr getUShortField(std::string const &fieldName) ;
/**
* Get an unsigned int field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVUIntPtr getUIntField(String const &fieldName) ;
PVUIntPtr getUIntField(std::string const &fieldName) ;
/**
* Get an unsigned long field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVULongPtr getULongField(String const &fieldName) ;
PVULongPtr getULongField(std::string const &fieldName) ;
/**
* Get a float field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVFloatPtr getFloatField(String const &fieldName) ;
PVFloatPtr getFloatField(std::string const &fieldName) ;
/**
* Get a double field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVDoublePtr getDoubleField(String const &fieldName) ;
PVDoublePtr getDoubleField(std::string const &fieldName) ;
/**
* Get a string field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVStringPtr getStringField(String const &fieldName) ;
PVStringPtr getStringField(std::string const &fieldName) ;
/**
* Get a structure field with the specified name.
@@ -829,14 +752,14 @@ public:
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVStructurePtr getStructureField(String const &fieldName) ;
PVStructurePtr getStructureField(std::string const &fieldName) ;
/**
* Get a union field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVUnionPtr getUnionField(String const &fieldName) ;
PVUnionPtr getUnionField(std::string const &fieldName) ;
/**
* Get a scalarArray field with the specified name.
* No longer needed. Use templete version of getSubField
@@ -845,21 +768,21 @@ public:
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVScalarArrayPtr getScalarArrayField(
String const &fieldName,ScalarType elementType) ;
std::string const &fieldName,ScalarType elementType) ;
/**
* Get a structureArray field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVStructureArrayPtr getStructureArrayField(String const &fieldName) ;
PVStructureArrayPtr getStructureArrayField(std::string const &fieldName) ;
/**
* Get a unionArray field with the specified name.
* No longer needed. Use templete version of getSubField
* @param fieldName The name of the field to get.
* @return Pointer to the field of null if a field with that name and type does not exist.
*/
PVUnionArrayPtr getUnionArrayField(String const &fieldName) ;
PVUnionArrayPtr getUnionArrayField(std::string const &fieldName) ;
/**
* Serialize.
* @param pbuffer The byte buffer.
@@ -926,7 +849,7 @@ private:
PVFieldPtrArray pvFields;
StructureConstPtr structurePtr;
String extendsStructureName;
std::string extendsStructureName;
friend class PVDataCreate;
};
@@ -988,10 +911,10 @@ public:
* @return corresponding PVField (of undetermined value).
* @throws {@code std::invalid_argument} if field does not exist.
*/
PVFieldPtr select(String const & fieldName);
PVFieldPtr select(std::string const & fieldName);
template<typename PVT>
std::tr1::shared_ptr<PVT> select(String const & fieldName) {
std::tr1::shared_ptr<PVT> select(std::string const & fieldName) {
return std::tr1::dynamic_pointer_cast<PVT>(select(fieldName));
}
@@ -1005,7 +928,7 @@ public:
* Get selected field name.
* @return selected field name, empty string if field does not exist.
*/
String getSelectedFieldName() const;
std::string getSelectedFieldName() const;
/**
* Set the {@code PVField} (by reference!) as selected field.
@@ -1025,12 +948,12 @@ public:
/**
* Set the {@code PVField} (by reference!) as field by given name.
* If a value is not a valid union field an {@code std::invalid_argument} exception is thrown.
* Use {@code select(String)} to put by value.
* Use {@code select(std::string)} to put by value.
* @param fieldName Name of the field to put.
* @param value the field to set.
* @see #select(String)
* @see #select(std::string)
*/
void set(String const & fieldName, PVFieldPtr const & value);
void set(std::string const & fieldName, PVFieldPtr const & value);
/**
* Serialize.
@@ -1429,7 +1352,7 @@ typedef std::tr1::shared_ptr<PVFloatArray> PVFloatArrayPtr;
typedef PVValueArray<double> PVDoubleArray;
typedef std::tr1::shared_ptr<PVDoubleArray> PVDoubleArrayPtr;
typedef PVValueArray<String> PVStringArray;
typedef PVValueArray<std::string> PVStringArray;
typedef std::tr1::shared_ptr<PVStringArray> PVStringArrayPtr;
/**

View File

@@ -12,6 +12,7 @@
#include <string>
#include <stdexcept>
#include <iostream>
#include <pv/noDefaultMethods.h>
#include <pv/pvType.h>
@@ -22,6 +23,67 @@
namespace epics { namespace pvData {
namespace format {
struct indent_level
{
long level;
indent_level(long l) : level(l) {}
};
inline long& indent_value(std::ios_base& ios)
{
static int indent_index = std::ios_base::xalloc();
return ios.iword(indent_index);
}
epicsShareExtern std::ostream& operator<<(std::ostream& os, indent_level const& indent);
struct indent_scope
{
long saved_level;
std::ios_base& stream;
indent_scope(std::ios_base& ios) :
stream(ios)
{
long& l = indent_value(ios);
saved_level = l;
l = saved_level + 1;
}
~indent_scope()
{
indent_value(stream) = saved_level;
}
};
struct indent
{
};
epicsShareExtern std::ostream& operator<<(std::ostream& os, indent const&);
struct array_at
{
std::size_t index;
array_at(std::size_t ix) : index(ix) {}
};
struct array_at_internal
{
std::size_t index;
std::ostream& stream;
array_at_internal(std::size_t ix, std::ostream& str) : index(ix), stream(str) {}
};
epicsShareExtern array_at_internal operator<<(std::ostream& str, array_at const& manip);
};
class Field;
class Scalar;
class Array;
@@ -108,14 +170,11 @@ namespace TypeFunc {
* @return The name for the type.
*/
epicsShareExtern const char* name(Type type);
/**
* Convert the type to a string and add it to builder.
* @param builder The string builder.
* @param type The type.
*/
epicsShareExtern void toString(StringBuilder builder,const Type type);
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const Type& type);
/**
* Definition of support scalar types.
*/
@@ -206,24 +265,21 @@ namespace ScalarTypeFunc {
* @return The scalarType.
* An exception is thrown if the name is not the name of a scalar type.
*/
epicsShareExtern ScalarType getScalarType(String const &value);
epicsShareExtern ScalarType getScalarType(std::string const &value);
/**
* Get a name for the scalarType.
* @param scalarType The type.
* @return The name for the scalarType.
*/
epicsShareExtern const char* name(ScalarType scalarType);
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* @param scalarType The type.
*/
epicsShareExtern void toString(StringBuilder builder,ScalarType scalarType);
//! gives sizeof(T) where T depends on the scalar type id.
epicsShareExtern size_t elementSize(ScalarType id);
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const ScalarType& scalarType);
/**
* This class implements introspection object for field.
*/
@@ -245,18 +301,15 @@ public:
* Get the identification string.
* @return The identification string, can be empty.
*/
virtual String getID() const = 0;
virtual std::string getID() const = 0;
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* Puts the string representation to the stream.
* @param o output stream.
* @return The output stream.
*/
virtual void toString(StringBuilder builder) const{toString(builder,0);}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder builder,int indentLevel) const;
virtual std::ostream& dump(std::ostream& o) const = 0;
protected:
/**
* Constructor
@@ -276,6 +329,8 @@ private:
struct Deleter{void operator()(Field *p){delete p;}};
};
epicsShareExtern std::ostream& operator<<(std::ostream& o, const Field& field);
/**
* This class implements introspection object for Scalar.
@@ -294,19 +349,10 @@ public:
* @return the scalarType
*/
ScalarType getScalarType() const {return scalarType;}
/**
* Convert the scalar to a string and add it to builder.
* @param builder The string builder.
*/
virtual void toString(StringBuilder buf) const{toString(buf,0);}
/**
* Convert the scalar to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual std::string getID() const;
virtual String getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -367,19 +413,10 @@ public:
* @return the scalarType
*/
ScalarType getElementType() const {return elementType;}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
*/
virtual void toString(StringBuilder buf) const{toString(buf,0);}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -391,7 +428,7 @@ protected:
virtual ~ScalarArray();
private:
int8 getTypeCodeLUT() const;
const String getIDScalarArrayLUT() const;
const std::string getIDScalarArrayLUT() const;
ScalarType elementType;
friend class FieldCreate;
};
@@ -411,14 +448,9 @@ public:
*/
StructureConstPtr getStructure() const {return pstructure;}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -453,14 +485,9 @@ public:
*/
UnionConstPtr getUnion() const {return punion;}
/**
* Convert the scalarType to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -490,7 +517,7 @@ public:
/**
* Default structure ID.
*/
static epics::pvData::String DEFAULT_ID;
static std::string DEFAULT_ID;
/**
* Destructor.
@@ -510,7 +537,7 @@ public:
* @return The introspection interface.
* This will hold a null pointer if the field is not in the structure.
*/
FieldConstPtr getField(String const &fieldName) const;
FieldConstPtr getField(std::string const &fieldName) const;
/**
* Get the field for the specified fieldName.
* @param fieldName The index of the field to get;
@@ -523,7 +550,7 @@ public:
* @return The introspection interface.
* This will be -1 if the field is not in the structure.
*/
std::size_t getFieldIndex(String const &fieldName) const;
std::size_t getFieldIndex(std::string const &fieldName) const;
/**
* Get the fields in the structure.
* @return The array of fields.
@@ -539,33 +566,26 @@ public:
* @param fieldIndex The index of the desired field.
* @return The fieldName.
*/
String getFieldName(std::size_t fieldIndex) const {return fieldNames[fieldIndex];}
/**
* Convert the structure to a string and add it to builder.
* @param builder The string builder.
*/
virtual void toString(StringBuilder buf) const{toString(buf,0);}
/**
* Convert the structure to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
std::string getFieldName(std::size_t fieldIndex) const {return fieldNames[fieldIndex];}
virtual std::string getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
protected:
Structure(StringArray const & fieldNames, FieldConstPtrArray const & fields, String const & id = DEFAULT_ID);
Structure(StringArray const & fieldNames, FieldConstPtrArray const & fields, std::string const & id = DEFAULT_ID);
private:
void toStringCommon(StringBuilder buf,int indentLevel) const;
StringArray fieldNames;
FieldConstPtrArray fields;
String id;
friend class FieldCreate;
friend class Union;
std::string id;
virtual void dumpFields(std::ostream& o) const;
friend class FieldCreate;
friend class Union;
};
/**
@@ -578,12 +598,12 @@ public:
/**
* Default union ID.
*/
static epics::pvData::String DEFAULT_ID;
static std::string DEFAULT_ID;
/**
* Default variant union ID.
*/
static epics::pvData::String ANY_ID;
static std::string ANY_ID;
/**
* Destructor.
@@ -603,7 +623,7 @@ public:
* @return The introspection interface.
* This will hold a null pointer if the field is not in the union.
*/
FieldConstPtr getField(String const &fieldName) const;
FieldConstPtr getField(std::string const &fieldName) const;
/**
* Get the field for the specified fieldName.
* @param fieldName The index of the field to get;
@@ -616,7 +636,7 @@ public:
* @return The introspection interface.
* This will be -1 if the field is not in the union.
*/
std::size_t getFieldIndex(String const &fieldName) const;
std::size_t getFieldIndex(std::string const &fieldName) const;
/**
* Get the fields in the union.
* @return The array of fields.
@@ -632,37 +652,30 @@ public:
* @param fieldIndex The index of the desired field.
* @return The fieldName.
*/
String getFieldName(std::size_t fieldIndex) const {return fieldNames[fieldIndex];}
std::string getFieldName(std::size_t fieldIndex) const {return fieldNames[fieldIndex];}
/**
* Check if this union is variant union (aka any type).
* @return <code>true</code> if this union is variant union, otherwise <code>false</code>.
*/
bool isVariant() const {return (fieldNames.size() == 0);}
/**
* Convert the union to a string and add it to builder.
* @param builder The string builder.
*/
virtual void toString(StringBuilder buf) const{toString(buf,0);}
/**
* Convert the union to a string and add it to builder.
* @param builder The string builder.
* @param indentLevel The number of blanks at the beginning of new lines.
*/
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual std::ostream& dump(std::ostream& o) const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
protected:
Union();
Union(StringArray const & fieldNames, FieldConstPtrArray const & fields, String const & id = DEFAULT_ID);
Union(StringArray const & fieldNames, FieldConstPtrArray const & fields, std::string const & id = DEFAULT_ID);
private:
void toStringCommon(StringBuilder buf,int indentLevel) const;
StringArray fieldNames;
FieldConstPtrArray fields;
String id;
StringArray fieldNames;
FieldConstPtrArray fields;
std::string id;
virtual void dumpFields(std::ostream& o) const;
friend class FieldCreate;
friend class Structure;
};
@@ -778,8 +791,8 @@ public:
/**
* Complete the creation of a nested object.
* @see #addNestedStructure(String)
* @see #addNestedUnion(String)
* @see #addNestedStructure(std::string)
* @see #addNestedUnion(std::string)
* @return a previous (parent) {@code FieldBuilder}.
*/
FieldBuilderPtr endNested();
@@ -864,7 +877,7 @@ public:
* @return a {@code Structure} interface for the newly created object.
*/
StructureConstPtr createStructure (
String const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**
@@ -901,7 +914,7 @@ public:
* @return a {@code Union} interface for the newly created object.
*/
UnionConstPtr createUnion (
String const & id,
std::string const & id,
StringArray const & fieldNames,
FieldConstPtrArray const & fields) const;
/**
@@ -913,7 +926,7 @@ public:
*/
StructureConstPtr appendField(
StructureConstPtr const & structure,
String const & fieldName, FieldConstPtr const & field) const;
std::string const & fieldName, FieldConstPtr const & field) const;
/**
* Append fields to a structure.
* @param structure The structure to which the fields appended.
@@ -986,8 +999,27 @@ OP(pvUInt, uint32)
OP(pvULong, uint64)
OP(pvFloat, float)
OP(pvDouble, double)
OP(pvString, String)
OP(pvString, std::string)
#undef OP
struct ScalarHashFunction {
size_t operator() (const Scalar& scalar) const { return scalar.getScalarType(); }
};
struct ScalarArrayHashFunction {
size_t operator() (const ScalarArray& scalarArray) const { return 0x10 | scalarArray.getElementType(); }
};
struct StructureHashFunction {
size_t operator() (const Structure& /*structure*/) const { return 0; }
// TODO hash
// final int PRIME = 31;
// return PRIME * Arrays.hashCode(fieldNames) + Arrays.hashCode(fields);
};
struct StructureArrayHashFunction {
size_t operator() (const StructureArray& structureArray) const { StructureHashFunction shf; return (0x10 | shf(*(structureArray.getStructure()))); }
};
}}
#endif /* PVINTROSPECT_H */

View File

@@ -93,29 +93,24 @@ typedef uint64_t uint64;
// float and double are types
/**
* A string
*/
typedef std::string String;
/**
* A string array.
*/
typedef std::vector<String> StringArray;
typedef std::vector<std::string> StringArray;
typedef std::tr1::shared_ptr<StringArray> StringArrayPtr;
inline String * get(StringArray &value)
inline std::string * get(StringArray &value)
{
return &value[0];
}
inline String const * get(StringArray const &value)
inline std::string const * get(StringArray const &value)
{
return static_cast<String const *>(&value[0]);
return static_cast<std::string const *>(&value[0]);
}
inline String * get(StringArrayPtr &value)
inline std::string * get(StringArrayPtr &value)
{
return get(*value.get());
}
inline String const * get(StringArrayPtr const &value)
inline std::string const * get(StringArrayPtr const &value)
{
return get(*value.get());
}
@@ -127,13 +122,8 @@ inline StringArray const & getVector(StringArrayPtr const &value)
{
return *value.get();
}
typedef std::vector<String>::iterator StringArray_iterator;
typedef std::vector<String>::const_iterator StringArray_const_iterator;
/**
* A convenience definition for toString methods
*/
typedef String * StringBuilder;
typedef std::vector<std::string>::iterator StringArray_iterator;
typedef std::vector<std::string>::const_iterator StringArray_const_iterator;
}}
#endif /* PVTYPE_H */

View File

@@ -38,9 +38,9 @@ typedef std::tr1::shared_ptr<StandardField> StandardFieldPtr;
* For example the call:
* {@code
StructureConstPtr example = standardField->scalar(
String("value"),
std::string("value"),
pvDouble,
String("value,alarm,timeStamp"));
std::string("value,alarm,timeStamp"));
* }
* Will result in a Field definition that has the form: {@code
structure example
@@ -75,7 +75,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
StructureConstPtr scalar(ScalarType type,String const & properties);
StructureConstPtr scalar(ScalarType type,std::string const & properties);
/** Create a structure that has a union value field.
* @param punion The interface for value field.
* @param properties A comma separated list of properties.
@@ -84,20 +84,20 @@ public:
*/
StructureConstPtr regUnion(
UnionConstPtr const & punion,
String const & properties);
std::string const & properties);
/** Create a structure that has a varient union value field.
* @param properties A comma separated list of properties.
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
StructureConstPtr variantUnion(String const & properties);
StructureConstPtr variantUnion(std::string const & properties);
/** Create a structure that has a scalarArray value field.
* @param type The type.
* @param properties A comma separated list of properties.
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
StructureConstPtr scalarArray(ScalarType elementType, String const & properties);
StructureConstPtr scalarArray(ScalarType elementType, std::string const & properties);
/** Create a structure that has a structureArray value field.
* @param type The type.
* @param properties A comma separated list of properties.
@@ -106,7 +106,7 @@ public:
*/
StructureConstPtr structureArray(
StructureConstPtr const & structure,
String const & properties);
std::string const & properties);
/** Create a structure that has a unionArray value field.
* @param type The type.
* @param properties A comma separated list of properties.
@@ -115,7 +115,7 @@ public:
*/
StructureConstPtr unionArray(
UnionConstPtr const & punion,
String const & properties);
std::string const & properties);
/** Create a structure that has an enumerated structure value field.
* The id for the structure is "enum-t".
* @return The const shared pointer to the structure.
@@ -127,7 +127,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
StructureConstPtr enumerated(String const & properties);
StructureConstPtr enumerated(std::string const & properties);
/**
* create an alarm structure
* @return The const shared pointer to the structure.
@@ -212,10 +212,10 @@ private:
StandardField();
void init();
StructureConstPtr createProperties(
String id,FieldConstPtr field,String properties);
std::string id,FieldConstPtr field,std::string properties);
FieldCreatePtr fieldCreate;
String notImplemented;
String valueFieldName;
std::string notImplemented;
std::string valueFieldName;
StructureConstPtr alarmField;
StructureConstPtr timeStampField;
StructureConstPtr displayField;

View File

@@ -50,7 +50,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
PVStructurePtr scalar(ScalarType type,String const & properties);
PVStructurePtr scalar(ScalarType type,std::string const & properties);
/**
* Create a structure that has a scalar array value field.
* @param type The type.
@@ -58,7 +58,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
PVStructurePtr scalarArray(ScalarType elementType, String const & properties);
PVStructurePtr scalarArray(ScalarType elementType, std::string const & properties);
/**
* Create a structure that has a structure array value field.
* @param type The type.
@@ -66,7 +66,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
PVStructurePtr structureArray(StructureConstPtr const &structure,String const & properties);
PVStructurePtr structureArray(StructureConstPtr const &structure,std::string const & properties);
/**
* Create a structure that has a union array value field.
* @param type The type.
@@ -74,7 +74,7 @@ public:
* This is some combination of "alarm,timeStamp,display,control,valueAlarm".
* @return The const shared pointer to the structure.
*/
PVStructurePtr unionArray(UnionConstPtr const &punion,String const & properties);
PVStructurePtr unionArray(UnionConstPtr const &punion,std::string const & properties);
/**
* Create a structure that has an enumerated structure value field.
* The id for the structure is "enum_t".
@@ -89,13 +89,13 @@ public:
* @param properties A comma separated list of properties.
* @return The const shared pointer to the structure.
*/
PVStructurePtr enumerated(StringArray const &choices, String const & properties);
PVStructurePtr enumerated(StringArray const &choices, std::string const & properties);
private:
StandardPVField();
StandardFieldPtr standardField;
FieldCreatePtr fieldCreate;
PVDataCreatePtr pvDataCreate;
String notImplemented;
std::string notImplemented;
};
epicsShareExtern StandardPVFieldPtr getStandardPVField();