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

@@ -113,8 +113,8 @@ then passes it to pvCopy.
class CreateRequest {
...
static CreateRequestPtr create();
virtual PVStructurePtr createRequest(String const &request);
String getMessage();
virtual PVStructurePtr createRequest(std::string const &request);
std::string getMessage();
};
</pre>
<p>An example of how it is used is:</p>
@@ -122,7 +122,7 @@ class CreateRequest {
CreateRequestPtr createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest-&gt;createRequest(request);
if(pvRequest==NULL) {
String error = createRequest-&gt;getMessage();
std::string error = createRequest-&gt;getMessage();
// take some action
} else {
//success do something
@@ -143,7 +143,7 @@ class class epicsShareClass PVCopy
static PVCopyPtr create(
PVStructurePtr const &amp;pvMaster,
PVStructurePtr const &amp;pvRequest,
String const &amp; structureName);
std::string const &amp; structureName);
PVStructurePtr getPVMaster();
void traverseMaster(PVCopyTraverseMasterCallbackPtr const &amp; callback);
StructureConstPtr getStructure();
@@ -216,7 +216,7 @@ where
<dt>getCopyOffset</dt>
<dd>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.
Two overloaded methods are provided. The first is called if
the field of master is not a structure. The second is for
subfields of a structure.
@@ -387,7 +387,7 @@ It has the methods:</p>
<pre>
class MonitorPlugin
{
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
virtual bool causeMonitor(
PVFieldPtr const &amp;pvField,
PVStructurePtr const &amp;pvTop,
@@ -406,16 +406,16 @@ class MonitorPluginCreator
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,
PVStructurePtr const &amp;pvFieldOptions) = 0;
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
}
class MonitorPluginManager
{
static MonitorPluginManagerPtr get();
bool addPlugin(
String const &amp;pluginName,
std::string const &amp;pluginName,
MonitorPluginCreatorPtr const &amp;creator);
MonitorPluginCreatorPtr findPlugin(String const &amp;pluginName);
MonitorPluginCreatorPtr findPlugin(std::string const &amp;pluginName);
void showNames();
};
@@ -587,7 +587,7 @@ will be passed to the client.
Assume that the client has already connected to the channel.
The client can then issue the commands:</p>
<pre>
String request("field(alarm[plugin=onChange]");
std::string request("field(alarm[plugin=onChange]");
request += ",timeStamp[plugin=onChange,raiseMonitor=false]";
request += ",power.value[plugin=onChange";
request += ",voltage.value[plugin=onChange";
@@ -623,13 +623,13 @@ public:
PVStringPtr pvString =
pvFieldOptions-&gt;getSubField&lt;PVString&gt;("raiseMonitor");
if(pvString!=NULL) {
String value = pvString-&gt;get();
std::string value = pvString-&gt;get();
if(value.compare("false")==0) raiseMonitor = false;
}
}
return true;
}
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual bool causeMonitor(
PVFieldPtr const &amp;pvNew,
PVStructurePtr const &amp;pvTop,
@@ -647,7 +647,7 @@ private:
class OnChangePluginCreator : public MonitorPluginCreator
{
public:
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual MonitorPluginPtr create(
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,

View File

@@ -170,7 +170,7 @@ the dumpValue method is replaced by the stream operator&lt;&lt;.
</p>
<h4>Java</h4>
<pre>interface PVField extends Requester, Serializable {
String getFieldName();
std::string getFieldName();
void setRequester(Requester requester);
int getFieldOffset();
int getNextFieldOffset();
@@ -180,12 +180,12 @@ the dumpValue method is replaced by the stream operator&lt;&lt;.
void setImmutable();
Field getField();
PVStructure getParent();
void renameField(String newName);
void renameField(std::string newName);
void postPut(); // calls PVRecordField.postPut if this is a field of a record
void setPostHandler(PostHandler postHandler);
void toString(StringBuilder buf);
void toString(StringBuilder buf,int indentLevel);
String toString();
std::string toString();
}</pre>
<h4>pvDataCPP</h4>
<pre>class PVField
@@ -195,8 +195,8 @@ the dumpValue method is replaced by the stream operator&lt;&lt;.
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
virtual void message(String message,MessageType messageType);
String getFieldName() const ;
virtual void message(std::string message,MessageType messageType);
std::string getFieldName() const ;
virtual void setRequester(RequesterPtr const &amp;prequester);
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
@@ -207,7 +207,7 @@ public:
const FieldConstPtr &amp; getField() const ;
PVStructure * getParent() const
void replacePVField(const PVFieldPtr&amp; newPVField);
void renameField(String const &amp;newName);
void renameField(std::string const &amp;newName);
void postPut() ;
void setPostHandler(PostHandlerPtr const &amp;postHandler);
virtual bool equals(PVField &amp;pv);
@@ -227,8 +227,8 @@ std::ostream&amp; operator&lt;&lt;(std::ostream&amp; o, const PVFieldPtr &amp; f
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
virtual void message(String message,MessageType messageType);
String getFieldName() const ;
virtual void message(std::string message,MessageType messageType);
std::string getFieldName() const ;
virtual void setRequester(RequesterPtr const &amp;prequester);
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
@@ -239,7 +239,7 @@ public:
const FieldConstPtr &amp; getField() const ;
PVStructure * getParent() const
void replacePVField(const PVFieldPtr&amp; newPVField);
void renameField(String const &amp;newName);
void renameField(std::string const &amp;newName);
void postPut() ;
void setPostHandler(PostHandlerPtr const &amp;postHandler);
virtual bool equals(PVField &amp;pv);
@@ -247,7 +247,7 @@ public:
virtual void toString(StringBuilder buf,int indentLevel);
std::ostream&amp; dumpValue(std::ostream&amp; o) const;
// not in pvDataCPP
String getFullName() const;
std::string getFullName() const;
...
}
@@ -262,8 +262,8 @@ class PVField
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
virtual void message(String message,MessageType messageType);
const String&amp; getFieldName() const;
virtual void message(std::string message,MessageType messageType);
const std::string&amp; getFieldName() const;
virtual void setRequester(RequesterPtr const &amp;prequester);
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
@@ -274,7 +274,7 @@ public:
const FieldConstPtr &amp; getField() const;
PVStructure * getParent() const;
void replacePVField(const PVFieldPtr&amp; newPVField);
void renameField(String const &amp; newName);
void renameField(std::string const &amp; newName);
void postPut();
void setPostHandler(PostHandlerPtr const &amp;postHandler);
virtual bool equals(PVField &amp;pv);
@@ -328,8 +328,8 @@ interface PVDouble extends PVScalar {
void put(double value);
}
interface PVString extends PVScalar, SerializableArray {
String get();
void put(String value);
std::string get();
void put(std::string value);
}
</pre>
<h4>pvDataCPP</h4>
@@ -369,7 +369,7 @@ typedef std::tr1::shared_ptr<PVDouble> PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -427,7 +427,7 @@ typedef std::tr1::shared_ptr<PVDouble> PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -472,7 +472,7 @@ typedef std::tr1::shared_ptr&lt;PVByte&gt; PVBytePtr;
typedef std::tr1::shared_ptr&lt;PVDouble&gt; PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -641,8 +641,8 @@ typedef PVArrayData&lt;uint8&gt; BooleanArrayData;
typedef PVValueArray&lt;uint8&gt; PVBooleanArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
...
typedef PVArrayData&lt;String&gt; StringArrayData;
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVArrayData&lt;std::string&gt; StringArrayData;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVStringArray&gt; PVStringArrayPtr;i
</pre>
@@ -786,8 +786,8 @@ typedef PVArrayData&lt;uint8&gt; BooleanArrayData;
typedef PVValueArray&lt;uint8&gt; PVBooleanArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
...
typedef PVArrayData&lt;String&gt; StringArrayData;
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVArrayData&lt;std::string&gt; StringArrayData;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVStringArray&gt; PVStringArrayPtr;i
</pre>
<h4>proposed</h4>
@@ -843,7 +843,7 @@ public:
typedef PVValueArray&lt;uint8&gt; PVBooleanArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
...
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVStringArray&gt; PVStringArrayPtr;
</pre>
@@ -865,8 +865,8 @@ class PVField
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
virtual void message(String message,MessageType messageType);
const String&amp; getFieldName() const;
virtual void message(std::string message,MessageType messageType);
const std::string&amp; getFieldName() const;
virtual void setRequester(RequesterPtr const &amp;prequester);
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
@@ -877,7 +877,7 @@ public:
const FieldConstPtr &amp; getField() const;
PVStructure * getParent() const;
void replacePVField(const PVFieldPtr&amp; newPVField);
void renameField(String const &amp; newName);
void renameField(std::string const &amp; newName);
void postPut();
void setPostHandler(PostHandlerPtr const &amp;postHandler);
virtual bool equals(PVField &amp;pv);
@@ -1006,7 +1006,7 @@ typedef std::tr1::shared_ptr&lt;PVFloat&gt; PVFloatPtr;
typedef std::tr1::shared_ptr&lt;PVDouble&gt; PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -1144,7 +1144,7 @@ typedef std::tr1::shared_ptr&lt;PVFloatArray&gt; PVFloatArrayPtr;
typedef PVValueArray&lt;double&gt; PVDoubleArray;
typedef std::tr1::shared_ptr&lt;PVDoubleArray&gt; PVDoubleArrayPtr;
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVStringArray&gt; PVStringArrayPtr;
</pre>
@@ -1231,7 +1231,7 @@ For others the brief summary is followed by tutorial information.
<pre>
typedef shared_vector&lt;int32&gt; Int32Array;
...
static void dumpArray(String const &amp;message,Int32Array const&amp; int32Array);
static void dumpArray(std::string const &amp;message,Int32Array const&amp; int32Array);
</pre>
<p>The following:
<pre>

View File

@@ -145,7 +145,7 @@ After it is unzipped just edit configure/RELEASE.local and then execute make.
</p>
<p>The examples assume that the following statements have been issued:</p>
<pre>
String builder;
std::string builder;
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StandardFieldPtr standardField = getStandardField();
@@ -876,21 +876,21 @@ typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
// float and double are types
typedef std::string String;
typedef std::string std::string;
typedef std::vector<String> StringArray;
typedef std::vector<std::string> StringArray;
typedef std::tr1::shared_ptr<StringArray> StringArrayPtr;
inline String * get(StringArray &amp;value);
inline String const * get(StringArray const &amp;value);
inline String * get(StringArrayPtr &amp;value);
inline String const * get(StringArrayPtr const &amp;value);
inline std::string * get(StringArray &amp;value);
inline std::string const * get(StringArray const &amp;value);
inline std::string * get(StringArrayPtr &amp;value);
inline std::string const * get(StringArrayPtr const &amp;value);
}
inline StringArray &amp; getVector(StringArrayPtr &value);
inline StringArray const &amp; getVector(StringArrayPtr const &value);
typedef std::vector<String>::iterator StringArray_iterator;
typedef std::vector<String>::const_iterator StringArray_const_iterator;
typedef std::vector<std::string>::iterator StringArray_iterator;
typedef std::vector<std::string>::const_iterator StringArray_const_iterator;
typedef String * StringBuilder;
typedef std::string * StringBuilder;
</pre>
<p>where</p>
@@ -905,7 +905,7 @@ typedef String * StringBuilder;
have worked on all C++ implementations tested at present. If they break
in a future implementation they should be changes via "#ifdef"
preprocessor statements.</dd>
<dt>String</dt>
<dt>std::string</dt>
<dd>pvData requires that a string be an immutable string that is transfered
over the network as a UTF8 encoded string. Since std::string implements
copy on write semantics, it can be used for support for immutable
@@ -914,8 +914,8 @@ typedef String * StringBuilder;
is the same convention the Java implementation uses.
Note that string is treated like a primitive type.</dd>
<dt>StringArray definitions</dt>
<dd>typedefs are provided for an array of Strings,
which is a std::vector&lt;String&gt;.
<dd>typedefs are provided for an array of std::strings,
which is a std::vector&lt;std::string&gt;.
This is used by introspection.
</dd>
<dt>StringBuilder</dt>
@@ -993,7 +993,7 @@ public:
bool isUInteger(ScalarType type);
bool isNumeric(ScalarType type);
bool isPrimitive(ScalarType type);
ScalarType getScalarType(String const &amp;value);
ScalarType getScalarType(std::string const &amp;value);
const char* name(ScalarType);
void toString(StringBuilder buf,ScalarType scalarType);
size_t elementSize(ScalarType id);
@@ -1072,7 +1072,7 @@ public:
<dt>name</dt>
<dd>Returns the name of the scalarType.</dd>
<dt>getScalarType</dt>
<dd>Given a string of the form String("boolean"),...,String("string")
<dd>Given a string of the form std::string("boolean"),...,std::string("string")
return the scalarType.</dd>
<dt>toString</dt>
<dd>Convert the scalar type to a string.</dd>
@@ -1158,7 +1158,7 @@ public:
POINTER_DEFINITIONS(Field);
virtual ~Field();
Type getType() const{return m_type;}
virtual String getID() const = 0;
virtual std::string getID() const = 0;
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
...
@@ -1174,7 +1174,7 @@ public:
ScalarType getScalarType() const {return scalarType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableContol *control);
...
@@ -1190,7 +1190,7 @@ public:
ScalarType getElementType() const {return elementType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1204,7 +1204,7 @@ public:
StructureConstPtr getStructure() const {return pstructure;}
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1217,14 +1217,14 @@ public:
typedef const Structure&amp; const_reference;
std::size_t getNumberFields() const {return numberFields;}
FieldConstPtr getField(String const &amp; fieldName) const;
FieldConstPtr getField(std::string const &amp; fieldName) const;
FieldConstPtr getField(std::size_t index) const;
std::size_t getFieldIndex(String const &amp;fieldName) const;
std::size_t getFieldIndex(std::string const &amp;fieldName) const;
FieldConstPtrArray const &amp; getFields() const {return fields;}
StringArray const &amp; getFieldNames() const;
String getFieldName(std::size_t fieldIndex) const;
std::string getFieldName(std::size_t fieldIndex) const;
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1233,23 +1233,23 @@ public:
class epicsShareClass Union : public Field {
public:
POINTER_DEFINITIONS(Union);
static epics::pvData::String DEFAULT_ID;
static epics::pvData::String ANY_ID;
static std::string DEFAULT_ID;
static std::string ANY_ID;
virtual ~Union();
typedef Union&amp; reference;
typedef const Union&amp; const_reference;
std::size_t getNumberFields() const;
FieldConstPtr getField(String const &amp;fieldName) const;
FieldConstPtr getField(std::string const &amp;fieldName) const;
FieldConstPtr getField(std::size_t index);
std::size_t getFieldIndex(String const &amp;fieldName) const;
std::size_t getFieldIndex(std::string const &amp;fieldName) const;
FieldConstPtrArray const &amp; getFields() const;
StringArray const &amp; getFieldNames() const;
String getFieldName(std::size_t fieldIndex) const;
std::string getFieldName(std::size_t fieldIndex) const;
bool isVariant() const;
virtual void toString(StringBuilder buf) const;
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(
ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(
@@ -1265,7 +1265,7 @@ public:
UnionConstPtr getUnion() const {return punion;}
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -1395,14 +1395,14 @@ public:
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
StructureConstPtr createStructure (
String const &amp; id,
std::string const &amp; id,
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createUnion (
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createUnion (
String const &amp; id,
std::string const &amp; id,
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createVariantUnion() const;
@@ -1410,7 +1410,7 @@ public:
UnionArrayConstPtr createUnionArray(UnionConstPtr const &amp; punion) const;
StructureConstPtr appendField(
StructureConstPtr const &amp; structure,
String const &amp; fieldName, FieldConstPtr const &amp; field) const;
std::string const &amp; fieldName, FieldConstPtr const &amp; field) const;
StructureConstPtr appendFields(
StructureConstPtr const &amp; structure,
StringArray const &amp; fieldNames,
@@ -1480,7 +1480,7 @@ StructureConstPtr structure =
add("index", pvDouble)-&gt;
addArray("choices", pvString)-&gt;
createStructure();
String builder;
std::string builder;
structure-&gt;toString(&amp;builder);
cout &lt;&lt; builder &lt;&lt; endl;
</pre>
@@ -1698,18 +1698,18 @@ class StandardField {
public:
static StandardFieldPtr getStandardField();
~StandardField();
StructureConstPtr scalar(ScalarType type,String const &amp;properties);
StructureConstPtr scalar(ScalarType type,std::string const &amp;properties);
StructureConstPtr regUnion(
UnionConstPtr const &amp; punion,
String const &amp; properties);
StructureConstPtr variantUnion(String const &amp; properties);
std::string const &amp; properties);
StructureConstPtr variantUnion(std::string const &amp; properties);
StructureConstPtr scalarArray(
ScalarType elementType, String const &amp;properties);
ScalarType elementType, std::string const &amp;properties);
StructureConstPtr structureArray(
StructureConstPtr const &amp; structure,String const &amp;properties);
StructureConstPtr unionArray(UnionConstPtr const &amp; punion,String const &amp; properties);
StructureConstPtr const &amp; structure,std::string const &amp;properties);
StructureConstPtr unionArray(UnionConstPtr const &amp; punion,std::string const &amp; properties);
StructureConstPtr enumerated();
StructureConstPtr enumerated(String const &amp;properties);
StructureConstPtr enumerated(std::string const &amp;properties);
StructureConstPtr alarm();
StructureConstPtr timeStamp();
StructureConstPtr display();
@@ -1879,7 +1879,7 @@ typedef PVValueArray&lt;uint32&gt; PVUIntArray;
typedef PVValueArray&lt;uint64&gt; PVULongArray;
typedef PVValueArray&lt;float&gt; PVFloatArray;
typedef PVValueArray&lt;double&gt; PVDoubleArray;
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
typedef std::tr1::shared_ptr&lt;PVByteArray&gt; PVByteArrayPtr;
@@ -1916,8 +1916,8 @@ class PVField
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
String getFieldName() const ;
String getFullName() const;
std::string getFieldName() const ;
std::string getFullName() const;
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
std::size_t getNumberFields() const;
@@ -2085,7 +2085,7 @@ typedef std::tr1::shared_ptr&lt;PVDouble&gt; PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -2177,18 +2177,18 @@ public:
return std::tr1::dynamic_pointer_cast&lt;PVT&gt;(select(index));
}
PVFieldPtr select(String const &amp; fieldName);
PVFieldPtr select(std::string const &amp; fieldName);
template&lt;typename PVT&gt;
std::tr1::shared_ptr&lt;PVT&gt; select(String const &amp; fieldName) {
std::tr1::shared_ptr&lt;PVT&gt; select(std::string const &amp; fieldName) {
return std::tr1::dynamic_pointer_cast&lt;PVT&gt;(select(fieldName));
}
int32 getSelectedIndex() const;
String getSelectedFieldName() const;
std::string getSelectedFieldName() const;
void set(PVFieldPtr const &amp; value);
void set(int32 index, PVFieldPtr const &amp; value);
void set(String const &amp; fieldName, PVFieldPtr const &amp; value);
void set(std::string const &amp; fieldName, PVFieldPtr const &amp; value);
virtual void serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher) const ;
PVUnion(UnionConstPtr const &amp; punion);
@@ -2328,10 +2328,10 @@ public:
virtual void setImmutable();
StructureConstPtr getStructure() const;
const PVFieldPtrArray &amp; getPVFields() const;
PVFieldPtr getSubField(String const &amp;fieldName) const;
PVFieldPtr getSubField(std::string const &amp;fieldName) const;
template&lt;typename PVT&gt;
std::tr1::shared_ptr&lt;PVT&gt; getSubField(String const &amp;fieldName) const
std::tr1::shared_ptr&lt;PVT&gt; getSubField(std::string const &amp;fieldName) const
PVFieldPtr getSubField(std::size_t fieldOffset) const;
@@ -2358,7 +2358,7 @@ public:
<dt>getPVFields</dt>
<dd>Returns the array of subfields. The set of subfields must all have
different field names.</dd>
<dt>getSubField(String fieldName)</dt>
<dt>getSubField(std::string fieldName)</dt>
<dd>
Get a subField of a field.d
A non-null result is
@@ -2694,12 +2694,12 @@ class StandardPVField : private NoDefaultMethods {
public:
static StandardPVFieldPtr getStandardPVField();
~StandardPVField();
PVStructurePtr scalar(ScalarType type,String const &amp;properties);
PVStructurePtr scalarArray(ScalarType elementType, String const &amp;properties);
PVStructurePtr structureArray(StructureConstPtr const &amp;structure,String const &amp;properties);
PVStructurePtr unionArray(UnionConstPtr const &amp;punion,String const &amp;properties);
PVStructurePtr scalar(ScalarType type,std::string const &amp;properties);
PVStructurePtr scalarArray(ScalarType elementType, std::string const &amp;properties);
PVStructurePtr structureArray(StructureConstPtr const &amp;structure,std::string const &amp;properties);
PVStructurePtr unionArray(UnionConstPtr const &amp;punion,std::string const &amp;properties);
PVStructurePtr enumerated(StringArray const &amp;choices);
PVStructurePtr enumerated(StringArray const &amp;choices, String const &amp;properties);
PVStructurePtr enumerated(StringArray const &amp;choices, std::string const &amp;properties);
...
}
@@ -2786,8 +2786,8 @@ public:
PVStructurePtr const &amp;pv,
StringArray const &amp; from,
std::size_t fromStartIndex = 0);
void fromString(PVScalarPtr const &amp; pv, String const &amp; from);
std::size_t fromString(PVScalarArrayPtr const &amp; pv, String const &amp;from);
void fromString(PVScalarPtr const &amp; pv, std::string const &amp; from);
std::size_t fromString(PVScalarArrayPtr const &amp; pv, std::string const &amp;from);
std::size_t fromStringArray(
PVScalarArrayPtr const &amp; pv,
std::size_t offset, std::size_t length,
@@ -2832,7 +2832,7 @@ public:
uint64 toULong(PVScalarPtr const &amp; pv);
float toFloat(PVScalarPtr const &amp; pv);
double toDouble(PVScalarPtr const &amp; pv);
String toString(PVScalarPtr const &amp; pv);
std::string toString(PVScalarPtr const &amp; pv);
void fromByte(PVScalarPtr const &amp; pv,int8 from);
void fromShort(PVScalarPtr const &amp; pv,int16 from);
void fromInt(PVScalarPtr const &amp; pv, int32 from);
@@ -3068,7 +3068,7 @@ stack. For example the following is permitted:</p>
result = pvAlarm.attach(pvField);
assert(result);
Alarm al;
al.setMessage(String("testMessage"));
al.setMessage(std::string("testMessage"));
al.setSeverity(majorAlarm);
result = pvAlarm.set(al);
assert(result);
@@ -3306,8 +3306,8 @@ class Alarm {
public:
Alarm();
//default constructors and destructor are OK
String getMessage();
void setMessage(String const &amp;value);
std::string getMessage();
void setMessage(std::string const &amp;value);
AlarmSeverity getSeverity() const;
void setSeverity(AlarmSeverity value);
AlarmStatus getStatus() const;
@@ -3505,12 +3505,12 @@ public:
double getHigh() const;
void setLow(double value);
void setHigh(double value);
String getDescription() const;
void setDescription(String const &amp;value);
String getFormat() const;
void setFormat(String const &amp;value);
String getUnits() const;
void setUnits(String const &amp;value);
std::string getDescription() const;
void setDescription(std::string const &amp;value);
std::string getFormat() const;
void setFormat(std::string const &amp;value);
std::string getUnits() const;
void setUnits(std::string const &amp;value);
};</pre>
<p>where</p>
@@ -3599,7 +3599,7 @@ public:
// a set returns false if field is immutable
bool setIndex(int32 index);
int32 getIndex();
String getChoice();
std::string getChoice();
bool choicesMutable();
StringArrayPtr const &amp; getChoices();
int32 getNumberChoices();
@@ -3624,7 +3624,7 @@ public:
<dt>getIndex</dt>
<dd>Get the index field in the pvData structure. </dd>
<dt>getChoice</dt>
<dd>Get the String value corresponding to the current index field in the
<dd>Get the std::string value corresponding to the current index field in the
pvData structure. An exception is thrown if not attached to a pvData
structure. </dd>
<dt>choicesMutable</dt>
@@ -3990,7 +3990,7 @@ private:
class Executor : public Runnable{
public:
POINTER_DEFINITIONS(Executor);
Executor(String threadName,ThreadPriority priority);
Executor(std::string threadName,ThreadPriority priority);
~Executor();
void execute(CommandPtr const &amp;node);
virtual void run();
@@ -4123,7 +4123,7 @@ typedef std::tr1::shared_ptr&lt;MessageQueue&gt; MessageQueuePtr;
class MessageNode {
public:
String getMessage() const;
std::string getMessage() const;
MessageType getMessageType() const;
void setMessageNull();
};
@@ -4138,7 +4138,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();
@@ -4299,14 +4299,14 @@ enum MessageType {
infoMessage,warningMessage,errorMessage,fatalErrorMessage
};
extern String getMessageTypeName(MessageType messageType);
extern std::string getMessageTypeName(MessageType messageType);
extern const size_t messageTypeCount;
class Requester {
public:
POINTER_DEFINITIONS(Requester);
virtual ~Requester(){}
virtual String getRequesterName() = 0;
virtual void message(String const &amp; message,MessageType messageType) = 0;
virtual std::string getRequesterName() = 0;
virtual void message(std::string const &amp; message,MessageType messageType) = 0;
};</pre>
<p>where</p>
@@ -4316,7 +4316,7 @@ public:
<dd>Type of message.</dd>
<dt>messageTypeName</dt>
<dd>An array of strings of the message type names, i.e.
String("info"),String("warning"),String("error"),String("fatalError").</dd>
std::string("info"),std::string("warning"),std::string("error"),std::string("fatalError").</dd>
<dt>getRequesterName</dt>
<dd>Returns the requester name.</dd>
<dt>message</dt>
@@ -4390,12 +4390,12 @@ public:
SerializableControl* flusher);
static int readSize(ByteBuffer* buffer,
DeserializableControl* control);
static void serializeString(const String&amp; value,
static void serializeString(const std::string&amp; value,
ByteBuffer* buffer,SerializableControl* flusher);
static void serializeSubstring(const String&amp; value, int offset,
static void serializeSubstring(const std::string&amp; value, int offset,
int count, ByteBuffer* buffer,
SerializableControl* flusher);
static String deserializeString(ByteBuffer* buffer,
static std::string deserializeString(ByteBuffer* buffer,
DeserializableControl* control);
...
};</pre>
@@ -4407,7 +4407,7 @@ public:
<dt>readSize</dt>
<dd>Deserialize the size.</dd>
<dt>serializeString</dt>
<dd>Serialize a String.</dd>
<dd>Serialize a std::string.</dd>
<dt>serializeSubstring</dt>
<dd>Serialize a substring.</dd>
<dt>deserializeString</dt>
@@ -4634,15 +4634,15 @@ Also he should check for correct descriptions.
static const char* StatusTypeName[];
static Status OK;
Status();
Status(StatusType type, epics::pvData::String const &amp; message);
Status(StatusType type, epics::pvData::String const &amp; message, epics::pvData::String stackDump);
Status(StatusType type, std::string const &amp; message);
Status(StatusType type, std::string const &amp; message, std::string stackDump);
~Status()
StatusType getType() const;
String getMessage() const;
String getStackDump() const;
std::string getMessage() const;
std::string getStackDump() const;
bool isOK() const;
bool isSuccess() const;
String toString() const;
std::string toString() const;
void toString(StringBuilder buffer, int indentLevel = 0) const;
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const;
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const;
@@ -4703,7 +4703,7 @@ class Thread;
class Thread : public epicsThread, private NoDefaultMethods {
public:
Thread(
String name,
std::string name,
ThreadPriority priority,
Runnable *runnableReady,
epicsThreadStackSizeClass stkcls=epicsThreadStackSmall);
@@ -4802,7 +4802,7 @@ public:
class Timer : private Runnable {
public:
POINTER_DEFINITIONS(Timer);
Timer(String threadName, ThreadPriority priority);
Timer(std::string threadName, ThreadPriority priority);
virtual ~Timer();
virtual void run();
void scheduleAfterDelay(
@@ -4971,8 +4971,8 @@ then passes it to pvCopy.
class CreateRequest {
...
static CreateRequestPtr create();
virtual PVStructurePtr createRequest(String const &amp;request);
String getMessage();
virtual PVStructurePtr createRequest(std::string const &amp;request);
std::string getMessage();
};
</pre>
<p>An example of how it is used is:</p>
@@ -4980,7 +4980,7 @@ class CreateRequest {
CreateRequestPtr createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest-&gt;createRequest(request);
if(pvRequest==NULL) {
String error = createRequest-&gt;getMessage();
std::string error = createRequest-&gt;getMessage();
// take some action
} else {
//success do something
@@ -5001,7 +5001,7 @@ class class epicsShareClass PVCopy
static PVCopyPtr create(
PVStructurePtr const &amp;pvMaster,
PVStructurePtr const &amp;pvRequest,
String const &amp; structureName);
std::string const &amp; structureName);
PVStructurePtr getPVMaster();
void traverseMaster(PVCopyTraverseMasterCallbackPtr const &amp; callback);
StructureConstPtr getStructure();
@@ -5074,7 +5074,7 @@ where
<dt>getCopyOffset</dt>
<dd>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.
Two overloaded methods are provided. The first is called if
the field of master is not a structure. The second is for
subfields of a structure.
@@ -5245,7 +5245,7 @@ It has the methods:</p>
<pre>
class MonitorPlugin
{
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
virtual bool causeMonitor(
PVFieldPtr const &amp;pvField,
PVStructurePtr const &amp;pvTop,
@@ -5264,16 +5264,16 @@ class MonitorPluginCreator
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,
PVStructurePtr const &amp;pvFieldOptions) = 0;
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
}
class MonitorPluginManager
{
static MonitorPluginManagerPtr get();
bool addPlugin(
String const &amp;pluginName,
std::string const &amp;pluginName,
MonitorPluginCreatorPtr const &amp;creator);
MonitorPluginCreatorPtr findPlugin(String const &amp;pluginName);
MonitorPluginCreatorPtr findPlugin(std::string const &amp;pluginName);
void showNames();
};
@@ -5445,7 +5445,7 @@ will be passed to the client.
Assume that the client has already connected to the channel.
The client can then issue the commands:</p>
<pre>
String request("field(alarm[plugin=onChange]");
std::string request("field(alarm[plugin=onChange]");
request += ",timeStamp[plugin=onChange,raiseMonitor=false]";
request += ",power.value[plugin=onChange";
request += ",voltage.value[plugin=onChange";
@@ -5481,13 +5481,13 @@ public:
PVStringPtr pvString =
pvFieldOptions-&gt;getSubField&lt;PVString&gt;("raiseMonitor");
if(pvString!=NULL) {
String value = pvString-&gt;get();
std::string value = pvString-&gt;get();
if(value.compare("false")==0) raiseMonitor = false;
}
}
return true;
}
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual bool causeMonitor(
PVFieldPtr const &amp;pvNew,
PVStructurePtr const &amp;pvTop,
@@ -5505,7 +5505,7 @@ private:
class OnChangePluginCreator : public MonitorPluginCreator
{
public:
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual MonitorPluginPtr create(
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,

View File

@@ -145,7 +145,7 @@ After it is unzipped just edit configure/RELEASE.local and then execute make.
</p>
<p>The examples assume that the following statements have been issued:</p>
<pre>
String builder;
std::string builder;
FieldCreatePtr fieldCreate = getFieldCreate();
PVDataCreatePtr pvDataCreate = getPVDataCreate();
StandardFieldPtr standardField = getStandardField();
@@ -876,21 +876,21 @@ typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
// float and double are types
typedef std::string String;
typedef std::string std::string;
typedef std::vector<String> StringArray;
typedef std::vector<std::string> StringArray;
typedef std::tr1::shared_ptr<StringArray> StringArrayPtr;
inline String * get(StringArray &amp;value);
inline String const * get(StringArray const &amp;value);
inline String * get(StringArrayPtr &amp;value);
inline String const * get(StringArrayPtr const &amp;value);
inline std::string * get(StringArray &amp;value);
inline std::string const * get(StringArray const &amp;value);
inline std::string * get(StringArrayPtr &amp;value);
inline std::string const * get(StringArrayPtr const &amp;value);
}
inline StringArray &amp; getVector(StringArrayPtr &value);
inline StringArray const &amp; getVector(StringArrayPtr const &value);
typedef std::vector<String>::iterator StringArray_iterator;
typedef std::vector<String>::const_iterator StringArray_const_iterator;
typedef std::vector<std::string>::iterator StringArray_iterator;
typedef std::vector<std::string>::const_iterator StringArray_const_iterator;
typedef String * StringBuilder;
typedef std::string * StringBuilder;
</pre>
<p>where</p>
@@ -905,7 +905,7 @@ typedef String * StringBuilder;
have worked on all C++ implementations tested at present. If they break
in a future implementation they should be changes via "#ifdef"
preprocessor statements.</dd>
<dt>String</dt>
<dt>std::string</dt>
<dd>pvData requires that a string be an immutable string that is transfered
over the network as a UTF8 encoded string. Since std::string implements
copy on write semantics, it can be used for support for immutable
@@ -914,8 +914,8 @@ typedef String * StringBuilder;
is the same convention the Java implementation uses.
Note that string is treated like a primitive type.</dd>
<dt>StringArray definitions</dt>
<dd>typedefs are provided for an array of Strings,
which is a std::vector&lt;String&gt;.
<dd>typedefs are provided for an array of std::strings,
which is a std::vector&lt;std::string&gt;.
This is used by introspection.
</dd>
<dt>StringBuilder</dt>
@@ -993,7 +993,7 @@ public:
bool isUInteger(ScalarType type);
bool isNumeric(ScalarType type);
bool isPrimitive(ScalarType type);
ScalarType getScalarType(String const &amp;value);
ScalarType getScalarType(std::string const &amp;value);
const char* name(ScalarType);
void toString(StringBuilder buf,ScalarType scalarType);
size_t elementSize(ScalarType id);
@@ -1072,7 +1072,7 @@ public:
<dt>name</dt>
<dd>Returns the name of the scalarType.</dd>
<dt>getScalarType</dt>
<dd>Given a string of the form String("boolean"),...,String("string")
<dd>Given a string of the form std::string("boolean"),...,std::string("string")
return the scalarType.</dd>
<dt>toString</dt>
<dd>Convert the scalar type to a string.</dd>
@@ -1158,7 +1158,7 @@ public:
POINTER_DEFINITIONS(Field);
virtual ~Field();
Type getType() const{return m_type;}
virtual String getID() const = 0;
virtual std::string getID() const = 0;
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
...
@@ -1174,7 +1174,7 @@ public:
ScalarType getScalarType() const {return scalarType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableContol *control);
...
@@ -1190,7 +1190,7 @@ public:
ScalarType getElementType() const {return elementType;}
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1204,7 +1204,7 @@ public:
StructureConstPtr getStructure() const {return pstructure;}
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1217,14 +1217,14 @@ public:
typedef const Structure&amp; const_reference;
std::size_t getNumberFields() const {return numberFields;}
FieldConstPtr getField(String const &amp; fieldName) const;
FieldConstPtr getField(std::string const &amp; fieldName) const;
FieldConstPtr getField(std::size_t index) const;
std::size_t getFieldIndex(String const &amp;fieldName) const;
std::size_t getFieldIndex(std::string const &amp;fieldName) const;
FieldConstPtrArray const &amp; getFields() const {return fields;}
StringArray const &amp; getFieldNames() const;
String getFieldName(std::size_t fieldIndex) const;
std::string getFieldName(std::size_t fieldIndex) const;
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
...
@@ -1233,23 +1233,23 @@ public:
class epicsShareClass Union : public Field {
public:
POINTER_DEFINITIONS(Union);
static epics::pvData::String DEFAULT_ID;
static epics::pvData::String ANY_ID;
static std::string DEFAULT_ID;
static std::string ANY_ID;
virtual ~Union();
typedef Union&amp; reference;
typedef const Union&amp; const_reference;
std::size_t getNumberFields() const;
FieldConstPtr getField(String const &amp;fieldName) const;
FieldConstPtr getField(std::string const &amp;fieldName) const;
FieldConstPtr getField(std::size_t index);
std::size_t getFieldIndex(String const &amp;fieldName) const;
std::size_t getFieldIndex(std::string const &amp;fieldName) const;
FieldConstPtrArray const &amp; getFields() const;
StringArray const &amp; getFieldNames() const;
String getFieldName(std::size_t fieldIndex) const;
std::string getFieldName(std::size_t fieldIndex) const;
bool isVariant() const;
virtual void toString(StringBuilder buf) const;
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(
ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(
@@ -1265,7 +1265,7 @@ public:
UnionConstPtr getUnion() const {return punion;}
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
@@ -1395,14 +1395,14 @@ public:
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
StructureConstPtr createStructure (
String const &amp; id,
std::string const &amp; id,
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createUnion (
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createUnion (
String const &amp; id,
std::string const &amp; id,
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
UnionConstPtr createVariantUnion() const;
@@ -1410,7 +1410,7 @@ public:
UnionArrayConstPtr createUnionArray(UnionConstPtr const &amp; punion) const;
StructureConstPtr appendField(
StructureConstPtr const &amp; structure,
String const &amp; fieldName, FieldConstPtr const &amp; field) const;
std::string const &amp; fieldName, FieldConstPtr const &amp; field) const;
StructureConstPtr appendFields(
StructureConstPtr const &amp; structure,
StringArray const &amp; fieldNames,
@@ -1480,7 +1480,7 @@ StructureConstPtr structure =
add("index", pvDouble)-&gt;
addArray("choices", pvString)-&gt;
createStructure();
String builder;
std::string builder;
structure-&gt;toString(&amp;builder);
cout &lt;&lt; builder &lt;&lt; endl;
</pre>
@@ -1698,18 +1698,18 @@ class StandardField {
public:
static StandardFieldPtr getStandardField();
~StandardField();
StructureConstPtr scalar(ScalarType type,String const &amp;properties);
StructureConstPtr scalar(ScalarType type,std::string const &amp;properties);
StructureConstPtr regUnion(
UnionConstPtr const &amp; punion,
String const &amp; properties);
StructureConstPtr variantUnion(String const &amp; properties);
std::string const &amp; properties);
StructureConstPtr variantUnion(std::string const &amp; properties);
StructureConstPtr scalarArray(
ScalarType elementType, String const &amp;properties);
ScalarType elementType, std::string const &amp;properties);
StructureConstPtr structureArray(
StructureConstPtr const &amp; structure,String const &amp;properties);
StructureConstPtr unionArray(UnionConstPtr const &amp; punion,String const &amp; properties);
StructureConstPtr const &amp; structure,std::string const &amp;properties);
StructureConstPtr unionArray(UnionConstPtr const &amp; punion,std::string const &amp; properties);
StructureConstPtr enumerated();
StructureConstPtr enumerated(String const &amp;properties);
StructureConstPtr enumerated(std::string const &amp;properties);
StructureConstPtr alarm();
StructureConstPtr timeStamp();
StructureConstPtr display();
@@ -1879,7 +1879,7 @@ typedef PVValueArray&lt;uint32&gt; PVUIntArray;
typedef PVValueArray&lt;uint64&gt; PVULongArray;
typedef PVValueArray&lt;float&gt; PVFloatArray;
typedef PVValueArray&lt;double&gt; PVDoubleArray;
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
typedef std::tr1::shared_ptr&lt;PVByteArray&gt; PVByteArrayPtr;
@@ -1916,8 +1916,8 @@ class PVField
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
String getFieldName() const ;
String getFullName() const;
std::string getFieldName() const ;
std::string getFullName() const;
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
std::size_t getNumberFields() const;
@@ -2085,7 +2085,7 @@ typedef std::tr1::shared_ptr&lt;PVDouble&gt; PVDoublePtr;
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -2177,18 +2177,18 @@ public:
return std::tr1::dynamic_pointer_cast&lt;PVT&gt;(select(index));
}
PVFieldPtr select(String const &amp; fieldName);
PVFieldPtr select(std::string const &amp; fieldName);
template&lt;typename PVT&gt;
std::tr1::shared_ptr&lt;PVT&gt; select(String const &amp; fieldName) {
std::tr1::shared_ptr&lt;PVT&gt; select(std::string const &amp; fieldName) {
return std::tr1::dynamic_pointer_cast&lt;PVT&gt;(select(fieldName));
}
int32 getSelectedIndex() const;
String getSelectedFieldName() const;
std::string getSelectedFieldName() const;
void set(PVFieldPtr const &amp; value);
void set(int32 index, PVFieldPtr const &amp; value);
void set(String const &amp; fieldName, PVFieldPtr const &amp; value);
void set(std::string const &amp; fieldName, PVFieldPtr const &amp; value);
virtual void serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher) const ;
PVUnion(UnionConstPtr const &amp; punion);
@@ -2328,10 +2328,10 @@ public:
virtual void setImmutable();
StructureConstPtr getStructure() const;
const PVFieldPtrArray &amp; getPVFields() const;
PVFieldPtr getSubField(String const &amp;fieldName) const;
PVFieldPtr getSubField(std::string const &amp;fieldName) const;
template&lt;typename PVT&gt;
std::tr1::shared_ptr&lt;PVT&gt; getSubField(String const &amp;fieldName) const
std::tr1::shared_ptr&lt;PVT&gt; getSubField(std::string const &amp;fieldName) const
PVFieldPtr getSubField(std::size_t fieldOffset) const;
@@ -2358,7 +2358,7 @@ public:
<dt>getPVFields</dt>
<dd>Returns the array of subfields. The set of subfields must all have
different field names.</dd>
<dt>getSubField(String fieldName)</dt>
<dt>getSubField(std::string fieldName)</dt>
<dd>
Get a subField of a field.d
A non-null result is
@@ -2694,12 +2694,12 @@ class StandardPVField : private NoDefaultMethods {
public:
static StandardPVFieldPtr getStandardPVField();
~StandardPVField();
PVStructurePtr scalar(ScalarType type,String const &amp;properties);
PVStructurePtr scalarArray(ScalarType elementType, String const &amp;properties);
PVStructurePtr structureArray(StructureConstPtr const &amp;structure,String const &amp;properties);
PVStructurePtr unionArray(UnionConstPtr const &amp;punion,String const &amp;properties);
PVStructurePtr scalar(ScalarType type,std::string const &amp;properties);
PVStructurePtr scalarArray(ScalarType elementType, std::string const &amp;properties);
PVStructurePtr structureArray(StructureConstPtr const &amp;structure,std::string const &amp;properties);
PVStructurePtr unionArray(UnionConstPtr const &amp;punion,std::string const &amp;properties);
PVStructurePtr enumerated(StringArray const &amp;choices);
PVStructurePtr enumerated(StringArray const &amp;choices, String const &amp;properties);
PVStructurePtr enumerated(StringArray const &amp;choices, std::string const &amp;properties);
...
}
@@ -2786,8 +2786,8 @@ public:
PVStructurePtr const &amp;pv,
StringArray const &amp; from,
std::size_t fromStartIndex = 0);
void fromString(PVScalarPtr const &amp; pv, String const &amp; from);
std::size_t fromString(PVScalarArrayPtr const &amp; pv, String const &amp;from);
void fromString(PVScalarPtr const &amp; pv, std::string const &amp; from);
std::size_t fromString(PVScalarArrayPtr const &amp; pv, std::string const &amp;from);
std::size_t fromStringArray(
PVScalarArrayPtr const &amp; pv,
std::size_t offset, std::size_t length,
@@ -2832,7 +2832,7 @@ public:
uint64 toULong(PVScalarPtr const &amp; pv);
float toFloat(PVScalarPtr const &amp; pv);
double toDouble(PVScalarPtr const &amp; pv);
String toString(PVScalarPtr const &amp; pv);
std::string toString(PVScalarPtr const &amp; pv);
void fromByte(PVScalarPtr const &amp; pv,int8 from);
void fromShort(PVScalarPtr const &amp; pv,int16 from);
void fromInt(PVScalarPtr const &amp; pv, int32 from);
@@ -3068,7 +3068,7 @@ stack. For example the following is permitted:</p>
result = pvAlarm.attach(pvField);
assert(result);
Alarm al;
al.setMessage(String("testMessage"));
al.setMessage(std::string("testMessage"));
al.setSeverity(majorAlarm);
result = pvAlarm.set(al);
assert(result);
@@ -3306,8 +3306,8 @@ class Alarm {
public:
Alarm();
//default constructors and destructor are OK
String getMessage();
void setMessage(String const &amp;value);
std::string getMessage();
void setMessage(std::string const &amp;value);
AlarmSeverity getSeverity() const;
void setSeverity(AlarmSeverity value);
AlarmStatus getStatus() const;
@@ -3505,12 +3505,12 @@ public:
double getHigh() const;
void setLow(double value);
void setHigh(double value);
String getDescription() const;
void setDescription(String const &amp;value);
String getFormat() const;
void setFormat(String const &amp;value);
String getUnits() const;
void setUnits(String const &amp;value);
std::string getDescription() const;
void setDescription(std::string const &amp;value);
std::string getFormat() const;
void setFormat(std::string const &amp;value);
std::string getUnits() const;
void setUnits(std::string const &amp;value);
};</pre>
<p>where</p>
@@ -3599,7 +3599,7 @@ public:
// a set returns false if field is immutable
bool setIndex(int32 index);
int32 getIndex();
String getChoice();
std::string getChoice();
bool choicesMutable();
StringArrayPtr const &amp; getChoices();
int32 getNumberChoices();
@@ -3624,7 +3624,7 @@ public:
<dt>getIndex</dt>
<dd>Get the index field in the pvData structure. </dd>
<dt>getChoice</dt>
<dd>Get the String value corresponding to the current index field in the
<dd>Get the std::string value corresponding to the current index field in the
pvData structure. An exception is thrown if not attached to a pvData
structure. </dd>
<dt>choicesMutable</dt>
@@ -3990,7 +3990,7 @@ private:
class Executor : public Runnable{
public:
POINTER_DEFINITIONS(Executor);
Executor(String threadName,ThreadPriority priority);
Executor(std::string threadName,ThreadPriority priority);
~Executor();
void execute(CommandPtr const &amp;node);
virtual void run();
@@ -4123,7 +4123,7 @@ typedef std::tr1::shared_ptr&lt;MessageQueue&gt; MessageQueuePtr;
class MessageNode {
public:
String getMessage() const;
std::string getMessage() const;
MessageType getMessageType() const;
void setMessageNull();
};
@@ -4138,7 +4138,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();
@@ -4299,14 +4299,14 @@ enum MessageType {
infoMessage,warningMessage,errorMessage,fatalErrorMessage
};
extern String getMessageTypeName(MessageType messageType);
extern std::string getMessageTypeName(MessageType messageType);
extern const size_t messageTypeCount;
class Requester {
public:
POINTER_DEFINITIONS(Requester);
virtual ~Requester(){}
virtual String getRequesterName() = 0;
virtual void message(String const &amp; message,MessageType messageType) = 0;
virtual std::string getRequesterName() = 0;
virtual void message(std::string const &amp; message,MessageType messageType) = 0;
};</pre>
<p>where</p>
@@ -4316,7 +4316,7 @@ public:
<dd>Type of message.</dd>
<dt>messageTypeName</dt>
<dd>An array of strings of the message type names, i.e.
String("info"),String("warning"),String("error"),String("fatalError").</dd>
std::string("info"),std::string("warning"),std::string("error"),std::string("fatalError").</dd>
<dt>getRequesterName</dt>
<dd>Returns the requester name.</dd>
<dt>message</dt>
@@ -4390,12 +4390,12 @@ public:
SerializableControl* flusher);
static int readSize(ByteBuffer* buffer,
DeserializableControl* control);
static void serializeString(const String&amp; value,
static void serializeString(const std::string&amp; value,
ByteBuffer* buffer,SerializableControl* flusher);
static void serializeSubstring(const String&amp; value, int offset,
static void serializeSubstring(const std::string&amp; value, int offset,
int count, ByteBuffer* buffer,
SerializableControl* flusher);
static String deserializeString(ByteBuffer* buffer,
static std::string deserializeString(ByteBuffer* buffer,
DeserializableControl* control);
...
};</pre>
@@ -4407,7 +4407,7 @@ public:
<dt>readSize</dt>
<dd>Deserialize the size.</dd>
<dt>serializeString</dt>
<dd>Serialize a String.</dd>
<dd>Serialize a std::string.</dd>
<dt>serializeSubstring</dt>
<dd>Serialize a substring.</dd>
<dt>deserializeString</dt>
@@ -4634,15 +4634,15 @@ Also he should check for correct descriptions.
static const char* StatusTypeName[];
static Status OK;
Status();
Status(StatusType type, epics::pvData::String const &amp; message);
Status(StatusType type, epics::pvData::String const &amp; message, epics::pvData::String stackDump);
Status(StatusType type, std::string const &amp; message);
Status(StatusType type, std::string const &amp; message, std::string stackDump);
~Status()
StatusType getType() const;
String getMessage() const;
String getStackDump() const;
std::string getMessage() const;
std::string getStackDump() const;
bool isOK() const;
bool isSuccess() const;
String toString() const;
std::string toString() const;
void toString(StringBuilder buffer, int indentLevel = 0) const;
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const;
void serialize(ByteBuffer *buffer, SerializableControl *flusher) const;
@@ -4703,7 +4703,7 @@ class Thread;
class Thread : public epicsThread, private NoDefaultMethods {
public:
Thread(
String name,
std::string name,
ThreadPriority priority,
Runnable *runnableReady,
epicsThreadStackSizeClass stkcls=epicsThreadStackSmall);
@@ -4802,7 +4802,7 @@ public:
class Timer : private Runnable {
public:
POINTER_DEFINITIONS(Timer);
Timer(String threadName, ThreadPriority priority);
Timer(std::string threadName, ThreadPriority priority);
virtual ~Timer();
virtual void run();
void scheduleAfterDelay(
@@ -4971,8 +4971,8 @@ then passes it to pvCopy.
class CreateRequest {
...
static CreateRequestPtr create();
virtual PVStructurePtr createRequest(String const &amp;request);
String getMessage();
virtual PVStructurePtr createRequest(std::string const &amp;request);
std::string getMessage();
};
</pre>
<p>An example of how it is used is:</p>
@@ -4980,7 +4980,7 @@ class CreateRequest {
CreateRequestPtr createRequest = CreateRequest::create();
PVStructurePtr pvRequest = createRequest-&gt;createRequest(request);
if(pvRequest==NULL) {
String error = createRequest-&gt;getMessage();
std::string error = createRequest-&gt;getMessage();
// take some action
} else {
//success do something
@@ -5001,7 +5001,7 @@ class class epicsShareClass PVCopy
static PVCopyPtr create(
PVStructurePtr const &amp;pvMaster,
PVStructurePtr const &amp;pvRequest,
String const &amp; structureName);
std::string const &amp; structureName);
PVStructurePtr getPVMaster();
void traverseMaster(PVCopyTraverseMasterCallbackPtr const &amp; callback);
StructureConstPtr getStructure();
@@ -5074,7 +5074,7 @@ where
<dt>getCopyOffset</dt>
<dd>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.
Two overloaded methods are provided. The first is called if
the field of master is not a structure. The second is for
subfields of a structure.
@@ -5245,7 +5245,7 @@ It has the methods:</p>
<pre>
class MonitorPlugin
{
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
virtual bool causeMonitor(
PVFieldPtr const &amp;pvField,
PVStructurePtr const &amp;pvTop,
@@ -5264,16 +5264,16 @@ class MonitorPluginCreator
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,
PVStructurePtr const &amp;pvFieldOptions) = 0;
virtual String const &amp; getName() = 0;
virtual std::string const &amp; getName() = 0;
}
class MonitorPluginManager
{
static MonitorPluginManagerPtr get();
bool addPlugin(
String const &amp;pluginName,
std::string const &amp;pluginName,
MonitorPluginCreatorPtr const &amp;creator);
MonitorPluginCreatorPtr findPlugin(String const &amp;pluginName);
MonitorPluginCreatorPtr findPlugin(std::string const &amp;pluginName);
void showNames();
};
@@ -5445,7 +5445,7 @@ will be passed to the client.
Assume that the client has already connected to the channel.
The client can then issue the commands:</p>
<pre>
String request("field(alarm[plugin=onChange]");
std::string request("field(alarm[plugin=onChange]");
request += ",timeStamp[plugin=onChange,raiseMonitor=false]";
request += ",power.value[plugin=onChange";
request += ",voltage.value[plugin=onChange";
@@ -5481,13 +5481,13 @@ public:
PVStringPtr pvString =
pvFieldOptions-&gt;getSubField&lt;PVString&gt;("raiseMonitor");
if(pvString!=NULL) {
String value = pvString-&gt;get();
std::string value = pvString-&gt;get();
if(value.compare("false")==0) raiseMonitor = false;
}
}
return true;
}
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual bool causeMonitor(
PVFieldPtr const &amp;pvNew,
PVStructurePtr const &amp;pvTop,
@@ -5505,7 +5505,7 @@ private:
class OnChangePluginCreator : public MonitorPluginCreator
{
public:
virtual String &amp;getName(){return pluginName;}
virtual std::string &amp;getName(){return pluginName;}
virtual MonitorPluginPtr create(
FieldConstPtr const &amp;field,
StructureConstPtr const &amp;top,

View File

@@ -88,7 +88,7 @@ The interfaces for C++ and Java should be similar so that
someone who understands the interface in one of the languages
and knows both languages will quickly understand the interface of the other language.</p>
<p>There is another problem with the existing API. There are methods that allow the "structure"
to change after an pvData object is created. An example is PVField::renameField(String newName).
to change after an pvData object is created. An example is PVField::renameField(std::string newName).
Such methods should not exist.</p>
<p>There are methods regarding immutability: setImmutable, isImmutablei, setCapacityMutable, and isCapacityMutable.
Should they exists? For now lets assume no.
@@ -114,18 +114,18 @@ The new methods also have a comment.
<h3>Introspection Interfaces</h3>
<pre>interface Field extends Serializable {
String getId();
std::string getId();
Type getType();
// following will be removed
<font color = "red">void toString(StringBuilder buf);</font>
<font color = "red">void toString(StringBuilder buf,int indentLevel);</font>
<font color = "red">String toString();</font>
<font color = "red">std::string toString();</font>
}
<font color = "blue">
// new interface
interface FieldToString {
String toString(Field field);
interface FieldTostd::string {
std::string toString(Field field);
}</font>
interface Scalar extends Field {
@@ -137,12 +137,12 @@ interface ScalarArray extends Field {
}
interface Structure extends Field {
Field getField(String fieldName);
int getFieldIndex(String fieldName);
Field getField(std::string fieldName);
int getFieldIndex(std::string fieldName);
Field[] getFields();
Field getField(int fieldIndex);
String[] getFieldNames();
String getFieldName(int fieldIndex)
std::string[] getFieldNames();
std::string getFieldName(int fieldIndex)
}
interface StructureArray extends Field {
@@ -153,19 +153,19 @@ interface FieldCreate {
Scalar createScalar(ScalarType scalarType);
ScalarArray createScalarArray(ScalarType elementType);
StructureArray createStructureArray(Structure elementStructure);
Structure createStructure(String[] fieldNames, Field[] field);
Structure createStructure(String id,String[] fieldNames, Field[] field);
Structure createStructure(std::string[] fieldNames, Field[] field);
Structure createStructure(std::string id,std::string[] fieldNames, Field[] field);
Structure createStructure(Structure structToClone);
Field deserialize(ByteBuffer buffer, DeserializableControl control);
// following will be removed
<font color = "red">Structure appendField(Structure structure,String fieldName, Field field);</font>
<font color = "red">Structure appendFields(Structure structure,String[] fieldNames, Field[] fields);</font>
<font color = "red">Structure appendField(Structure structure,std::string fieldName, Field field);</font>
<font color = "red">Structure appendFields(Structure structure,std::string[] fieldNames, Field[] fields);</font>
}
</pre>
<h3>Data Interfaces</h3>
<pre>
interface PVField extends Requester, Serializable {
String getFieldName();
std::string getFieldName();
void setRequester(Requester requester);
int getFieldOffset();
int getNextFieldOffset();
@@ -178,16 +178,16 @@ interface PVField extends Requester, Serializable {
<font color = "red">PVAuxInfo getPVAuxInfo();</font>
<font color = "red">boolean isImmutable();</font>
<font color = "red">void setImmutable();</font>
<font color = "red">void renameField(String newName);</font>
<font color = "red">void renameField(std::string newName);</font>
<font color = "red">void toString(StringBuilder buf);</font>
<font color = "red">void toString(StringBuilder buf,int indentLevel);</font>
<font color = "red">String toString();</font>
<font color = "red">std::string toString();</font>
}
<font color = "blue">
// The following is a new interface
interface PVFieldToString {
String toString(PVField pvField);
interface PVFieldTostd::string {
std::string toString(PVField pvField);
void setMaxInitialArrayElements(int num);
void setMaxFinalArrayElements(int num);
int getMaxInitialArrayElements();
@@ -241,28 +241,28 @@ interface PVDoubleArray extends PVArray {
interface PVStructure extends PVField , BitSetSerializable{
Structure getStructure();
PVField[] getPVFields();
PVField getSubField(String fieldName);
PVField getSubField(std::string fieldName);
PVField getSubField(int fieldOffset);
// The following are convenience methods
PVBoolean getBooleanField(String fieldName);
PVByte getByteField(String fieldName);
PVShort getShortField(String fieldName);
PVInt getIntField(String fieldName);
PVLong getLongField(String fieldName);
PVFloat getFloatField(String fieldName);
PVDouble getDoubleField(String fieldName);
PVString getStringField(String fieldName);
PVScalarArray getScalarArrayField(String fieldName);
PVStructureArray getStructureArrayField(String fieldName);
PVStructure getStructureField(String fieldName);
PVArray getArrayField(String fieldName,ScalarType elementType);
PVBoolean getBooleanField(std::string fieldName);
PVByte getByteField(std::string fieldName);
PVShort getShortField(std::string fieldName);
PVInt getIntField(std::string fieldName);
PVLong getLongField(std::string fieldName);
PVFloat getFloatField(std::string fieldName);
PVDouble getDoubleField(std::string fieldName);
PVString getStringField(std::string fieldName);
PVScalarArray getScalarArrayField(std::string fieldName);
PVStructureArray getStructureArrayField(std::string fieldName);
PVStructure getStructureField(std::string fieldName);
PVArray getArrayField(std::string fieldName,ScalarType elementType);
// following will be removed
<font color = "red"> void appendPVField(String fieldName,PVField pvField);</font>
<font color = "red"> void appendPVFields(String[] fieldNames,PVField[] pvFields);</font>
<font color = "red"> void removePVField(String fieldName);</font>
<font color = "red"> void appendPVField(std::string fieldName,PVField pvField);</font>
<font color = "red"> void appendPVFields(std::string[] fieldNames,PVField[] pvFields);</font>
<font color = "red"> void removePVField(std::string fieldName);</font>
<font color = "red"> void replacePVField(PVField oldPVField,PVField newPVField);</font>
<font color = "red"> String getExtendsStructureName();</font>
<font color = "red"> boolean putExtendsStructureName(String extendsStructureName);</font>
<font color = "red"> std::string getExtendsStructureName();</font>
<font color = "red"> boolean putExtendsStructureName(std::string extendsStructureName);</font>
<font color = "red"> public boolean checkValid();</font>
}
@@ -297,13 +297,13 @@ public interface PVDataCreate {
PVScalarArray createPVScalarArray(PVScalarArray arrayToClone;
PVStructureArray createPVStructureArray(StructureArray structureArray);
PVStructure createPVStructure(Structure structure);
PVStructure createPVStructure(String[] fieldNames,Field[] fields);
PVStructure createPVStructure(std::string[] fieldNames,Field[] fields);
PVStructure createPVStructure(PVStructure structToClone);
// following will be removed
<font color = "red">PVField[] flattenPVStructure(PVStructure pvStructure);</font>
}
</pre>
<h3>PVFieldToString</h3>
<h3>PVFieldTostd::string</h3>
<p>In addition to toString this has methods to limit the number of array element to display.
The existing Java implementation of toString displayed all elements.
For large arrays this is not desirable.
@@ -346,7 +346,7 @@ public:
POINTER_DEFINITIONS(Field);
virtual ~Field();
Type getType() const{return m_type;}
virtual String getID() const = 0;
virtual std::string getID() const = 0;
<font color = "red">
// following will be removed
virtual void toString(StringBuilder buf) const{toString(buf,0);}
@@ -373,7 +373,7 @@ public:
// following will be removed
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
</font>
...
};
@@ -391,7 +391,7 @@ public:
// following will be removed
virtual void toString(StringBuilder buf) const{toString(buf,0);}
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
</font>
...
};
@@ -403,19 +403,19 @@ public:
typedef const Structure&amp; const_reference;
std::size_t getNumberFields() const {return numberFields;}
FieldConstPtr getField(String const &amp; fieldName) const;
FieldConstPtr getField(std::string const &amp; fieldName) const;
FieldConstPtr getField(std::size_t index) const;
std::size_t getFieldIndex(String const &amp;fieldName) const;
std::size_t getFieldIndex(std::string const &amp;fieldName) const;
FieldConstPtrArray const &amp; getFields() const {return fields;}
StringArray const &amp; getFieldNames() const;
String getFieldName(std::size_t fieldIndex);
std::string getFieldName(std::size_t fieldIndex);
virtual void serialize(ByteBuffer *buffer, SerializableControl *control) const;
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *control);
<font color = "red">
// following will be removed
void renameField(std::size_t fieldIndex,String const &amp;newName);
void renameField(std::size_t fieldIndex,std::string const &amp;newName);
virtual void toString(StringBuilder buf,int indentLevel) const;
virtual String getID() const;
virtual std::string getID() const;
</font>
...
};
@@ -432,7 +432,7 @@ public:
<font color = "red">
// following will be removed
virtual void toString(StringBuilder buf,int indentLevel=0) const;
virtual String getID() const;
virtual std::string getID() const;
</font>
...
};
@@ -447,7 +447,7 @@ public:
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
StructureConstPtr createStructure (
String const &amp;id,
std::string const &amp;id,
StringArray const &amp; fieldNames,
FieldConstPtrArray const &amp; fields) const;
FieldConstPtr deserialize(ByteBuffer* buffer, DeserializableControl* control) const;
@@ -455,7 +455,7 @@ public:
// following will be removed
StructureConstPtr appendField(
StructureConstPtr const &amp; structure,
String const &amp;fieldName, FieldConstPtr const &amp; field) const;
std::string const &amp;fieldName, FieldConstPtr const &amp; field) const;
StructureConstPtr appendFields(
StructureConstPtr const &amp; structure,
StringArray const &amp; fieldNames,
@@ -475,7 +475,7 @@ class PVField
public:
POINTER_DEFINITIONS(PVField);
virtual ~PVField();
inline const String &amp;getFieldName() const ;
inline const std::string &amp;getFieldName() const ;
virtual void setRequester(RequesterPtr const &amp;prequester);
std::size_t getFieldOffset() const;
std::size_t getNextFieldOffset() const;
@@ -486,15 +486,15 @@ public:
void setPostHandler(PostHandlerPtr const &amp;postHandler);
// following will be removed
<font color = "red">
virtual void message(String message,MessageType messageType);
virtual void message(std::string message,MessageType messageType);
void replacePVField(const PVFieldPtr&amp; newPVField);
String getFullName() const;
std::string getFullName() const;
virtual bool equals(PVField &amp;pv);
PVAuxInfoPtr &amp; getPVAuxInfo()
bool isImmutable() const;
virtual void setImmutable();
void replacePVField(const PVFieldPtr&amp; newPVField);
void renameField(String const &amp;newName);
void renameField(std::string const &amp;newName);
virtual void toString(StringBuilder buf) ;
virtual void toString(StringBuilder buf,int indentLevel);
std::ostream&amp; dumpValue(std::ostream&amp; o) const;
@@ -504,8 +504,8 @@ public:
<font color = "blue">
// The following is a new class
class PVFieldToString {
String toString(const PVFieldPtr &amp;pvField);
class PVFieldTostd::string {
std::string toString(const PVFieldPtr &amp;pvField);
void setMaxInitialArrayElements(size_t num);
void setMaxFinalArrayElements(size_t num);
size_t getMaxInitialArrayElements();
@@ -546,7 +546,7 @@ public:
}
// PVString is special case, since it implements SerializableArray
class PVString : public PVScalarValue&lt;String&gt;, SerializableArray {
class PVString : public PVScalarValue&lt;std::string&gt;, SerializableArray {
public:
virtual ~PVString() {}
...
@@ -650,7 +650,7 @@ public:
typedef PVValueArray&lt;uint8&gt; PVBooleanArray;
typedef std::tr1::shared_ptr&lt;PVBooleanArray&gt; PVBooleanArrayPtr;
...
typedef PVValueArray&lt;String&gt; PVStringArray;
typedef PVValueArray&lt;std::string&gt; PVStringArray;
typedef std::tr1::shared_ptr&lt;PVStringArray&gt; PVStringArrayPtr;
class PVStructure : public PVField,public BitSetSerializable {
@@ -662,24 +662,24 @@ public:
StructureConstPtr getStructure() const;
const PVFieldPtrArray &amp; getPVFields() const;
PVFieldPtr getSubField(String const &amp;fieldName) const;
PVFieldPtr getSubField(std::string const &amp;fieldName) const;
PVFieldPtr getSubField(std::size_t fieldOffset) const;
PVBooleanPtr getBooleanField(String const &amp;fieldName) ;
PVBytePtr getByteField(String const &amp;fieldName) ;
PVShortPtr getShortField(String const &amp;fieldName) ;
PVIntPtr getIntField(String const &amp;fieldName) ;
PVLongPtr getLongField(String const &amp;fieldName) ;
PVUBytePtr getUByteField(String const &amp;fieldName) ;
PVUShortPtr getUShortField(String const &amp;fieldName) ;
PVUIntPtr getUIntField(String const &amp;fieldName) ;
PVULongPtr getULongField(String const &amp;fieldName) ;
PVFloatPtr getFloatField(String const &amp;fieldName) ;
PVDoublePtr getDoubleField(String const &amp;fieldName) ;
PVStringPtr getStringField(String const &amp;fieldName) ;
PVStructurePtr getStructureField(String const &amp;fieldName) ;
PVBooleanPtr getBooleanField(std::string const &amp;fieldName) ;
PVBytePtr getByteField(std::string const &amp;fieldName) ;
PVShortPtr getShortField(std::string const &amp;fieldName) ;
PVIntPtr getIntField(std::string const &amp;fieldName) ;
PVLongPtr getLongField(std::string const &amp;fieldName) ;
PVUBytePtr getUByteField(std::string const &amp;fieldName) ;
PVUShortPtr getUShortField(std::string const &amp;fieldName) ;
PVUIntPtr getUIntField(std::string const &amp;fieldName) ;
PVULongPtr getULongField(std::string const &amp;fieldName) ;
PVFloatPtr getFloatField(std::string const &amp;fieldName) ;
PVDoublePtr getDoubleField(std::string const &amp;fieldName) ;
PVStringPtr getStringField(std::string const &amp;fieldName) ;
PVStructurePtr getStructureField(std::string const &amp;fieldName) ;
PVScalarArrayPtr getScalarArrayField(
String const &amp;fieldName,ScalarType elementType) ;
PVStructureArrayPtr getStructureArrayField(String const &amp;fieldName) ;
std::string const &amp;fieldName,ScalarType elementType) ;
PVStructureArrayPtr getStructureArrayField(std::string const &amp;fieldName) ;
virtual void serialize(
ByteBuffer *pbuffer,SerializableControl *pflusher) const ;
virtual void deserialize(
@@ -693,16 +693,16 @@ public:
<font color = "red">
// following are removed
void appendPVField(
String const &amp;fieldName,
std::string const &amp;fieldName,
PVFieldPtr const &amp; pvField);
void appendPVFields(
StringArray const &amp; fieldNames,
PVFieldPtrArray const &amp; pvFields);
void removePVField(String const &amp;fieldName);
void removePVField(std::string const &amp;fieldName);
virtual void setImmutable();
String getExtendsStructureName() const;
std::string getExtendsStructureName() const;
bool putExtendsStructureName(
String const &amp;extendsStructureName);
std::string const &amp;extendsStructureName);
</font>
};

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();

View File

@@ -14,6 +14,7 @@
#include <pv/createRequest.h>
using namespace epics::pvData;
using std::string;
using std::cout;
using std::endl;
@@ -23,8 +24,8 @@ void testCreateRequest() {
printf("testCreateRequest... \n");
CreateRequest::shared_pointer createRequest = CreateRequest::create();
String out;
String request = "";
string out;
string request = "";
if(debug) { cout << "request " << request <<endl;}
PVStructurePtr pvRequest = createRequest->createRequest(request);
if(debug) { cout<< createRequest->getMessage() << endl;}
@@ -43,7 +44,7 @@ void testCreateRequest() {
testOk1(pvRequest!=NULL);
if(debug) { cout << pvRequest->dumpValue(cout) << endl;}
PVStringPtr pvString = pvRequest->getSubField<PVString>("record.a");
String sval = pvString->get();
string sval = pvString->get();
testOk(sval.compare("b")==0,"record.a = b");
pvString = pvRequest->getSubField<PVString>("record.x");
sval = pvString->get();
@@ -131,7 +132,7 @@ void testCreateRequest() {
request = "alarm,timeStamp,power.value";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << endl << String("request") <<endl << request <<endl;}
if(debug) { cout << endl << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -144,7 +145,7 @@ void testCreateRequest() {
request = "record[process=true]field(alarm,timeStamp,power.value)";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << endl << String("request") <<endl << request <<endl;}
if(debug) { cout << endl << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -160,7 +161,7 @@ void testCreateRequest() {
request = "record[process=true]field(alarm,timeStamp[algorithm=onChange,causeMonitor=false],power{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -183,7 +184,7 @@ void testCreateRequest() {
request = "record[int=2,float=3.14159]field(alarm,timeStamp[shareData=true],power.value)";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -202,12 +203,12 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -224,12 +225,12 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("field(alarm,timeStamp,supply{")
request = string("field(alarm,timeStamp,supply{")
+ "0{voltage.value,current.value,power.value},"
+ "1{voltage.value,current.value,power.value}"
+ "})";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -245,7 +246,7 @@ void testCreateRequest() {
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
@@ -253,7 +254,7 @@ void testCreateRequest() {
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}}"
+ ")";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(pvRequest==NULL) {
cout << "reason " << createRequest->getMessage() << endl;
}
@@ -288,13 +289,13 @@ void testCreateRequest() {
request = "a{b{c{d}}}";
pvRequest = createRequest->createRequest(request);
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
testOk1(pvRequest!=NULL);
testOk1(pvRequest->getSubField("field.a.b.c.d")!=NULL);
if(debug) {cout << pvRequest->dumpValue(cout) << endl;}
testPass("request %s",request.c_str());
request = String("record[process=true,xxx=yyy]")
request = string("record[process=true,xxx=yyy]")
+ "putField(power.value)"
+ "getField(alarm,timeStamp,power{value,alarm},"
+ "current{value,alarm},voltage{value,alarm},"
@@ -302,14 +303,14 @@ void testCreateRequest() {
+ "ps1{alarm,timeStamp,power{value,alarm},current{value,alarm},voltage{value,alarm}"
+ ")";
if(debug) { cout << endl << "Error Expected for next call!!" << endl;}
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
pvRequest = createRequest->createRequest(request);
assert(pvRequest.get()==NULL);
if(debug) {cout << "reason " << createRequest->getMessage() << endl;}
testPass("request %s",request.c_str());
request = "record[process=true,power.value";
if(debug) { cout << String("request") <<endl << request <<endl;}
if(debug) { cout << string("request") <<endl << request <<endl;}
if(debug) { cout << endl << "Error Expected for next call!!" << endl;}
pvRequest = createRequest->createRequest(request);
assert(pvRequest.get()==NULL);

View File

@@ -35,8 +35,8 @@ using namespace epics::pvData;
static bool debug = true;
static void testPVScalar(
String const & valueNameMaster,
String const & valueNameCopy,
string const & valueNameMaster,
string const & valueNameCopy,
PVStructurePtr const & pvMaster,
PVCopyPtr const & pvCopy)
{
@@ -45,7 +45,6 @@ static void testPVScalar(
PVScalarPtr pvValueMaster;
PVScalarPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
ConvertPtr convert = getConvert();
@@ -53,8 +52,7 @@ static void testPVScalar(
pvValueMaster = static_pointer_cast<PVScalar>(pvField);
convert->fromDouble(pvValueMaster,.04);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
if(debug) { cout << "structure from copy" << endl << builder << endl; }
if(debug) { cout << "structure from copy" << endl << *structure << endl; }
pvStructureCopy = pvCopy->createPVStructure();
pvField = pvStructureCopy->getSubField(valueNameCopy);
pvValueCopy = static_pointer_cast<PVScalar>(pvField);
@@ -68,24 +66,20 @@ static void testPVScalar(
testOk1(convert->toDouble(pvValueCopy)==.06);
testOk1(bitSet->get(pvValueCopy->getFieldOffset()));
if(debug) { cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy); }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
offset = pvCopy->getCopyOffset(pvValueMaster);
if(debug) { cout << "getCopyOffset() " << offset; }
if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->clear();
convert->fromDouble(pvValueMaster,1.0);
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << "before updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->set(0);
testOk1(convert->toDouble(pvValueCopy)==0.06);
@@ -94,14 +88,14 @@ static void testPVScalar(
if(debug) { cout << "after updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
convert->fromDouble(pvValueCopy,2.0);
bitSet->set(0);
if(debug) { cout << "before updateMaster"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
testOk1(convert->toDouble(pvValueMaster)==1.0);
pvCopy->updateMaster(pvStructureCopy,bitSet);
@@ -109,14 +103,14 @@ static void testPVScalar(
if(debug) { cout << "after updateMaster"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
}
static void testPVScalarArray(
ScalarType scalarType,
String const & valueNameMaster,
String const & valueNameCopy,
string const & valueNameMaster,
string const & valueNameCopy,
PVStructurePtr const & pvMaster,
PVCopyPtr const & pvCopy)
{
@@ -124,7 +118,6 @@ static void testPVScalarArray(
PVScalarArrayPtr pvValueMaster;
PVScalarArrayPtr pvValueCopy;
BitSetPtr bitSet;
String builder;
size_t offset;
size_t n = 5;
shared_vector<double> values(n);
@@ -135,14 +128,12 @@ static void testPVScalarArray(
const shared_vector<const double> xxx(freeze(values));
pvValueMaster->putFrom(xxx);
StructureConstPtr structure = pvCopy->getStructure();
builder.clear(); structure->toString(&builder);
if(debug) { cout << "structure from copy" << endl << builder << endl;}
if(debug) { cout << "structure from copy" << endl << *structure << endl;}
pvStructureCopy = pvCopy->createPVStructure();
pvValueCopy = pvStructureCopy->getScalarArrayField(valueNameCopy,scalarType);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << "after initCopy pvValueCopy " << builder << endl; }
if(debug) { cout << "after initCopy pvValueCopy " << *pvValueCopy << endl; }
if(debug) { cout << endl; }
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + .06;
@@ -153,35 +144,24 @@ static void testPVScalarArray(
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
pvValueCopy->getAs(cvalues);
testOk1(cvalues[0]==0.06);
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << "after put(i+ .06) pvValueCopy " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << "after put(i+ .06) pvValueCopy " << *pvValueCopy << endl; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
offset = pvCopy->getCopyOffset(pvValueMaster);
if(debug) { cout << "getCopyOffset() " << offset; }
if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->clear();
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + 1.0;
const shared_vector<const double> zzz(freeze(values));
pvValueMaster->putFrom(zzz);
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << "before updateCopyFromBitSet"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
if(debug) { cout << " bitSet " << builder; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->set(0);
pvValueCopy->getAs(cvalues);
@@ -190,13 +170,9 @@ static void testPVScalarArray(
pvValueCopy->getAs(cvalues);
testOk1(cvalues[0]==1.0);
if(debug) { cout << "after updateCopyFromBitSet"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
values.resize(n);
for(size_t i=0; i<n; i++) values[i] = i + 2.0;
@@ -204,27 +180,19 @@ static void testPVScalarArray(
pvValueMaster->putFrom(ttt);
bitSet->set(0);
if(debug) { cout << "before updateMaster"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
pvValueMaster->getAs(cvalues);
testOk1(cvalues[0]==2.0);
pvCopy->updateMaster(pvStructureCopy,bitSet);
pvValueMaster->getAs(cvalues);
testOk1(cvalues[0]==1.0);
if(debug) { cout << "after updateMaster"; }
builder.clear(); pvValueMaster->toString(&builder);
if(debug) { cout << " masterValue " << builder << endl; }
builder.clear(); pvValueCopy->toString(&builder);
if(debug) { cout << " copyValue " << builder << endl; }
builder.clear();
bitSet->toString(&builder);
if(debug) { cout << " bitSet " << builder; }
if(debug) { cout << "before updateMaster"; }
if(debug) { cout << " masterValue " << *pvValueMaster << endl; }
if(debug) { cout << " copyValue " << *pvValueCopy << endl; }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
}
@@ -232,12 +200,12 @@ static void scalarTest()
{
if(debug) { cout << endl << endl << "****scalarTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String valueNameMaster;
String valueNameCopy;
string valueNameMaster;
string valueNameCopy;
StandardPVFieldPtr standardPVField = getStandardPVField();
pvMaster = standardPVField->scalar(pvDouble,"alarm,timeStamp,display");
@@ -272,12 +240,12 @@ static void arrayTest()
{
if(debug) { cout << endl << endl << "****arrayTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String valueNameMaster;
String valueNameCopy;
string valueNameMaster;
string valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
StandardPVFieldPtr standardPVField = getStandardPVField();
@@ -322,7 +290,7 @@ static PVStructurePtr createPowerSupply()
powerSupply.push_back(standardField->alarm());
names.push_back("timeStamp");
powerSupply.push_back(standardField->timeStamp());
String properties("alarm,display");
string properties("alarm,display");
names.push_back("voltage");
powerSupply.push_back(standardField->scalar(pvDouble,properties));
names.push_back("power");
@@ -339,13 +307,13 @@ static void powerSupplyTest()
{
if(debug) { cout << endl << endl << "****powerSupplyTest****" << endl; }
PVStructurePtr pvMaster;
String request;
string request;
PVStructurePtr pvRequest;
PVFieldPtr pvMasterField;
PVCopyPtr pvCopy;
String builder;
String valueNameMaster;
String valueNameCopy;
string builder;
string valueNameMaster;
string valueNameCopy;
CreateRequest::shared_pointer createRequest = CreateRequest::create();
pvMaster = createPowerSupply();

View File

@@ -12,12 +12,22 @@
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <sstream>
#include <pv/bitSet.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace epics::pvData;
using std::string;
static string toString(BitSet& bitSet)
{
std::ostringstream oss;
oss << bitSet;
return oss.str();
}
static void testGetSetClearFlip()
{
@@ -28,7 +38,7 @@ static void testGetSetClearFlip()
testOk1(b1->isEmpty());
testOk1(b1->cardinality() == 0);
// to string check
std::string str; b1->toString(&str);
string str = toString(*b1);
testOk1(str == "{}");
// one
@@ -37,7 +47,7 @@ static void testGetSetClearFlip()
testOk1(!b1->isEmpty());
testOk1(b1->cardinality() == 1);
// to string check
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3}");
// grow
@@ -45,34 +55,34 @@ static void testGetSetClearFlip()
b1->set(67);
b1->set(68);
testOk1(b1->cardinality() == 4);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 66, 67, 68}");
// clear one
b1->clear(67);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 66, 68}");
// flip
b1->flip(66);
b1->flip(130);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 68, 130}");
// flip
b1->set(130, false);
b1->set(4, true);
testOk1(b1->cardinality() == 3);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{3, 4, 68}");
// clear all
b1->clear();
testOk1(b1->isEmpty());
testOk1(b1->cardinality() == 0);
str.clear(); b1->toString(&str);
str = toString(*b1);
testOk1(str == "{}");
delete b1;
@@ -101,11 +111,11 @@ static void testOperators()
b2.set(106);
b2.set(105);
b1 |= b2;
std::string str; b1.toString(&str);
string str = toString(b1);
testOk1(str == "{1, 65, 105, 106}");
b1.clear();
b1 |= b2;
str.clear(); b1.toString(&str);
str = toString(b1);
testOk1(str == "{1, 65, 105, 106}");
// AND test
@@ -134,7 +144,7 @@ static void testOperators()
b2.clear(); b2.set(66); b2.set(128);
BitSet b3; b3.set(128); b3.set(520);
b1.or_and(b2, b3);
str.clear(); b1.toString(&str);
str = toString(b1);
testOk1(str == "{2, 128}");
}

View File

@@ -21,6 +21,7 @@
#include <pv/pvIntrospect.h>
using namespace epics::pvData;
using std::string;
using std::cout;
void testBasicOperations() {
@@ -197,7 +198,7 @@ void testBasicOperations() {
testOk1(buff->getPosition()==6);
testOk1(strncmp(&src[2],&dst[2],6)==0);
cout<<" First 10 characters of destination: >>"<<String(dst, 10)<<"<<\n";
cout<<" First 10 characters of destination: >>"<<string(dst, 10)<<"<<\n";
delete buff;

View File

@@ -21,6 +21,7 @@
#include <epicsAssert.h>
using namespace epics::pvData;
using std::string;
using std::cout;
using std::endl;
@@ -28,8 +29,8 @@ static StandardPVFieldPtr standardPVField = getStandardPVField();
void test()
{
String buffer;
String properties("alarm,timeStamp,display");
string buffer;
string properties("alarm,timeStamp,display");
PVStructurePtr pvStructure = standardPVField->scalar(pvDouble,properties);
PVDoublePtr pvValue = pvStructure->getDoubleField("value");
uint32 valueOffset = (uint32) pvValue->getFieldOffset();

View File

@@ -51,6 +51,7 @@
#define DOUBLE_MIN_VALUE std::numeric_limits<double>::min()
using namespace epics::pvData;
using std::string;
namespace {
@@ -135,12 +136,10 @@ void serializationTest(PVFieldPtr const & field) {
testPass("Serialization round trip OK");
else {
testFail("Serialization round trip did not match!");
std::string buf;
field->toString(&buf);
testDiag("Expected: %s", buf.c_str());
buf.clear();
deserializedField->toString(&buf);
testDiag("Found: %s", buf.c_str());
std::ostringstream oss;
oss << "Expected: " << *field << std::endl;
oss << "Found : " << *deserializedField << std::endl;
testDiag("Found: %s", oss.str().c_str());
}
}
@@ -300,7 +299,7 @@ void testScalar() {
serializationTest(pvString);
// huge string test
pvString->put(String(10000, 'a'));
pvString->put(string(10000, 'a'));
serializationTest(pvString);
}
@@ -347,7 +346,7 @@ static const float fdata[] = { (float)0.0, (float)1.1, (float)2.3, (float)-1.4,
FLOAT_MAX_VALUE, FLOAT_MAX_VALUE-(float)123456.789,
FLOAT_MIN_VALUE+(float)1.1, FLOAT_MIN_VALUE };
static const String sdata[] = {
static const string sdata[] = {
"",
"a",
"a b",
@@ -355,7 +354,7 @@ static const String sdata[] = {
"test",
"smile",
"this is a little longer string... maybe a little but longer... this makes test better",
String(10000, 'b')
string(10000, 'b')
};
void testArray() {
@@ -701,10 +700,10 @@ void testIntrospectionSerialization()
}
void testStringCopy() {
String s1 = "abc";
String s2 = s1;
string s1 = "abc";
string s2 = s1;
if (s1.c_str() != s2.c_str())
testDiag("implementation of epics::pvData::String assignment operator does not share content");
testDiag("implementation of string assignment operator does not share content");
}
} // end namespace

View File

@@ -18,6 +18,8 @@
#include "pv/sharedVector.h"
using std::string;
static void testEmpty()
{
testDiag("Test empty vector");
@@ -376,7 +378,7 @@ static void testNonPOD()
{
testDiag("Test vector of non-POD types");
epics::pvData::shared_vector<std::string> strings(6);
epics::pvData::shared_vector<string> strings(6);
epics::pvData::shared_vector<std::tr1::shared_ptr<dummyStruct> > structs(5);
testOk1(strings[0].empty());
@@ -406,7 +408,7 @@ static void testVectorConvert()
epics::pvData::shared_vector<int> ints(6, 42), moreints;
epics::pvData::shared_vector<float> floats;
epics::pvData::shared_vector<std::string> strings;
epics::pvData::shared_vector<string> strings;
epics::pvData::shared_vector<void> voids;
testOk1(ints.unique());
@@ -435,7 +437,7 @@ static void testVectorConvert()
// convert from void uses shared_vector<void>::original_type()
// to find that the actual type is 'int'.
// returns a new vector
strings = epics::pvData::shared_vector_convert<std::string>(voids);
strings = epics::pvData::shared_vector_convert<string>(voids);
voids.clear();

View File

@@ -27,8 +27,9 @@
#include <pv/timeFunction.h>
using namespace epics::pvData;
using std::string;
static String actionName("action");
static string actionName("action");
class Action;
typedef std::tr1::shared_ptr<Action> ActionPtr;
@@ -101,7 +102,7 @@ private:
typedef std::tr1::shared_ptr<Basic> BasicPtr;
static void testBasic() {
ExecutorPtr executor(new Executor(String("basic"),middlePriority));
ExecutorPtr executor(new Executor(string("basic"),middlePriority));
BasicPtr basic( new Basic(executor));
basic->run();
printf("testBasic PASSED\n");
@@ -130,7 +131,7 @@ typedef std::tr1::shared_ptr<MyFunc> MyFuncPtr;
#ifdef TESTTHREADCONTEXT
static void testThreadContext() {
ExecutorPtr executor(new Executor(String("basic"),middlePriority));
ExecutorPtr executor(new Executor(string("basic"),middlePriority));
BasicPtr basic(new Basic(executor));
MyFuncPtr myFunc(new MyFunc(basic));
TimeFunctionPtr timeFunction(new TimeFunction(myFunc));

View File

@@ -15,6 +15,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <iostream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -25,6 +26,7 @@
#include <pv/thread.h>
using namespace epics::pvData;
using std::string;
static TimeStamp currentTimeStamp;
static double oneDelay = 4.0;
@@ -39,7 +41,7 @@ typedef std::tr1::shared_ptr<MyCallback> MyCallbackPtr;
class MyCallback : public TimerCallback {
public:
POINTER_DEFINITIONS(MyCallback);
MyCallback(String name,EventPtr const & wait)
MyCallback(string name,EventPtr const & wait)
: name(name),
wait(wait)
{
@@ -58,7 +60,7 @@ public:
}
TimeStamp &getTimeStamp() { return timeStamp;}
private:
String name;
string name;
EventPtr wait;
TimeStamp timeStamp;
};
@@ -69,13 +71,13 @@ static void testBasic()
printf("\n\ntestBasic oneDelay %lf twoDelay %lf threeDaley %lf\n",
oneDelay,twoDelay,threeDelay);
}
String one("one");
String two("two");
String three("three");
string one("one");
string two("two");
string three("three");
EventPtr eventOne(new Event());
EventPtr eventTwo(new Event());
EventPtr eventThree(new Event());
TimerPtr timer(new Timer(String("timer"),middlePriority));
TimerPtr timer(new Timer(string("timer"),middlePriority));
MyCallbackPtr callbackOne(new MyCallback(one,eventOne));
MyCallbackPtr callbackTwo(new MyCallback(two,eventTwo));
MyCallbackPtr callbackThree(new MyCallback(three,eventThree));
@@ -91,9 +93,8 @@ static void testBasic()
if(twoDelay>.1) testOk1(timer->isScheduled(callbackTwo));
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
if(debug) {
String builder;
timer->toString(&builder);
printf("timerQueue\n%s",builder.c_str());
std::cout << "timerQueue" << std::endl;
std::cout << *timer;
}
eventOne->wait();
eventTwo->wait();
@@ -137,13 +138,13 @@ static void testCancel()
printf("\n\ntestCancel oneDelay %lf twoDelay %lf threeDaley %lf\n",
oneDelay,twoDelay,threeDelay);
}
String one("one");
String two("two");
String three("three");
string one("one");
string two("two");
string three("three");
EventPtr eventOne(new Event());
EventPtr eventTwo(new Event());
EventPtr eventThree(new Event());
TimerPtr timer(new Timer(String("timer"),middlePriority));
TimerPtr timer(new Timer(string("timer"),middlePriority));
MyCallbackPtr callbackOne(new MyCallback(one,eventOne));
MyCallbackPtr callbackTwo(new MyCallback(two,eventTwo));
MyCallbackPtr callbackThree(new MyCallback(three,eventThree));
@@ -160,9 +161,8 @@ static void testCancel()
testOk1(!timer->isScheduled(callbackTwo));
if(threeDelay>.1) testOk1(timer->isScheduled(callbackThree));
if(debug) {
String builder;
timer->toString(&builder);
printf("timerQueue\n%s",builder.c_str());
std::cout << "timerQueue" << std::endl;
std::cout << *timer;
}
eventOne->wait();
eventThree->wait();

View File

@@ -27,7 +27,7 @@
#include "pv/typeCast.h"
using epics::pvData::String;
using std::string;
namespace {
@@ -131,11 +131,11 @@ try {
uint64_t xuint64=0;
float xfloat=0.0;
double xdouble=0.0;
epics::pvData::String xString("0");
string xstring("0");
typedef float float_t;
typedef double double_t;
typedef epics::pvData::String String_t;
typedef string string_t;
// force all possibilities to be compiled
#define CHECK(M, N) x## M = ::epics::pvData::castUnsafe<M ##_t>(x## N); \
@@ -151,7 +151,7 @@ try {
CHECK(int8, uint64);
CHECK(int8, float);
CHECK(int8, double);
CHECK(int8, String);
CHECK(int8, string);
CHECK(uint8, int8);
CHECK(uint8, uint8);
@@ -163,7 +163,7 @@ try {
CHECK(uint8, uint64);
CHECK(uint8, float);
CHECK(uint8, double);
CHECK(uint8, String);
CHECK(uint8, string);
CHECK(int16, int8);
CHECK(int16, uint8);
@@ -175,7 +175,7 @@ try {
CHECK(int16, uint64);
CHECK(int16, float);
CHECK(int16, double);
CHECK(int16, String);
CHECK(int16, string);
CHECK(uint16, int8);
CHECK(uint16, uint8);
@@ -187,7 +187,7 @@ try {
CHECK(uint16, uint64);
CHECK(uint16, float);
CHECK(uint16, double);
CHECK(uint16, String);
CHECK(uint16, string);
CHECK(int32, int8);
CHECK(int32, uint8);
@@ -199,7 +199,7 @@ try {
CHECK(int32, uint64);
CHECK(int32, float);
CHECK(int32, double);
CHECK(int32, String);
CHECK(int32, string);
CHECK(uint32, int8);
CHECK(uint32, uint8);
@@ -211,7 +211,7 @@ try {
CHECK(uint32, uint64);
CHECK(uint32, float);
CHECK(uint32, double);
CHECK(uint32, String);
CHECK(uint32, string);
CHECK(int64, int8);
CHECK(int64, uint8);
@@ -223,7 +223,7 @@ try {
CHECK(int64, uint64);
CHECK(int64, float);
CHECK(int64, double);
//CHECK(int64, String);
//CHECK(int64, string);
CHECK(uint64, int8);
CHECK(uint64, uint8);
@@ -235,7 +235,7 @@ try {
CHECK(uint64, uint64);
CHECK(uint64, float);
CHECK(uint64, double);
//CHECK(uint64, String);
//CHECK(uint64, string);
CHECK(float, int8);
CHECK(float, uint8);
@@ -247,7 +247,7 @@ try {
CHECK(float, uint64);
CHECK(float, float);
CHECK(float, double);
CHECK(float, String);
CHECK(float, string);
CHECK(double, int8);
CHECK(double, uint8);
@@ -259,19 +259,19 @@ try {
CHECK(double, uint64);
CHECK(double, float);
CHECK(double, double);
CHECK(double, String);
CHECK(double, string);
CHECK(String, int8);
CHECK(String, uint8);
CHECK(String, int16);
CHECK(String, uint16);
CHECK(String, int32);
CHECK(String, uint32);
CHECK(String, int64);
CHECK(String, uint64);
CHECK(String, float);
CHECK(String, double);
CHECK(String, String);
CHECK(string, int8);
CHECK(string, uint8);
CHECK(string, int16);
CHECK(string, uint16);
CHECK(string, int32);
CHECK(string, uint32);
CHECK(string, int64);
CHECK(string, uint64);
CHECK(string, float);
CHECK(string, double);
CHECK(string, string);
#undef CHECK
testDiag("Integer signed <=> unsigned");
@@ -309,91 +309,91 @@ try {
TEST(int32_t, -2, float, -2.5f);
TEST(int32_t, -2, float, -2.7f);
testDiag("String Printing/parsing");
testDiag("string Printing/parsing");
TEST2(String, "1", int32_t, 1);
TEST2(String, "-1", int32_t, -1);
TEST2(String, "1", int8_t, 1);
TEST2(String, "-1", int8_t, -1);
TEST2(String, "1", uint8_t, 1);
TEST2(string, "1", int32_t, 1);
TEST2(string, "-1", int32_t, -1);
TEST2(string, "1", int8_t, 1);
TEST2(string, "-1", int8_t, -1);
TEST2(string, "1", uint8_t, 1);
TEST2(String, "127", int32_t, std::numeric_limits<int8_t>::max());
TEST2(String, "-128", int32_t, std::numeric_limits<int8_t>::min());
TEST2(String, "255", int32_t, std::numeric_limits<uint8_t>::max());
TEST2(string, "127", int32_t, std::numeric_limits<int8_t>::max());
TEST2(string, "-128", int32_t, std::numeric_limits<int8_t>::min());
TEST2(string, "255", int32_t, std::numeric_limits<uint8_t>::max());
TEST2(String, "32767", int32_t, std::numeric_limits<int16_t>::max());
TEST2(String, "-32768", int32_t, std::numeric_limits<int16_t>::min());
TEST2(String, "65535", int32_t, std::numeric_limits<uint16_t>::max());
TEST2(string, "32767", int32_t, std::numeric_limits<int16_t>::max());
TEST2(string, "-32768", int32_t, std::numeric_limits<int16_t>::min());
TEST2(string, "65535", int32_t, std::numeric_limits<uint16_t>::max());
TEST2(String, "2147483647", int32_t, std::numeric_limits<int32_t>::max());
TEST2(String, "-2147483648", int32_t, std::numeric_limits<int32_t>::min());
TEST2(String, "4294967295", uint32_t, std::numeric_limits<uint32_t>::max());
TEST2(string, "2147483647", int32_t, std::numeric_limits<int32_t>::max());
TEST2(string, "-2147483648", int32_t, std::numeric_limits<int32_t>::min());
TEST2(string, "4294967295", uint32_t, std::numeric_limits<uint32_t>::max());
TEST2(String, "9223372036854775807", int64_t, std::numeric_limits<int64_t>::max());
TEST2(String, "-9223372036854775808", int64_t, std::numeric_limits<int64_t>::min());
TEST2(String, "18446744073709551615", uint64_t, std::numeric_limits<uint64_t>::max());
TEST2(string, "9223372036854775807", int64_t, std::numeric_limits<int64_t>::max());
TEST2(string, "-9223372036854775808", int64_t, std::numeric_limits<int64_t>::min());
TEST2(string, "18446744073709551615", uint64_t, std::numeric_limits<uint64_t>::max());
TEST2(String, "1.1", double, 1.1);
TEST2(String, "1.1e+100", double, 1.1e100);
TEST2(String, "1.1e-100", double, 1.1e-100);
TEST2(string, "1.1", double, 1.1);
TEST2(string, "1.1e+100", double, 1.1e100);
TEST2(string, "1.1e-100", double, 1.1e-100);
TEST(double, 1.1e100, String, "1.1E+100");
TEST(double, 1.1e100, string, "1.1E+100");
// any non-zero value is true
TEST(String, "true", epics::pvData::boolean, 100);
TEST(string, "true", epics::pvData::boolean, 100);
TEST2(String, "true", epics::pvData::boolean, 1);
TEST2(String, "false", epics::pvData::boolean, 0);
TEST2(string, "true", epics::pvData::boolean, 1);
TEST2(string, "false", epics::pvData::boolean, 0);
// Case insensitive
TEST(epics::pvData::boolean, 1, String, "True");
TEST(epics::pvData::boolean, 0, String, "False");
TEST(epics::pvData::boolean, 1, String, "TRUE");
TEST(epics::pvData::boolean, 0, String, "FALSE");
TEST(epics::pvData::boolean, 1, string, "True");
TEST(epics::pvData::boolean, 0, string, "False");
TEST(epics::pvData::boolean, 1, string, "TRUE");
TEST(epics::pvData::boolean, 0, string, "FALSE");
testDiag("String Parsing");
testDiag("string Parsing");
TEST(int32_t, 15, String, "0xf");
TEST(int32_t, 15, String, "0xF");
TEST(int32_t, -15, String, "-0xF");
TEST(int32_t, 16, String, "0x10");
TEST(int32_t, -16, String, "-0x10");
TEST(int32_t, 15, string, "0xf");
TEST(int32_t, 15, string, "0xF");
TEST(int32_t, -15, string, "-0xF");
TEST(int32_t, 16, string, "0x10");
TEST(int32_t, -16, string, "-0x10");
TEST(int32_t, 7, String, "07");
TEST(int32_t, 8, String, "010");
TEST(int32_t, -7, String, "-07");
TEST(int32_t, -8, String, "-010");
TEST(int32_t, 7, string, "07");
TEST(int32_t, 8, string, "010");
TEST(int32_t, -7, string, "-07");
TEST(int32_t, -8, string, "-010");
TEST(int64_t, 15, String, "0xf");
TEST(int64_t, 15, String, "0xF");
TEST(int64_t, -15, String, "-0xF");
TEST(int64_t, 16, String, "0x10");
TEST(int64_t, -16, String, "-0x10");
TEST(int64_t, 15, string, "0xf");
TEST(int64_t, 15, string, "0xF");
TEST(int64_t, -15, string, "-0xF");
TEST(int64_t, 16, string, "0x10");
TEST(int64_t, -16, string, "-0x10");
TEST(int64_t, 7, String, "07");
TEST(int64_t, 8, String, "010");
TEST(int64_t, -7, String, "-07");
TEST(int64_t, -8, String, "-010");
TEST(int64_t, 7, string, "07");
TEST(int64_t, 8, string, "010");
TEST(int64_t, -7, string, "-07");
TEST(int64_t, -8, string, "-010");
testDiag("String parsing errors");
testDiag("string parsing errors");
FAIL(int32_t, String, "hello!");
FAIL(int32_t, String, "42 is the answer");
FAIL(int64_t, String, "hello!");
FAIL(int64_t, String, "42 is the answer");
FAIL(double, String, "hello!");
FAIL(double, String, "42 is the answer");
FAIL(int32_t, string, "hello!");
FAIL(int32_t, string, "42 is the answer");
FAIL(int64_t, string, "hello!");
FAIL(int64_t, string, "42 is the answer");
FAIL(double, string, "hello!");
FAIL(double, string, "42 is the answer");
FAIL(int8_t, String, "1000");
FAIL(int8_t, String, "-1000");
FAIL(int8_t, string, "1000");
FAIL(int8_t, string, "-1000");
FAIL(double, String, "1e+10000000");
FAIL(double, string, "1e+10000000");
FAIL(epics::pvData::boolean, String, "hello");
FAIL(epics::pvData::boolean, String, "1");
FAIL(epics::pvData::boolean, String, "0");
FAIL(epics::pvData::boolean, String, "T");
FAIL(epics::pvData::boolean, String, "F");
FAIL(epics::pvData::boolean, string, "hello");
FAIL(epics::pvData::boolean, string, "1");
FAIL(epics::pvData::boolean, string, "0");
FAIL(epics::pvData::boolean, string, "T");
FAIL(epics::pvData::boolean, string, "F");
testDiag("Floating point overflows");
@@ -406,10 +406,10 @@ try {
testOk(isnan( xfloat ), "Test cast double NAN to float NAN yields: %f", xfloat);
{
std::string result[3];
string result[3];
const int32_t in[3] = { 1234, 506001, 42424242 };
testDiag("Test vcast int32 -> String");
testDiag("Test vcast int32 -> string");
epics::pvData::castUnsafeV(3, epics::pvData::pvString, (void*)result,
epics::pvData::pvInt, (void*)in);
testDiag("Yields %s %s %s", result[0].c_str(), result[1].c_str(), result[2].c_str());

View File

@@ -33,6 +33,7 @@
#include <pv/pvTimeStamp.h>
using namespace epics::pvData;
using std::string;
static bool debug = false;
@@ -41,9 +42,8 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder;
static String alarmTimeStamp("alarm,timeStamp");
static String allProperties("alarm,timeStamp,display,control");
static string alarmTimeStamp("alarm,timeStamp");
static string allProperties("alarm,timeStamp,display,control");
static PVStructurePtr doubleRecord;
static PVStructurePtr enumeratedRecord;
@@ -51,11 +51,8 @@ static PVStructurePtr enumeratedRecord;
static void createRecords()
{
doubleRecord = standardPVField->scalar(pvDouble,allProperties);
if(debug) {
builder.clear();
doubleRecord->toString(&builder);
printf("doubleRecord\n%s\n",builder.c_str());
}
if(debug)
std::cout << "doubleRecord" << std::endl << *doubleRecord << std::endl;
StringArray choices;
choices.reserve(4);
choices.push_back("1");
@@ -63,23 +60,14 @@ static void createRecords()
choices.push_back("3");
choices.push_back("4");
enumeratedRecord = standardPVField->enumerated(choices,alarmTimeStamp);
if(debug) {
builder.clear();
enumeratedRecord->toString(&builder);
printf("enumeratedRecord\n%s\n",builder.c_str());
}
if(debug)
std::cout << "enumeratedRecord" << std::endl << *doubleRecord << std::endl;
}
static void printRecords()
{
printf("doubleRecord\n");
builder.clear();
doubleRecord->toString(&builder);
printf("%s\n",builder.c_str());
printf("enumeratedRecord\n");
builder.clear();
enumeratedRecord->toString(&builder);
printf("%s\n",builder.c_str());
std::cout << "doubleRecord" << std::endl << *doubleRecord << std::endl;
std::cout << "enumeratedRecord" << std::endl << *doubleRecord << std::endl;
}
static void testAlarm()
@@ -88,7 +76,7 @@ static void testAlarm()
Alarm alarm;
PVAlarm pvAlarm;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("alarm"));
PVFieldPtr pvField = doubleRecord->getSubField(string("alarm"));
if(pvField.get()==NULL) {
printf("testAlarm ERROR did not find field alarm\n");
return;
@@ -96,7 +84,7 @@ static void testAlarm()
result = pvAlarm.attach(pvField);
testOk1(result);
Alarm al;
al.setMessage(String("testMessage"));
al.setMessage(string("testMessage"));
al.setSeverity(majorAlarm);
al.setStatus(clientStatus);
result = pvAlarm.set(al);
@@ -105,9 +93,9 @@ static void testAlarm()
testOk1(al.getMessage().compare(alarm.getMessage())==0);
testOk1(al.getSeverity()==alarm.getSeverity());
testOk1(al.getStatus()==alarm.getStatus());
String message = alarm.getMessage();
String severity = (*AlarmSeverityFunc::getSeverityNames())[alarm.getSeverity()];
String status = (*AlarmStatusFunc::getStatusNames())[alarm.getStatus()];
string message = alarm.getMessage();
string severity = (*AlarmSeverityFunc::getSeverityNames())[alarm.getSeverity()];
string status = (*AlarmStatusFunc::getStatusNames())[alarm.getStatus()];
if(debug) {
printf(" message %s severity %s status %s\n",
message.c_str(),severity.c_str(),status.c_str());
@@ -121,7 +109,7 @@ static void testTimeStamp()
TimeStamp timeStamp;
PVTimeStamp pvTimeStamp;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("timeStamp"));
PVFieldPtr pvField = doubleRecord->getSubField(string("timeStamp"));
if(pvField.get()==NULL) {
printf("testTimeStamp ERROR did not find field timeStamp\n");
return;
@@ -161,7 +149,7 @@ static void testControl()
Control control;
PVControl pvControl;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("control"));
PVFieldPtr pvField = doubleRecord->getSubField(string("control"));
if(pvField.get()==NULL) {
printf("testControl ERROR did not find field control\n");
return;
@@ -188,7 +176,7 @@ static void testDisplay()
Display display;
PVDisplay pvDisplay;
bool result;
PVFieldPtr pvField = doubleRecord->getSubField(String("display"));
PVFieldPtr pvField = doubleRecord->getSubField(string("display"));
if(pvField.get()==NULL) {
printf("testDisplay ERROR did not find field display\n");
return;
@@ -198,9 +186,9 @@ static void testDisplay()
Display dy;
dy.setLow(-10.0);
dy.setHigh(-1.0);
dy.setDescription(String("testDescription"));
dy.setFormat(String("%f10.0"));
dy.setUnits(String("volts"));
dy.setDescription(string("testDescription"));
dy.setFormat(string("%f10.0"));
dy.setUnits(string("volts"));
result = pvDisplay.set(dy);
testOk1(result);
pvDisplay.get(display);
@@ -220,7 +208,7 @@ static void testEnumerated()
if(debug) printf("testEnumerated\n");
PVEnumerated pvEnumerated;
bool result;
PVFieldPtr pvField = enumeratedRecord->getSubField(String("value"));
PVFieldPtr pvField = enumeratedRecord->getSubField(string("value"));
if(pvField.get()==NULL) {
printf("testEnumerated ERROR did not find field enumerated\n");
return;
@@ -228,7 +216,7 @@ static void testEnumerated()
result = pvEnumerated.attach(pvField);
testOk1(result);
int32 index = pvEnumerated.getIndex();
String choice = pvEnumerated.getChoice();
string choice = pvEnumerated.getChoice();
PVStringArray::const_svector choices = pvEnumerated.getChoices();
int32 numChoices = pvEnumerated.getNumberChoices();
if(debug) {

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -22,6 +23,7 @@
#include <pv/standardPVField.h>
using namespace epics::pvData;
using std::string;
using std::tr1::static_pointer_cast;
static bool debug = false;
@@ -31,10 +33,11 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder("");
static void test()
{
std::ostringstream oss;
if(debug) printf("\ntestBitSetUtil\n");
StringArray fieldNames;
PVFieldPtrArray pvFields;
@@ -60,19 +63,28 @@ static void test()
standardField->scalar(pvDouble,"alarm")));
PVStructurePtr pvs = pvDataCreate->createPVStructure(
fieldNames,pvFields);
builder.clear();
pvs->toString(&builder);
if(debug) printf("pvs\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "pvs" << std::endl;
oss << *pvs << std::endl;
std::cout << oss.str();
}
int32 nfields = (int32)pvs->getNumberFields();
BitSetPtr bitSet = BitSet::create(nfields);
for(int32 i=0; i<nfields; i++) bitSet->set(i);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
bitSet->clear();
PVFieldPtr pvField = pvs->getSubField("timeStamp");
int32 offsetTimeStamp = (int32)pvField->getFieldOffset();
@@ -87,15 +99,21 @@ static void test()
testOk1(bitSet->get(offsetSeconds)==true);
bitSet->set(offsetNano);
bitSet->set(offsetUserTag);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
testOk1(bitSet->get(offsetSeconds)==false);
testOk1(bitSet->get(offsetTimeStamp)==true);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
bitSet->clear();
pvField = pvs->getSubField("current");
@@ -114,25 +132,37 @@ static void test()
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
testOk1(bitSet->get(offsetCurrent)==true);
bitSet->clear();
bitSet->set(offsetSeverity);
bitSet->set(offsetStatus);
bitSet->set(offsetMessage);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
BitSetUtil::compress(bitSet,pvs);
builder.clear();
bitSet->toString(&builder);
if(debug) printf("bitSet\n%s\n",builder.c_str());
if(debug) {
oss.clear();
oss << "bitSet" << std::endl;
oss << *bitSet << std::endl;
std::cout << oss.str();
}
testOk1(bitSet->get(offsetAlarm)==true);
bitSet->clear();
printf("testBitSetUtil PASSED\n");

View File

@@ -31,7 +31,7 @@ void test_structure()
FieldBuilderPtr fb = fieldCreate->createFieldBuilder();
// test with simple (non-nested) structure
std::string ID = "testStructureID";
string ID = "testStructureID";
StructureConstPtr s = fb->setId(ID)->
add("double", pvDouble)->
addArray("intArray", pvInt)->
@@ -116,7 +116,7 @@ void test_nestedStructure()
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
addNestedStructure("nested")->
@@ -172,7 +172,7 @@ void test_nestedStructureArray()
FieldCreatePtr fieldCreate = getFieldCreate();
std::string NESTED_ID = "nestedID";
string NESTED_ID = "nestedID";
StructureConstPtr s = fieldCreate->createFieldBuilder()->
add("double", pvDouble)->
addNestedStructureArray("nested")->

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -21,6 +22,7 @@
#include <pv/standardField.h>
using namespace epics::pvData;
using std::string;
static FieldCreatePtr fieldCreate;
static PVDataCreatePtr pvDataCreate;
@@ -29,13 +31,14 @@ static StandardFieldPtr standardField;
static void testScalarCommon(ScalarType stype,
bool isInteger,bool isNumeric,bool isPrimitive)
{
String builder;
ScalarConstPtr pscalar = fieldCreate->createScalar(stype);
Type type = pscalar->getType();
testOk1(type==scalar);
builder.clear();
TypeFunc::toString(&builder,type);
testOk1(builder.compare("scalar")==0);
std::ostringstream oss;
oss << type;
testOk1(oss.str().compare("scalar")==0);
ScalarType scalarType = pscalar->getScalarType();
testOk1(scalarType==stype);
testOk1(ScalarTypeFunc::isInteger(scalarType)==isInteger);
@@ -58,13 +61,14 @@ static void testScalar() {
static void testScalarArrayCommon(ScalarType stype,
bool isInteger,bool isNumeric,bool isPrimitive)
{
String builder;
ScalarArrayConstPtr pscalar = fieldCreate->createScalarArray(stype);
Type type = pscalar->getType();
testOk1(type==scalarArray);
builder.clear();
TypeFunc::toString(&builder,type);
testOk1(builder.compare("scalarArray")==0);
std::ostringstream oss;
oss << type;
testOk1(oss.str().compare("scalarArray")==0);
ScalarType scalarType = pscalar->getElementType();
testOk1(scalarType==stype);
testOk1(ScalarTypeFunc::isInteger(scalarType)==isInteger);
@@ -246,7 +250,7 @@ static void testMapping()
OP(uint64, pvULong)
OP(float, pvFloat)
OP(double, pvDouble)
OP(String, pvString)
OP(string, pvString)
#undef OP
testOk1((ScalarType)ScalarTypeID<PVField>::value==(ScalarType)-1);

View File

@@ -11,11 +11,13 @@
#include <pv/pvData.h>
#include <pv/standardField.h>
#include <pv/standardPVField.h>
#include <pv/status.h>
#include <epicsUnitTest.h>
#include <testMain.h>
using namespace epics::pvData;
using std::string;
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardFieldPtr standardField = getStandardField();
@@ -37,12 +39,12 @@ MAIN(testOperators)
testOk1(testDV == dv);
const std::string testSV = "test message";
const string testSV = "test message";
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
*pvMessage <<= testSV;
std::string sv;
string sv;
*pvMessage >>= sv;
testOk1(testSV == sv);
@@ -54,6 +56,10 @@ MAIN(testOperators)
std::cout << *pvMessage << std::endl;
std::cout << *pvStructure << std::endl;
std::cout << *pvStructure->getStructure() << std::endl;
std::cout << Status::Ok << std::endl;
std::cout << Status::STATUSTYPE_OK << std::endl;
StringArray choices;
choices.reserve(3);

View File

@@ -24,6 +24,7 @@
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::string;
using std::cout;
using std::endl;
@@ -34,14 +35,14 @@ static PVDataCreatePtr pvDataCreate;
static StandardFieldPtr standardField;
static StandardPVFieldPtr standardPVField;
static ConvertPtr convert;
static String builder("");
static String alarmTimeStamp("alarm,timeStamp");
static String alarmTimeStampValueAlarm("alarm,timeStamp,valueAlarm");
static String allProperties("alarm,timeStamp,display,control,valueAlarm");
static string alarmTimeStamp("alarm,timeStamp");
static string alarmTimeStampValueAlarm("alarm,timeStamp,valueAlarm");
static string allProperties("alarm,timeStamp,display,control,valueAlarm");
static void testCreatePVStructure()
{
if(debug) printf("\ntestCreatePVStructure\n");
if(debug)
std::cout << std::endl << "testCreatePVStructure" << std::endl;
PVStructurePtr pv0 = standardPVField->scalar(
pvDouble,alarmTimeStampValueAlarm);
PVScalarPtr pv1 = pvDataCreate->createPVScalar(pvString);
@@ -55,27 +56,27 @@ static void testCreatePVStructure()
pvFields.push_back(pv1);
PVStructurePtr pvParent = pvDataCreate->createPVStructure(
fieldNames,pvFields);
builder.clear();
pvParent->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
printf("testCreatePVStructure PASSED\n");
if(debug)
std::cout << *pvParent << std::endl;
std::cout << "testCreatePVStructure PASSED" << std::endl;
}
static void testPVScalarCommon(String /*fieldName*/,ScalarType stype)
static void testPVScalarCommon(string /*fieldName*/,ScalarType stype)
{
PVScalarPtr pvScalar = pvDataCreate->createPVScalar(stype);
if(stype==pvBoolean) {
convert->fromString(pvScalar,String("true"));
convert->fromString(pvScalar,string("true"));
} else {
convert->fromString(pvScalar,String("10"));
convert->fromString(pvScalar,string("10"));
}
builder.clear();
pvScalar->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvScalar << std::endl;
}
static void testPVScalarWithProperties(
String /*fieldName*/,ScalarType stype)
string /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure;
bool hasValueAlarm = false;
@@ -190,137 +191,138 @@ static void testPVScalarWithProperties(
pvStructure = standardPVField->scalar(
stype,alarmTimeStamp);
PVStringPtr pvField = pvStructure->getStringField("value");
pvField->put(String("this is a string"));
pvField->put(string("this is a string"));
break;
}
}
PVLongPtr seconds = pvStructure->getLongField(
String("timeStamp.secondsPastEpoch"));
string("timeStamp.secondsPastEpoch"));
testOk1(seconds!=0);
seconds->put(123456789);
PVIntPtr nano = pvStructure->getIntField(String("timeStamp.nanoSeconds"));
PVIntPtr nano = pvStructure->getIntField(string("timeStamp.nanoSeconds"));
testOk1(nano!=0);
nano->put(1000000);
PVIntPtr severity = pvStructure->getIntField(String("alarm.severity"));
PVIntPtr severity = pvStructure->getIntField(string("alarm.severity"));
testOk1(severity!=0);
severity->put(2);
PVStringPtr message = pvStructure->getStringField(String("alarm.message"));
PVStringPtr message = pvStructure->getStringField(string("alarm.message"));
testOk1(message!=0);
message->put(String("messageForAlarm"));
message->put(string("messageForAlarm"));
if(hasDisplayControl) {
PVStringPtr desc = pvStructure->getStringField(
String("display.description"));
string("display.description"));
testOk1(desc!=0);
desc->put(String("this is a description"));
desc->put(string("this is a description"));
PVStringPtr format = pvStructure->getStringField(
String("display.format"));
string("display.format"));
testOk1(format!=0);
format->put(String("f10.2"));
format->put(string("f10.2"));
PVStringPtr units = pvStructure->getStringField(
String("display.units"));
string("display.units"));
testOk1(units!=0);
units->put(String("SomeUnits"));
units->put(string("SomeUnits"));
PVDoublePtr limit = pvStructure->getDoubleField(
String("display.limitLow"));
string("display.limitLow"));
testOk1(limit!=0);
limit->put(0.0);
limit = pvStructure->getDoubleField(
String("display.limitHigh"));
string("display.limitHigh"));
testOk1(limit!=0);
limit->put(10.0);
limit = pvStructure->getDoubleField(
String("control.limitLow"));
string("control.limitLow"));
testOk1(limit!=0);
limit->put(1.0);
limit = pvStructure->getDoubleField(
String("control.limitHigh"));
string("control.limitHigh"));
testOk1(limit!=0);
limit->put(9.0);
}
if(hasValueAlarm) {
PVFieldPtr pvField = pvStructure->getSubField(
String("valueAlarm.active"));
string("valueAlarm.active"));
PVBooleanPtr pvBoolean = static_pointer_cast<PVBoolean>(pvField);
pvBoolean->put(true);
pvField = pvStructure->getSubField(
String("valueAlarm.lowAlarmLimit"));
string("valueAlarm.lowAlarmLimit"));
PVScalarPtr pvtemp = static_pointer_cast<PVScalar>(pvField);
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,1.0);
pvField = pvStructure->getSubField(
String("valueAlarm.highAlarmLimit"));
string("valueAlarm.highAlarmLimit"));
pvtemp = static_pointer_cast<PVScalar>(pvField);
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,9.0);
severity = pvStructure->getIntField(
String("valueAlarm.lowAlarmSeverity"));
string("valueAlarm.lowAlarmSeverity"));
testOk1(severity!=0);
severity->put(2);
severity = pvStructure->getIntField(
String("valueAlarm.highAlarmSeverity"));
string("valueAlarm.highAlarmSeverity"));
testOk1(severity!=0);
severity->put(2);
PVBooleanPtr active = pvStructure->getBooleanField(
String("valueAlarm.active"));
string("valueAlarm.active"));
testOk1(active!=0);
active->put(true);
}
if(hasBooleanAlarm) {
PVFieldPtr pvField = pvStructure->getSubField(
String("valueAlarm.active"));
string("valueAlarm.active"));
PVBooleanPtr pvBoolean = static_pointer_cast<PVBoolean>(pvField);
pvBoolean->put(true);
severity = pvStructure->getIntField(
String("valueAlarm.falseSeverity"));
string("valueAlarm.falseSeverity"));
testOk1(severity!=0);
severity->put(0);
severity = pvStructure->getIntField(
String("valueAlarm.trueSeverity"));
string("valueAlarm.trueSeverity"));
testOk1(severity!=0);
severity->put(2);
severity = pvStructure->getIntField(
String("valueAlarm.changeStateSeverity"));
string("valueAlarm.changeStateSeverity"));
testOk1(severity!=0);
severity->put(1);
}
builder.clear();
pvStructure->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvStructure << std::endl;
}
static void testPVScalar()
{
if(debug) printf("\ntestScalar\n");
testPVScalarCommon(String("boolean"),pvByte);
testPVScalarCommon(String("byte"),pvByte);
testPVScalarCommon(String("short"),pvShort);
testPVScalarCommon(String("int"),pvInt);
testPVScalarCommon(String("long"),pvLong);
testPVScalarCommon(String("ubyte"),pvUByte);
testPVScalarCommon(String("ushort"),pvUShort);
testPVScalarCommon(String("uint"),pvUInt);
testPVScalarCommon(String("ulong"),pvULong);
testPVScalarCommon(String("float"),pvFloat);
testPVScalarCommon(String("double"),pvDouble);
testPVScalarCommon(String("string"),pvString);
if(debug)
std::cout << std::endl << "testScalar" << std::endl;
testPVScalarCommon(string("boolean"),pvByte);
testPVScalarCommon(string("byte"),pvByte);
testPVScalarCommon(string("short"),pvShort);
testPVScalarCommon(string("int"),pvInt);
testPVScalarCommon(string("long"),pvLong);
testPVScalarCommon(string("ubyte"),pvUByte);
testPVScalarCommon(string("ushort"),pvUShort);
testPVScalarCommon(string("uint"),pvUInt);
testPVScalarCommon(string("ulong"),pvULong);
testPVScalarCommon(string("float"),pvFloat);
testPVScalarCommon(string("double"),pvDouble);
testPVScalarCommon(string("string"),pvString);
testPVScalarWithProperties(String("boolean"),pvBoolean);
testPVScalarWithProperties(String("byte"),pvByte);
testPVScalarWithProperties(String("short"),pvShort);
testPVScalarWithProperties(String("int"),pvInt);
testPVScalarWithProperties(String("long"),pvLong);
testPVScalarWithProperties(String("ubyte"),pvUByte);
testPVScalarWithProperties(String("ushort"),pvUShort);
testPVScalarWithProperties(String("uint"),pvUInt);
testPVScalarWithProperties(String("ulong"),pvULong);
testPVScalarWithProperties(String("float"),pvFloat);
testPVScalarWithProperties(String("double"),pvDouble);
testPVScalarWithProperties(String("string"),pvString);
printf("testScalar PASSED\n");
testPVScalarWithProperties(string("boolean"),pvBoolean);
testPVScalarWithProperties(string("byte"),pvByte);
testPVScalarWithProperties(string("short"),pvShort);
testPVScalarWithProperties(string("int"),pvInt);
testPVScalarWithProperties(string("long"),pvLong);
testPVScalarWithProperties(string("ubyte"),pvUByte);
testPVScalarWithProperties(string("ushort"),pvUShort);
testPVScalarWithProperties(string("uint"),pvUInt);
testPVScalarWithProperties(string("ulong"),pvULong);
testPVScalarWithProperties(string("float"),pvFloat);
testPVScalarWithProperties(string("double"),pvDouble);
testPVScalarWithProperties(string("string"),pvString);
std::cout << "testPVScalar PASSED" << std::endl;
}
static void testScalarArrayCommon(String /*fieldName*/,ScalarType stype)
static void testScalarArrayCommon(string /*fieldName*/,ScalarType stype)
{
PVStructurePtr pvStructure = standardPVField->scalarArray(
stype,alarmTimeStamp);
@@ -340,30 +342,32 @@ static void testScalarArrayCommon(String /*fieldName*/,ScalarType stype)
values[2] = "2";
convert->fromStringArray(scalarArray, 0,3,values,0);
}
builder.clear();
pvStructure->toString(&builder);
if(debug) printf("%s\n",builder.c_str());
if(debug)
std::cout << *pvStructure << std::endl;
PVFieldPtr pvField = pvStructure->getSubField("alarm.status");
testOk1(pvField!=NULL);
}
static void testScalarArray()
{
if(debug) printf("\ntestScalarArray\n");
testScalarArrayCommon(String("boolean"),pvBoolean);
testScalarArrayCommon(String("byte"),pvByte);
testScalarArrayCommon(String("short"),pvShort);
testScalarArrayCommon(String("int"),pvInt);
testScalarArrayCommon(String("long"),pvLong);
testScalarArrayCommon(String("float"),pvFloat);
testScalarArrayCommon(String("double"),pvDouble);
testScalarArrayCommon(String("string"),pvString);
printf("testScalarArray PASSED\n");
if(debug)
std::cout << std::endl << "testScalarArray" << std::endl;
testScalarArrayCommon(string("boolean"),pvBoolean);
testScalarArrayCommon(string("byte"),pvByte);
testScalarArrayCommon(string("short"),pvShort);
testScalarArrayCommon(string("int"),pvInt);
testScalarArrayCommon(string("long"),pvLong);
testScalarArrayCommon(string("float"),pvFloat);
testScalarArrayCommon(string("double"),pvDouble);
testScalarArrayCommon(string("string"),pvString);
std::cout << "testScalarArray PASSED" << std::endl;
}
static void testRequest()
{
if(debug) printf("\ntestScalarArray\n");
if(debug)
std::cout << std::endl << "testScalarArray" << std::endl;
StringArray nullNames;
FieldConstPtrArray nullFields;
StringArray optionNames(1);
@@ -388,35 +392,22 @@ static void testRequest()
topFields[1] = fieldCreate->createStructure(fieldNames,fieldFields);
StructureConstPtr topStructure = fieldCreate->createStructure(
topNames,topFields);
String buffer;
topStructure->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *topStructure << endl;
PVStructurePtr pvTop = pvDataCreate->createPVStructure(topStructure);
buffer.clear();
pvTop->toString(&buffer);
cout << buffer.c_str() << endl;
buffer.clear();
pvTop->getStructure()->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *pvTop << endl;
cout << *pvTop->getStructure() << endl;
PVStructurePtr xxx = pvTop->getSubField<PVStructure>("record");
buffer.clear();
xxx->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *xxx << endl;
xxx = pvTop->getSubField<PVStructure>("field");
buffer.clear();
xxx->toString(&buffer);
cout << buffer.c_str() << endl;
cout << *xxx << endl;
PVStringPtr pvString = pvTop->getSubField<PVString>("record._options.process");
pvString->put("true");
buffer.clear();
pvTop->toString(&buffer);
cout << buffer.c_str() << endl;
cout << pvTop->dumpValue(cout) << endl;
cout << *pvTop << endl;
String subName("record._options.process");
string subName("record._options.process");
PVFieldPtr pvField = pvTop->getSubField(subName);
String fieldName = pvField->getFieldName();
String fullName = pvField->getFullName();
string fieldName = pvField->getFieldName();
string fullName = pvField->getFullName();
cout << "fieldName " << fieldName << " fullName " << fullName << endl;
testOk1(fieldName.compare("process")==0);

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -23,16 +24,18 @@
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::string;
static bool debug = false;
static FieldCreatePtr fieldCreate = getFieldCreate();
static StandardFieldPtr standardField = getStandardField();
static String builder("");
static void print(String name)
static void print(const string& name, FieldConstPtr const & f)
{
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
if(debug) {
std::cout << std::endl << name << std::endl << *f << std::endl;
}
}
MAIN(testStandardField)
@@ -40,19 +43,13 @@ MAIN(testStandardField)
testPlan(1);
StructureConstPtr doubleValue = standardField->scalar(pvDouble,
"alarm,timeStamp,display,control,valueAlarm");
builder.clear();
doubleValue->toString(&builder);
print("doubleValue");
print("doubleValue", doubleValue);
StructureConstPtr stringArrayValue = standardField->scalarArray(pvString,
"alarm,timeStamp");
builder.clear();
stringArrayValue->toString(&builder);
print("stringArrayValue");
print("stringArrayValue", stringArrayValue);
StructureConstPtr enumeratedValue = standardField->enumerated(
"alarm,timeStamp,valueAlarm");
builder.clear();
enumeratedValue->toString(&builder);
print("enumeratedValue");
print("enumeratedValue", enumeratedValue);
FieldConstPtrArray fields;
fields.reserve(2);
fields.push_back(fieldCreate->createScalar(pvDouble));
@@ -63,9 +60,7 @@ MAIN(testStandardField)
fieldNames.push_back("arrayValue");
StructureConstPtr structure = fieldCreate->createStructure(fieldNames, fields);
StructureConstPtr structureArrayValue = standardField->structureArray(structure, "alarm,timeStamp");
builder.clear();
structureArrayValue->toString(&builder);
print("structureArrayValue");
print("structureArrayValue", structureArrayValue);
StructureConstPtr punion = standardField->regUnion(
fieldCreate->createFieldBuilder()->
@@ -74,9 +69,7 @@ MAIN(testStandardField)
add("timeStamp",standardField->timeStamp())->
createUnion(),
"alarm,timeStamp");
builder.clear();
punion->toString(&builder);
print("unionValue");
print("unionValue", punion);
testPass("testStandardField");
return testDone();
}

View File

@@ -11,6 +11,7 @@
#include <cstddef>
#include <string>
#include <cstdio>
#include <sstream>
#include <epicsUnitTest.h>
#include <testMain.h>
@@ -24,17 +25,19 @@
using namespace epics::pvData;
using std::tr1::static_pointer_cast;
using std::string;
static bool debug = false;
static PVDataCreatePtr pvDataCreate = getPVDataCreate();
static StandardFieldPtr standardField = getStandardField();
static StandardPVFieldPtr standardPVField = getStandardPVField();
static String builder("");
static void print(String name)
static void print(const string& name, PVFieldPtr const & f)
{
if(debug) printf("\n%s\n%s\n",name.c_str(),builder.c_str());
if(debug) {
std::cout << std::endl << name << std::endl << *f << std::endl;
}
}
MAIN(testStandardPVField)
@@ -48,26 +51,18 @@ MAIN(testStandardPVField)
pvSeverity->put(2);
PVStringPtr pvMessage = pvStructure->getStringField("alarm.message");
pvMessage->put("test message");
builder.clear();
pvStructure->toString(&builder);
print("scalarTest");
print("scalarTest", pvStructure);
pvStructure = standardPVField->scalar(pvBoolean,"alarm,timeStamp,valueAlarm");
builder.clear();
pvStructure->toString(&builder);
print("booleanTest");
print("booleanTest", pvStructure);
StringArray choices;
choices.reserve(3);
choices.push_back("one");
choices.push_back("two");
choices.push_back("three");
pvStructure = standardPVField->enumerated(choices, "alarm,timeStamp,valueAlarm");
builder.clear();
pvStructure->toString(&builder);
print("enumeratedTest");
print("enumeratedTest", pvStructure);
pvStructure = standardPVField->scalarArray(pvBoolean,"alarm,timeStamp");
builder.clear();
pvStructure->toString(&builder);
print("scalarArrayTest");
print("scalarArrayTest", pvStructure);
StructureConstPtr structure = standardField->scalar(pvDouble, "alarm,timeStamp");
pvStructure = standardPVField->structureArray(structure,"alarm,timeStamp");
size_t num = 2;
@@ -78,9 +73,7 @@ MAIN(testStandardPVField)
}
PVStructureArrayPtr pvStructureArray = pvStructure->getStructureArrayField("value");
pvStructureArray->replace(freeze(pvStructures));
builder.clear();
pvStructure->toString(&builder);
print("structureArrayTest");
print("structureArrayTest", pvStructure);
testPass("testStandardPVField");
return testDone();
}