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

@@ -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