#include "iclGrabber.h" #include using namespace std; namespace icl{ namespace{ string toStr(double val){ // {{{ open char buf[100]; sprintf(buf,"%f",val); return buf; } // }}} string toStrComma(double val){ // {{{ open char buf[100]; sprintf(buf,"%f,",val); return buf; } // }}} inline bool inList(const string &s, const std::vector &vec){ // {{{ open return find(vec.begin(),vec.end(),s) != vec.end(); } // }}} } bool Grabber::supportsProperty(const std::string &property){ // {{{ open return inList(property,getPropertyList()); } // }}} string Grabber::translateSteppingRange(const SteppingRange& range){ // {{{ open static const string begin("["); return begin+toStr(range.minVal)+","+toStr(range.maxVal)+"]:"+toStr(range.stepping); } // }}} SteppingRange Grabber::translateSteppingRange(const string &rangeStr){ // {{{ open const char *str = rangeStr.c_str(); if(*str++ != '['){ ERROR_LOG("syntax error: " << rangeStr); return SteppingRange(); } char *str2 = 0; double minVal = strtod(str,&str2); if(*str2++ != ','){ ERROR_LOG("syntax error: " << rangeStr); return SteppingRange(); } str = str2; double maxVal = strtod(str,&str2); if(*str2++ != ']'){ ERROR_LOG("syntax error: " << rangeStr); return SteppingRange(); } if(*str2++ != ':'){ ERROR_LOG("syntax error: " << rangeStr); return SteppingRange(); } str = str2; double stepping = strtod(str,&str2); return SteppingRange(minVal,maxVal,stepping); } // }}} string Grabber::translateDoubleVec(const vector &doubleVec){ // {{{ op4mn unsigned int s = doubleVec.size(); if(!s) return "{}"; string str = "{"; for(unsigned int i=0;i Grabber::translateDoubleVec(const string &doubleVecStr){ // {{{ open const char *str = doubleVecStr.c_str(); if(*str++ != '{'){ ERROR_LOG("syntax error "<< doubleVecStr); return vector(); } const char *end = str+doubleVecStr.size(); char *next=const_cast(str); vector v; while(next(); } return v; } str = next+1; } return vector(); } // }}} string Grabber::translateStringVec(const vector &stringVec){ // {{{ open unsigned int s = stringVec.size(); if(!s) return "{}"; string str = "{"; for(unsigned int i=0;i Grabber::translateStringVec(const string &stringVecStr){ // {{{ open const char *str = stringVecStr.c_str(); if(*str++ != '{'){ ERROR_LOG("[code 4] syntax error "<< stringVecStr); return vector(); } const char *end = str+stringVecStr.size(); char *curr=const_cast(str); char *next = 0; vector v; while(curr(); } next = strchr(curr,'"'); if(!next){ ERROR_LOG("[code 2] syntax error "<< stringVecStr); return vector(); } *next = '\0'; v.push_back(curr); *next++ = '"'; if(*next != ','){ if(*next == '}'){ return v; }else{ ERROR_LOG("[code 1] syntax error "<< stringVecStr); return vector(); } } curr = next+1; } return v; } // }}} ImgBase* Grabber::prepareOutput (ImgBase **ppoDst) { // use internal output image, if ppoDst == 0 if(!ppoDst) ppoDst = &m_poImage; // adapt destination image to desired params and depth ensureCompatible(ppoDst, m_eDesiredDepth, m_oDesiredParams); return *ppoDst; } }