Make CreateRequest compatible with the Java version

This commit is contained in:
Marty Kraimer
2012-06-26 09:33:37 -04:00
parent 4b5bc38835
commit 7e8312d1ee
10 changed files with 465 additions and 385 deletions
+18 -12
View File
@@ -17,20 +17,25 @@ using namespace std::tr1;
using namespace epics::pvData;
using namespace epics::pvAccess;
void convertStructure(StringBuilder buffer,PVStructure *data,int notFirst);
void convertArray(StringBuilder buffer,PVScalarArray * pv,int notFirst);
void convertStructureArray(StringBuilder buffer,PVStructureArray * pvdata,int notFirst);
class RequesterImpl : public Requester,
public std::tr1::enable_shared_from_this<RequesterImpl>
{
public:
virtual String getRequesterName()
{
return "RequesterImpl";
};
virtual void message(String message,MessageType messageType)
{
std::cout << "[" << getRequesterName() << "] message(" << message << ", " << getMessageTypeName(messageType) << ")" << std::endl;
}
};
void convertToString(StringBuilder buffer,PVField * pv,int notFirst)
{
@@ -543,6 +548,8 @@ int main (int argc, char *argv[])
int opt; /* getopt() current option */
bool debug = false;
Requester::shared_pointer requester(new RequesterImpl());
setvbuf(stdout,NULL,_IOLBF,BUFSIZ); /* Set stdout to line buffering */
while ((opt = getopt(argc, argv, ":hr:w:t")) != -1) {
@@ -602,10 +609,9 @@ int main (int argc, char *argv[])
for (int n = 0; optind < argc; n++, optind++)
values.push_back(argv[optind]); /* Copy values from command line */
try {
pvRequest = getCreateRequest()->createRequest(request);
} catch (std::exception &ex) {
printf("failed to parse request string: %s\n", ex.what());
pvRequest = getCreateRequest()->createRequest(request,requester);
if(pvRequest.get()==NULL) {
printf("failed to parse request string\n");
return 1;
}