32 namespace PTScriptParsing {
 
   37 bool getPTParam(std::string & output, 
const std::string & 
line, 
const std::string & parameter)
 
   39     int len = line.size();
 
   40     for (
int i=1; i < len; i++) {
 
   41         if (line[i-1] == 
' ' && line[i] != 
' ') {
 
   43             std::string par = line.substr(i, parameter.length());
 
   44             if (par == parameter) {
 
   46                 i = i+parameter.length();
 
   58                     size_t end = line.find(
'"', i);
 
   59                     if (end == std::string::npos) {
 
   63                     output = line.substr(i,end-i);
 
   67                     size_t end = line.find_first_of(
" \t\n", i);
 
   68                     output = line.substr(i, end-i);
 
   80                     size_t end = line.find(
'"', i);
 
   81                     if (end == std::string::npos) {
 
   91                     size_t end = line.find_first_of(
" \t\n", i);
 
   92                     if (end == std::string::npos) {
 
  105 bool getPTParam(std::string & output, 
const std::string & 
line, 
const std::string & parameter)
 
  107     std::string::size_type p;
 
  108     if ((p=line.find(std::string(
" ") + parameter)) == std::string::npos) {
 
  109         DEBUG_INFO(
"could not find param " << parameter
 
  110                    << 
" in line: " << line);
 
  113     p += parameter.length() + 1;
 
  114     std::string::size_type p2 = line.find(
' ',p);
 
  115     output = line.substr(p, p2-p);
 
  120 bool getPTStringParam(std::string & output, 
const std::string & line, 
const std::string & parameter)
 
  122     std::string::size_type p;
 
  123     if ((p=line.find(std::string(
" ") + parameter + 
"\"")) == std::string::npos) {
 
  124         DEBUG_INFO(
"could not find string param " << parameter
 
  125                    << 
" in line: " << line);
 
  128     p += parameter.length() + 2;
 
  129     std::string::size_type e = line.find(
"\"",p);
 
  131     output = line.substr(p,e-p);
 
  136 bool getPTStringParamColon(std::string & output, 
const std::string & line, 
const std::string & parameter)
 
  138     std::string::size_type p;
 
  139     if ((p=line.find(std::string(
" ") + parameter + 
":")) == std::string::npos) {
 
  140         DEBUG_INFO(
"could not find string param " << parameter
 
  141                    << 
" in line: " << line);
 
  144     p += parameter.length() + 2;
 
  145     std::string::size_type e = line.find(
" ",p);
 
  147     output = line.substr(p,e-p);
 
  153 bool getDoubleParam(
double & d, 
const std::string & line, 
const std::string & name)
 
  163                           const std::string & line, 
const std::string & var)
 
  217 const char * 
ImgInfo::varnames[] = {
"v", 
"a",
"b",
"c", 
"d",
"e", 
"g",
"t", 
"r",
"p",
"y",
"j",
"TrX", 
"TrY", 
"TrZ", 
"Tpy", 
"Tpp",
 
  218                                     "Va", 
"Vb", 
"Vc", 
"Vd",  
"Vx", 
"Vy",
 
  220                                     "Ra", 
"Rb", 
"Rc", 
"Rd", 
"Re",  0};
 
  222 double ImgInfo::defaultValues[] = {51.0,  0.0, 0.0, 0.0,  0.0, 0.0,  0.0, 0.0,  0.0, 0.0, 0.0,  0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
 
  223                                    1.0, 0.0, 0.0, 0.0,   0.0, 0.0, 
 
  225                                    0.0, 0.0, 0.0, 0.0, 0.0};
 
  237     for (
const char ** v = 
varnames; *v != 0; v++) {
 
  250     for (
const char ** v = 
varnames; *v; v++, val++) {
 
  281     std::string crop_str;
 
  283         int left, right, top, bottom;
 
  284         int n = sscanf(crop_str.c_str(), 
"%d,%d,%d,%d", &left, &right, &top, &bottom);
 
  286             crop = vigra::Rect2D(left, top, right, bottom);
 
  288             DEBUG_WARN(
"Could not parse crop string: " << crop_str);
 
  292         int left, right, top, bottom;
 
  293         int n = sscanf(crop_str.c_str(), 
"%d,%d,%d,%d", &left, &right, &top, &bottom);
 
  295             crop = vigra::Rect2D(left, top, right, bottom);
 
  297             DEBUG_WARN(
"Could not parse crop string: " << crop_str);
 
static const char * varnames[]
bool readVar(Variable &var, int &link, const std::string &line)
const std::string & getName() const 
bool getIntParam(T &value, const std::string &line, const std::string &name)
a variable has a value and a name. 
#define DEBUG_ASSERT(cond)
bool getPTParam(std::string &output, const std::string &line, const std::string ¶meter)
helper functions for parsing of a script line 
static double defaultValues[]
std::map< std::string, double > vars
bool stringToInt(const std::string &s, int &val)
convert string to integer value, returns true, if sucessful 
bool stringToDouble(const STR &str_, double &dest)
convert a string to a double, ignore localisation. 
std::map< std::string, int > links
std::string flatfieldname
bool getDoubleParam(double &d, const std::string &line, const std::string &name)
bool getPTDoubleParam(double &value, int &link, const std::string &line, const std::string &var)
void parse(const std::string &line)