This is Unofficial EPICS BASE Doxygen Site
pvutils.cpp File Reference
#include <stdio.h>
#include <signal.h>
#include <iostream>
#include <string>
#include <ostream>
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <algorithm>
#include <pv/logger.h>
#include <pv/pvTimeStamp.h>
#include "pvutils.h"
+ Include dependency graph for pvutils.cpp:

Go to the source code of this file.

Macros

#define USE_SIGNAL
 

Functions

std::string request ("")
 
std::string defaultProvider ("pva")
 
void jarray (pvd::shared_vector< std::string > &out, const char *inp)
 

Variables

double timeout = 5.0
 
bool debugFlag = false
 
pvd::PVStructure::Formatter::format_t outmode = pvd::PVStructure::Formatter::NT
 
int verbosity
 

Macro Definition Documentation

#define USE_SIGNAL

Definition at line 8 of file pvutils.cpp.

Function Documentation

std::string defaultProvider ( "pva"  )
void jarray ( pvd::shared_vector< std::string > &  out,
const char *  inp 
)

Definition at line 68 of file pvutils.cpp.

69 {
70  assert(inp[0]=='[');
71  const char * const orig = inp;
72  inp++;
73 
74  while(true) {
75  // starting a new token
76 
77  for(; *inp==' '; inp++) {} // skip leading whitespace
78 
79  if(*inp=='\0') early(inp, inp-orig);
80 
81  if(isalnum(*inp) || *inp=='+' || *inp=='-') {
82  // number
83 
84  const char *start = inp;
85 
86  while(isalnum(*inp) || *inp=='.' || *inp=='+' || *inp=='-')
87  inp++;
88 
89  if(*inp=='\0') early(inp, inp-orig);
90 
91  // inp points to first char after token
92 
93  out.push_back(std::string(start, inp-start));
94 
95  } else if(*inp=='"') {
96  // quoted string
97 
98  const char *start = ++inp; // skip quote
99 
100  while(*inp!='\0' && *inp!='"')
101  inp++;
102 
103  if(*inp=='\0') early(inp, inp-orig);
104 
105  // inp points to trailing "
106 
107  out.push_back(std::string(start, inp-start));
108 
109  inp++; // skip trailing "
110 
111  } else if(*inp==']') {
112  // no-op
113  } else {
114  fprintf(stderr, "Unknown token '%c' in \"%s\"", *inp, inp);
115  throw std::runtime_error("Unknown token");
116  }
117 
118  for(; *inp==' '; inp++) {} // skip trailing whitespace
119 
120  if(*inp==',') inp++;
121  else if(*inp==']') break;
122  else {
123  fprintf(stderr, "Unknown token '%c' in \"%s\"", *inp, inp);
124  throw std::runtime_error("Unknown token");
125  }
126  }
127 
128 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
void push_back(param_type v)
Definition: sharedVector.h:602
#define stderr
Definition: epicsStdio.h:32
std::string request ( ""  )

Variable Documentation

bool debugFlag = false

Definition at line 26 of file pvutils.cpp.

pvd::PVStructure::Formatter::format_t outmode = pvd::PVStructure::Formatter::NT

Definition at line 28 of file pvutils.cpp.

double timeout = 5.0

Definition at line 25 of file pvutils.cpp.

int verbosity

Definition at line 29 of file pvutils.cpp.