T Parser::top_pop(std::stack<T>& input){ T temp = input.top(); input.pop(); return temp; }
void OnStartCluster(const std::string & id, const AttrMap & attrs) { assert(!id.empty()); m_clusterStack.push(GetCluster(m_graph, m_clusterStack.top(), id, m_merge)); m_clusterStack.top()->SetProperty(DOT_PROP_CDOTITEM, new CDotCluster(id, attrs)); }
void startElement(void *ctx, const char *name, const char **atts) { CC_UNUSED_PARAM(ctx); CC_UNUSED_PARAM(atts); const std::string sName(name); if( sName == "dict" ) { if(_resultType == SAX_RESULT_DICT && _rootDict.empty()) { _curDict = &_rootDict; } _state = SAX_DICT; SAXState preState = SAX_NONE; if (! _stateStack.empty()) { preState = _stateStack.top(); } if (SAX_ARRAY == preState) { // add a new dictionary into the array _curArray->push_back(Value(ValueMap())); _curDict = &(_curArray->rbegin())->asValueMap(); } else if (SAX_DICT == preState) { // add a new dictionary into the pre dictionary CCASSERT(! _dictStack.empty(), "The state is wrong!"); ValueMap* preDict = _dictStack.top(); (*preDict)[_curKey] = Value(ValueMap()); _curDict = &(*preDict)[_curKey].asValueMap(); } // record the dict state _stateStack.push(_state); _dictStack.push(_curDict); } else if(sName == "key") { _state = SAX_KEY; } else if(sName == "integer") { _state = SAX_INT; } else if(sName == "real") { _state = SAX_REAL; } else if(sName == "string") { _state = SAX_STRING; } else if (sName == "array") { _state = SAX_ARRAY; if (_resultType == SAX_RESULT_ARRAY && _rootArray.empty()) { _curArray = &_rootArray; } SAXState preState = SAX_NONE; if (! _stateStack.empty()) { preState = _stateStack.top(); } if (preState == SAX_DICT) { (*_curDict)[_curKey] = Value(ValueVector()); _curArray = &(*_curDict)[_curKey].asValueVector(); } else if (preState == SAX_ARRAY) { CCASSERT(! _arrayStack.empty(), "The state is wrong!"); ValueVector* preArray = _arrayStack.top(); preArray->push_back(Value(ValueVector())); _curArray = &(_curArray->rbegin())->asValueVector(); } // record the array state _stateStack.push(_state); _arrayStack.push(_curArray); } else { _state = SAX_NONE; } }
CGraphvizVisitor(IGraph * graph, bool merge) { m_graph = graph; m_merge = merge; m_clusterStack.push(graph); }
void OnStartGraph(int kind, const std::string & id, const AttrMap & attrs) { assert(!id.empty()); m_graph->SetProperty(DOT_PROP_CDOTITEM, new CDotGraph(kind, id, attrs)); m_clusterStack.push(NULL); }
LAS_DLL void LASError_Reset(void) { if (errors.empty()) return; for (std::size_t i=0;i<errors.size();i++) errors.pop(); }
LAS_DLL void LASError_PushError(int code, const char *message, const char *method) { LASError err = LASError(code, std::string(message), std::string(method)); errors.push(err); }
static Value DeserializeValue( std::string& str, bool* had_error, std::stack<StackDepthType>& depth_stack ) { Value v; *had_error = false; str = Trim( str ); if ( str.length() == 0 ) return v; if ( str[ 0 ] == '[' ) { // This value is an array, determine the end of it and then deserialize the array depth_stack.push( InArray ); size_t i = GetEndOfArrayOrObj( str, depth_stack ); if ( i == std::string::npos ) { *had_error = true; return Value(); } std::string array_str = str.substr( 0, i + 1 ); v = Value( DeserializeArray( array_str, depth_stack ) ); str = str.substr( i + 1, str.length() ); } else if ( str[ 0 ] == '{' ) { // This value is an object, determine the end of it and then deserialize the object depth_stack.push( InObject ); size_t i = GetEndOfArrayOrObj( str, depth_stack ); if ( i == std::string::npos ) { *had_error = true; return Value(); } std::string obj_str = str.substr( 0, i + 1 ); v = Value( DeserializeInternal( obj_str, depth_stack ) ); str = str.substr( i + 1, str.length() ); } else if ( str[ 0 ] == '\"' ) { // This value is a string size_t end_quote = GetQuotePos( str, 1 ); if ( end_quote == std::string::npos ) { *had_error = true; return Value(); } v = Value( UnescapeJSONString( str.substr( 1, end_quote - 1 ) ) ); str = str.substr( end_quote + 1, str.length() ); } else { // it's not an object, string, or array so it's either a boolean or a number or null. // Numbers can contain an exponent indicator ('e') or a decimal point. bool has_dot = false; bool has_e = false; std::string temp_val; size_t i = 0; bool found_digit = false; bool found_first_valid_char = false; for ( ; i < str.length(); i++ ) { if ( str[ i ] == '.' ) { if ( !found_digit ) { // As per JSON standards, there must be a digit preceding a decimal point *had_error = true; return Value(); } has_dot = true; } else if ( ( str[ i ] == 'e' ) || ( str[ i ] == 'E' ) ) { if ( ( _stricmp( temp_val.c_str(), "fals" ) != 0 ) && ( _stricmp( temp_val.c_str(), "tru" ) != 0 ) ) { // it's not a boolean, check for scientific notation validity. This will also trap booleans with extra 'e' characters like falsee/truee if ( !found_digit ) { // As per JSON standards, a digit must precede the 'e' notation *had_error = true; return Value(); } else if ( has_e ) { // multiple 'e' characters not allowed *had_error = true; return Value(); } has_e = true; } } else if ( str[ i ] == ']' ) { if ( depth_stack.empty() || ( depth_stack.top() != InArray ) ) { *had_error = true; return Value(); } depth_stack.pop(); } else if ( str[ i ] == '}' ) { if ( depth_stack.empty() || ( depth_stack.top() != InObject ) ) { *had_error = true; return Value(); } depth_stack.pop(); } else if ( str[ i ] == ',' ) break; else if ( ( str[ i ] == '[' ) || ( str[ i ] == '{' ) ) { // error, we're supposed to be processing things besides arrays/objects in here *had_error = true; return Value(); } if ( !std::isspace( str[ i ] ) ) { if ( std::isdigit( str[ i ] ) ) found_digit = true; found_first_valid_char = true; temp_val += str[ i ]; } } // store all floating point as doubles. This will also set the float and int values as well. if ( _stricmp( temp_val.c_str(), "true" ) == 0 ) v = Value( true ); else if ( _stricmp( temp_val.c_str(), "false" ) == 0 ) v = Value( false ); else if ( has_e || has_dot ) { char* end_char; errno = 0; double d = strtod( temp_val.c_str(), &end_char ); if ( ( errno != 0 ) || ( *end_char != '\0' ) ) { // invalid conversion or out of range *had_error = true; return Value(); } v = Value( d ); } else if ( _stricmp( temp_val.c_str(), "null" ) == 0 ) v = Value(); else { // Check if the value is beyond the size of an int and if so, store it as a double char* end_char; errno = 0; long int ival = strtol( temp_val.c_str(), &end_char, 10 ); if ( *end_char != '\0' ) { // invalid character sequence, not a number *had_error = true; return Value(); } else if ( ( errno == ERANGE ) && ( ( ival == LONG_MAX ) || ( ival == LONG_MIN ) ) ) { // value is out of range for a long int, should be a double then. See if we can convert it correctly. errno = 0; double dval = strtod( temp_val.c_str(), &end_char ); if ( ( errno != 0 ) || ( *end_char != '\0' ) ) { // error in conversion or it's too big for a double *had_error = true; return Value(); } v = Value( dval ); } else if ( ( ival >= INT_MIN ) && ( ival <= INT_MAX ) ) { // valid integer range v = Value( (int)ival ); } else { // probably running on a very old OS since this block implies that long isn't the same size as int. // int is guaranteed to be at least 16 bits and long 32 bits...however nowadays they're almost // always the same 32 bit size. But it's possible someone is running this on a very old architecture // so for correctness, we'll error out here *had_error = true; return Value(); } } str = str.substr( i, str.length() ); } return v; }
void Pulsar::PlotLoop::plot( std::stack< Reference::To<TextIndex> >& indeces ) { if (indeces.empty()) { VERBOSE("Pulsar::PlotLoop::plot plotting"); for (unsigned i=0; i<plots.size(); i++) { if (!overlay) cpgpage (); plots[i]->plot (archives[i]); } return; } Reference::To<TextIndex> index = indeces.top(); indeces.pop(); vector<string> current (plots.size()); unsigned loop_size = 0; for (unsigned iplot=0; iplot < plots.size(); iplot++) { index->set_container( archives[iplot]->get_interface() ); if (iplot == 0) loop_size = index->size(); else if ( loop_size != index->size() ) throw Error (InvalidState, "Pulsar::PlotLoop::plot", "loop size for plot[0]=%u != that of plot[%u]=%u", loop_size, iplot, index->size()); } for (unsigned i=0; i<loop_size; i++) { for (unsigned iplot=0; iplot < plots.size(); iplot++) try { index->set_container( archives[iplot]->get_interface() ); string index_command = index->get_index(i); VERBOSE("Pulsar::PlotLoop::plot " << index_command); PlotLabel* label = plots[iplot]->get_attributes()->get_label_above(); current[iplot] = label->get_centre(); plots[iplot]->configure( index_command ); label->set_centre( current[iplot] + " " + index_command ); } catch (Error& error) { cerr << "Pulsar::PlotLoop::plot error configuring " << index->get_index(i) << " of " << "\n\t" << archives[iplot]->get_filename() << "\n\t" << error.get_message() << endl; } try { plot (indeces); } catch (Error& error) { cerr << "Pulsar::PlotLoop::plot error plotting " << "\n\t" << error.get_message() << endl; } for (unsigned iplot=0; iplot < plots.size(); iplot++) { PlotLabel* label = plots[iplot]->get_attributes()->get_label_above(); label->set_centre( current[iplot] ); } } indeces.push( index ); }
void ObjectHandle::free() { freedHandles.push((int64)*this); }
static Value DeserializeValue(std::string& str, bool* had_error, std::stack<StackDepthType>& depth_stack) { Value v; *had_error = false; str = Trim(str); if (str.length() == 0) return v; if (str[0] == '[') { // This value is an array, determine the end of it and then deserialize the array depth_stack.push(InArray); size_t i = GetEndOfArrayOrObj(str, depth_stack); if (i == std::string::npos) { *had_error = true; return Value(); } std::string array_str = str.substr(0, i + 1); v = Value(DeserializeArray(array_str, depth_stack)); str = str.substr(i + 1, str.length()); } else if (str[0] == '{') { // This value is an object, determine the end of it and then deserialize the object depth_stack.push(InObject); size_t i = GetEndOfArrayOrObj(str, depth_stack); if (i == std::string::npos) { *had_error = true; return Value(); } std::string obj_str = str.substr(0, i + 1); v = Value(DeserializeInternal(obj_str, depth_stack)); str = str.substr(i + 1, str.length()); } else if (str[0] == '\"') { // This value is a string size_t end_quote = GetQuotePos(str, 1); if (end_quote == std::string::npos) { *had_error = true; return Value(); } v = Value(UnescapeJSONString(str.substr(1, end_quote - 1))); str = str.substr(end_quote + 1, str.length()); } else { // it's not an object, string, or array so it's either a boolean or a number or null. // Numbers can contain an exponent indicator ('e') or a decimal point. bool has_dot = false; bool has_e = false; std::string temp_val; size_t i = 0; for (; i < str.length(); i++) { if (str[i] == '.') has_dot = true; else if ((str[i] == 'e') || (str[i] == 'E')) has_e = true; else if (str[i] == ']') { if (depth_stack.top() != InArray) { *had_error = true; return Value(); } depth_stack.pop(); } else if (str[i] == '}') { if (depth_stack.top() != InObject) { *had_error = true; return Value(); } depth_stack.pop(); } else if (str[i] == ',') break; if (!std::isspace(str[i])) temp_val += str[i]; } // store all floating point as doubles. This will also set the float and int values as well. if (_stricmp(temp_val.c_str(), "true") == 0) v = Value(true); else if (_stricmp(temp_val.c_str(), "false") == 0) v = Value(false); else if (has_e || has_dot) v = Value(atof(temp_val.c_str())); else if (_stricmp(temp_val.c_str(), "null") == 0) v = Value(); else { // Check if the value is beyond the size of an int and if so, store it as a double double tmp_val = atof(temp_val.c_str()); if ((tmp_val >= (double)INT_MIN) && (tmp_val <= (double)INT_MAX)) v = Value(atoi(temp_val.c_str())); else v = Value(tmp_val); } str = str.substr(i, str.length()); } return v; }
namespace ospray { static std::map<int64,Ref<ospray::ManagedObject>> objectByHandle; static std::stack<int64> freedHandles; //! next unassigned ID on this node /*! we start numbering with 1 to make sure that "0:0" is an invalid handle (so we can typecast between (64-bit) handles and (64-bit)OSPWhatEver pointers */ static int32 nextFreeLocalID = 1; void ObjectHandle::free() { freedHandles.push((int64)*this); } ObjectHandle::ObjectHandle() { if (freedHandles.empty()) { i32.ID = nextFreeLocalID++; i32.owner = 0; } else { i64 = freedHandles.top(); freedHandles.pop(); } } ObjectHandle::ObjectHandle(int64 i) : i64(i) { } ObjectHandle::ObjectHandle(const ObjectHandle &other) : i64(other.i64) { } ObjectHandle &ObjectHandle::operator=(const ObjectHandle &other) { i64 = other.i64; return *this; } /*! define the given handle to refer to given object */ void ObjectHandle::assign(const ObjectHandle &handle, ManagedObject *object) { objectByHandle[handle] = object; } void ObjectHandle::assign(ManagedObject *object) const { objectByHandle[*this] = object; } void ObjectHandle::freeObject() const { auto it = objectByHandle.find(i64); Assert(it != objectByHandle.end()); it->second = nullptr; objectByHandle.erase(it); } int32 ObjectHandle::ownerRank() const { return i32.owner; } int32 ObjectHandle::objID() const { return i32.ID; } ospray::ObjectHandle::operator int64() const { return i64; } bool ObjectHandle::defined() const { auto it = objectByHandle.find(i64); return it != objectByHandle.end(); } ManagedObject *ObjectHandle::lookup() const { if (i64 == 0) return nullptr; auto it = objectByHandle.find(i64); if (it == objectByHandle.end()) { #ifndef NDEBUG // iw - made this into a warning only; the original code had // this throw an actual exceptoin, but that may be overkill std::cout << "#osp: WARNING: ospray is trying to look up object handle "+std::to_string(i64)+" that isn't defined!" << std::endl; #endif return nullptr; } return it->second.ptr; } ObjectHandle ObjectHandle::lookup(ManagedObject *object) { for (auto it = objectByHandle.begin(); it != objectByHandle.end(); it++) { if (it->second.ptr == object) return(ObjectHandle(it->first)); } return(nullHandle); } OSPRAY_SDK_INTERFACE const ObjectHandle nullHandle(0); } // ::ospray
/*! \brief return current camera picture, as rgb or yuv picture, threadsave * * \param rgb if set to zero (default), yuv-Picture will return, <br> * if set to other value, rgb-Picture will return * \param removeFrame if set to 1 (default) the next picture will be catch <br> * if set to zero, the last picture will be returned * \return SPicture pointer to lokal buffer, which didn't change until the next call from getPicture with * the same rgb-parameter * \return NULL if any error occured */ SPicture* getPicture(int rgb/* = 0*/, int removeFrame/* = 1*/) { if(mutex_lock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_lock</font>")); // if start wasn't called if(!g_run) { while(g_capture.isOpened()) g_capture.release(); printf("encoder.getPicture after call g_capture.release\n"); g_Messages.push(string("getPicture</b> <font color='blue'>Kamera wurde geschlossen</font>")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 1</font>")); return 0; } // try to open capture else if(!g_capture.isOpened()) { g_Messages.push(string("getPicture</b> <font color='red'>keine Kamera geoeffnet!</font>")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 2</font>")); return 0; } //get next or last picture Mat m, m2, m3; if(!removeFrame) g_capture.retrieve(m); else g_capture >> m; // get a new frame from camer if(!m.size().area()) { g_Messages.push(string("getPicture</b> <font color='red'>picture from camera is empty</font>")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 3</font>")); return 0; } //m = cvLoadImage("test.jpg"); if(m.depth() != CV_8U) { g_Messages.push(string("getPicture</b> <font color='red'>depth != unsigned char</font>\n")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 4</font>")); return 0; } //m.convertTo(m2, ) //Scale Picture to choosen resolution (if camera didn't support it) Mat matrices[4]; //IplImage src = m; // IplImage* scaled = cvCreateImage(cvSize(g_cfg.width, g_cfg.height), IPL_DEPTH_8U, 3); //cvResize( &src, scaled, CV_INTER_LINEAR ); m3.create(g_cfg.width, g_cfg.height, m.type()); resize(m, m3, Size(g_cfg.width, g_cfg.height)); char buffer[256]; sprintf(buffer, "getPicture</b> <i>breite: %d, hoehe: %d, area: %d</i>", m.size().width, m.size().height, m.size().area()); // g_Messages.push(string(buffer)); //rgb-output if(rgb) { //imshow("LIVE", scaled); split(m3, matrices); matrices[3] = matrices[0].clone(); matrices[3] = Scalar(255); merge(matrices, 4, m2); //get current buffer size and required buffer size int oldSize = picture_getSize(&g_rgbPicture); g_rgbPicture.width = m2.cols; g_rgbPicture.height = m2.rows; int newSize = picture_getSize(&g_rgbPicture); //compare buffer size and picture size, and make new buffer, if picture size differ if(oldSize != newSize) { picture_release(&g_rgbPicture); if(picture_create(&g_rgbPicture, m2.cols, m2.rows, 4)) { g_Messages.push(string("getPicture</b> <font color='red'>Fehler beim speicher reservieren in getPicture rgb!</font>")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 5</font>")); return NULL; } } //return 0; //copy picture to buffer size_t size = m2.cols*m2.rows*4; memcpy(g_rgbPicture.channel1, m2.data, size); //free scaled image //cvReleaseImage(&scaled); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 6</font>")); //return pointer to picture buffer return &g_rgbPicture; } // yuv-Output else { //convert and split picture cvtColor(m3, m2, CV_BGR2YCrCb); split(m2, matrices); IplImage* U = cvCreateImage(cvSize(m3.cols/2, m3.rows/2), IPL_DEPTH_8U, 1); IplImage* V = cvCreateImage(cvSize(m3.cols/2, m3.rows/2), IPL_DEPTH_8U, 1); IplImage uSrc = matrices[1]; IplImage vSrc = matrices[2]; //create resized u and v pictures (half-size) cvResize(&uSrc, U, CV_INTER_LINEAR); cvResize( &vSrc, V, CV_INTER_LINEAR ); // imshow("Y", matrices[0]); //imshow("U", U); //imshow("V", V); //get current buffer size and required buffer size int oldSize = picture_getSize(&g_yuvPicture); g_yuvPicture.width = m3.cols; g_yuvPicture.height = m3.rows; int newSize = picture_getSize(&g_yuvPicture); //compare buffer size and picture size, and make new buffer, if picture size differ if(oldSize != newSize) { picture_release(&g_yuvPicture); if(picture_create(&g_yuvPicture, m2.cols, m2.rows, 1)) { g_Messages.push(string("getPicture</b> <font color='red'>Fehler beim speicher reservieren in getPicture yuv!</font>")); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 7</font>")); return 0; } } //return 0; //copy channels size_t size = m2.cols*m2.rows; memcpy(g_yuvPicture.channel1, matrices[0].data, size); memcpy(g_yuvPicture.channel2, V->imageData, size/4); memcpy(g_yuvPicture.channel3, U->imageData, size/4); //release u and v pictures cvReleaseImage(&U); cvReleaseImage(&V); // cvReleaseImage(&scaled); if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 8</font>")); //return pointer to picture buffer return &g_yuvPicture; } if(mutex_unlock(mutex)) g_Messages.push(string("getPicture</b> <font color='red'>Fehler bei mutex_unlock 9</font>")); return NULL; }
/*! \brief get parameter from capture * * * <br> * <table><tr><th colspan='3'>Possible Parameters to get:</th></tr> * <tr><th>name</th><th>return</th><th>description</th></tr> * <tr><td>getLastMessage</td><td>char[256]</td><td> * - return pointer to char-buffer with last error-message from capture</td></tr> * <tr><td>capture.getPictureFunc</td> * <td>(SPicture* (*)(int, int))</td><td> * - return pointer to getPicture(int rgb, int removeFrame)</td></tr> * <tr><td>capture.camera.count</td><td>int</td><td> * - return number of cameras currently connected to the Computer</td></tr> * <tr><td>capture.camera.x.name</td><td>char[]</td><td> * - return name of camera x, where x is a number between 0 and capture.camera.count</td></tr> * <tr><td>capture.camera.x.resolution.count</td><td>int</td><td> * - return number of resolutions for camera x (where x is a number between 0 and capture.camera.count)</td></tr> * <tr><td>capture.camera.i.resolution.j.x<br>capture.camera.i.resolution.j.width</td><td>int</td><td> * - return resolution width of camera i, of resolution j * (where i is a number between 0 and capture.camera.count * and j is a number between 0 and capture.camera.i.resolution.count)</td></tr> * <tr><td>capture.camera.i.resolution.j.y<br>capture.camera.i.resolution.j.height</td><td>int</td><td> * - return resolution height of camera i, of resolution j * (where i is a number between 0 and capture.camera.count * and j is a number between 0 and capture.camera.i.resolution.count)</td></tr> * <tr><td>capture.resolution.x<br>capture.resolution.width</td> * <td>int</td><td> * - return current width of camera resolution</td></tr> * <tr><td>capture.resolution.y<br>capture.resolution.height</td> * <td>int</td><td> * - return current height of camera resolution</td></tr> * </table> * <br> * * \param name parameter name * \return parameter value (number or pointer) if succeed * \return NULL if parameter is unknown */ int getParameter(const char* name) { if(mutex_lock(mutex)) printf("capture.getParameter Fehler bei lock_mutex\n"); // printf("Name: %s\n", name); char buffer[256]; sprintf(buffer, "%s", name); char * pch; pch = strtok (buffer, ".\0"); int count = 0; while (pch != NULL) { g_Parameters[count++] = pch; pch = strtok (NULL, ".\0"); } if(g_Parameters[0] == string("getLastMessage")) { if(g_Messages.size()) { sprintf(g_MessagesBuffer,"<b>capture.%s", g_Messages.top().data()); g_Messages.pop(); if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 1\n"); return (int)g_MessagesBuffer; } else { if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 2\n"); return 0; } } else if(g_Parameters[0] != string(g_modulname)) { //TODO: weiterleiten if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 3\n"); return 0; } if(g_Parameters[1] == string("camera")) { return camera_getParameter(&g_Parameters[2]); } else if(g_Parameters[1] == string("getPictureFunc") ) { if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 4\n"); return (int)getPicture; } else if(string(name) == string("capture.resolution.x") || string(name) == string("capture.resolution.width")) { int width = g_cfg.width; if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 5\n"); return width; } else if(string(name) == string("capture.resolution.y") || string(name) == string("capture.resolution.height")) { int height = g_cfg.height; if(mutex_unlock(mutex)) printf("capture.getParameter Fehler bei unlock_mutex 6\n"); return height; } /* for(int i = 0; i < MAX_PARAMETER_COUNT; i++) { printf("%d: %s\n", i, g_Parameters[i].data()); }*/ return 0; }
void PushExpListValueCount(int count) { exp_list_value_count_.push(count); }
inline void push( std::stack<StackValueType> &s, T t ) { s.push( t ); }
void MyCompressData::AnalysisWildCard(const char *inWildCard,char *outFileList,std::stack<std::string>& ioStack) { bool theStartFlag = 1; if(outFileList[0] != '\0') { theStartFlag = 0; } HANDLE hFind; WIN32_FIND_DATA fd; //================================ //ワイルドカード使用時 //================================ hFind = FindFirstFile(inWildCard, &fd); //検索失敗 if(hFind == INVALID_HANDLE_VALUE) { return; } //=================================== //ディレクトリの名前取得 //=================================== char theDirName[256]; strcpy(theDirName,inWildCard); for(int i = (int)strlen(theDirName); i >= 0; i--) { if(theDirName[i] == '/') { theDirName[i + 1] = '\0'; break; } } char theBuffer[256]; do { if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { if(theStartFlag == 0) { strcat(outFileList,","); } strcat(outFileList,theDirName); strcat(outFileList,fd.cFileName); theStartFlag = 0; } else if(fd.cFileName[0] != '.') { strcpy(theBuffer,theDirName); strcat(theBuffer,fd.cFileName); strcat(theBuffer,"/"); strcat(theBuffer,"*"); ioStack.push(std::string(theBuffer)); } } while(FindNextFile(hFind, &fd)); FindClose(hFind); }
/** * An exception-safe push-and-release function for unique_ptr objects: the * unique_ptr will be released only if pushing succeeds. * * @tparam StackValueType The stack's \c value_type. * @tparam PointedToType The pointed-to type. * @param s The stack to push onto. * @param p A pointer to the object to push. */ template<typename StackValueType,typename PointedToType> inline void push( std::stack<StackValueType> &s, std::unique_ptr<PointedToType> &p ) { s.push( p.get() ); p.release(); }
LAS_DLL void LASError_Pop(void) { if (errors.empty()) return; errors.pop(); }
void endElement(void *ctx, const char *name) { CC_UNUSED_PARAM(ctx); CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top(); std::string sName((char*)name); if( sName == "dict" ) { m_tStateStack.pop(); m_tDictStack.pop(); if ( !m_tDictStack.empty()) { m_pCurDict = m_tDictStack.top(); } } else if (sName == "array") { m_tStateStack.pop(); m_tArrayStack.pop(); if (! m_tArrayStack.empty()) { m_pArray = m_tArrayStack.top(); } } else if (sName == "true") { CCString *str = new CCString("1"); if (SAX_ARRAY == curState) { m_pArray->addObject(str); } else if (SAX_DICT == curState) { m_pCurDict->setObject(str, m_sCurKey.c_str()); } str->release(); } else if (sName == "false") { CCString *str = new CCString("0"); if (SAX_ARRAY == curState) { m_pArray->addObject(str); } else if (SAX_DICT == curState) { m_pCurDict->setObject(str, m_sCurKey.c_str()); } str->release(); } else if (sName == "string" || sName == "integer" || sName == "real") { CCString* pStrValue = new CCString(m_sCurValue); if (SAX_ARRAY == curState) { m_pArray->addObject(pStrValue); } else if (SAX_DICT == curState) { m_pCurDict->setObject(pStrValue, m_sCurKey.c_str()); } pStrValue->release(); m_sCurValue.clear(); } m_tState = SAX_NONE; }
LAS_DLL int LASError_GetErrorCount(void) { return static_cast<int>(errors.size()); }
void startElement(void *ctx, const char *name, const char **atts) { CC_UNUSED_PARAM(ctx); CC_UNUSED_PARAM(atts); std::string sName((char*)name); if( sName == "dict" ) { m_pCurDict = new CCDictionary<std::string, CCObject*>(); if (m_eResultType == SAX_RESULT_DICT && ! m_pRootDict) { // Because it will call m_pCurDict->release() later, so retain here. m_pRootDict = m_pCurDict; m_pRootDict->retain(); } m_tState = SAX_DICT; CCSAXState preState = SAX_NONE; if (! m_tStateStack.empty()) { preState = m_tStateStack.top(); } if (SAX_ARRAY == preState) { // add the dictionary into the array m_pArray->addObject(m_pCurDict); } else if (SAX_DICT == preState) { // add the dictionary into the pre dictionary CCAssert(! m_tDictStack.empty(), "The state is wrong!"); CCDictionary<std::string, CCObject*>* pPreDict = m_tDictStack.top(); pPreDict->setObject(m_pCurDict, m_sCurKey); } m_pCurDict->release(); // record the dict state m_tStateStack.push(m_tState); m_tDictStack.push(m_pCurDict); } else if(sName == "key") { m_tState = SAX_KEY; } else if(sName == "integer") { m_tState = SAX_INT; } else if(sName == "real") { m_tState = SAX_REAL; } else if(sName == "string") { m_tState = SAX_STRING; } else if (sName == "array") { m_tState = SAX_ARRAY; m_pArray = new CCMutableArray<CCObject*>(); if (m_eResultType == SAX_RESULT_ARRAY && m_pRootArray == NULL) { m_pRootArray = m_pArray; m_pRootArray->retain(); } CCSAXState preState = SAX_NONE; if (! m_tStateStack.empty()) { preState = m_tStateStack.top(); } //CCSAXState preState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top(); if (preState == SAX_DICT) { m_pCurDict->setObject(m_pArray, m_sCurKey); } else if (preState == SAX_ARRAY) { CCAssert(! m_tArrayStack.empty(), "The state is worng!"); CCMutableArray<CCObject*>* pPreArray = m_tArrayStack.top(); pPreArray->addObject(m_pArray); } m_pArray->release(); // record the array state m_tStateStack.push(m_tState); m_tArrayStack.push(m_pArray); } else { m_tState = SAX_NONE; } }
~CGraphvizVisitor() { m_clusterStack.pop(); assert(m_clusterStack.empty()); }
void EvalStack::exec(char chr) { AttributeValue a, b, c; switch (chr) { case '+': case '-': case '*': case '/': case '>': case '<': case funcMin: case funcMax: case funcTable: if (vals.size() < 2) return; b = vals.top(); vals.pop(); a = vals.top(); vals.pop(); vals.push(binop(a, b, chr)); break; case '~': if (vals.size() < 1) return; if (vals.top().text.empty()) { a = vals.top(); vals.pop(); vals.emplace(-a.max, -a.min); } break; case ':': if (vals.size() < 3) return; c = vals.top(); vals.pop(); b = vals.top(); vals.pop(); a = vals.top(); vals.pop(); vals.push(a.max ? b : c); break; } }
void OnEndGraph(int kind, const std::string & id) { m_clusterStack.pop(); }
void MenuServices::run(const std::vector<std::string> &cmd, std::stack<std::unique_ptr<MenuBase>> &menuStack) { if (cmd.size() > 0) { if (cmd[0] == "find") { std::vector<std::string> knownServices = { // services std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_BRIGHTNESS, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_POWER_SWITCH, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_CONNECTION_MANAGER, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_AV_TRANSPORT, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_CONTENT_DIRECTORY, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_RENDERING_CONTROL, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_SCHEDULED_RECORDING, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_IF_CONFIG, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_LAYER3_FORWARDING, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_CABLE_LINK_CONFIG, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_DSL_LINK_CONFIG, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_ETHERNET_CONFIG, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_POTS_LINK_CONFIG, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_WAN_IP_CONNECTION, std::string(OC_RSRVD_WELL_KNOWN_URI) + "?rt=" + UPNP_OIC_TYPE_LAN_HOST_CONFIG }; for (auto service : knownServices) { OC::OCPlatform::findResource("", service, CT_DEFAULT, onFindResourceCb); } } else if (cmd[0] == "list") { if (!m_avTransport.empty()) { std::cout << "AV Transport Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_avTransport) { printResourceCompact(r); std::cout << std::endl; } } if (!m_brightness.empty()) { std::cout << "Brightness Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_brightness) { printResourceCompact(r); std::cout << std::endl; } } if (!m_binarySwitch.empty()) { std::cout << "Binary Switch Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_binarySwitch) { printResourceCompact(r); std::cout << std::endl; } } if (!m_connectionManager.empty()) { std::cout << "Connection Manager Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_connectionManager) { printResourceCompact(r); std::cout << std::endl; } } if (!m_contentDirectory.empty()) { std::cout << "Content Dirctory Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_contentDirectory) { printResourceCompact(r); std::cout << std::endl; } } if (!m_layer3Forwarding.empty()) { std::cout << "Layer 3 Forwarding Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_layer3Forwarding) { printResourceCompact(r); std::cout << std::endl; } } if (!m_renderingControl.empty()) { std::cout << "Rendering Control Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_renderingControl) { printResourceCompact(r); std::cout << std::endl; } } if (!m_scheduledRecording.empty()) { std::cout << "Scheduled Recording Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_scheduledRecording) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanIfConfig.empty()) { std::cout << "WAN IF Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanIfConfig) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanCableLinkConfig.empty()) { std::cout << "WAN Cable Link Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanCableLinkConfig) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanDSLLinkConfig.empty()) { std::cout << "WAN DSL Link Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanDSLLinkConfig) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanEthernetConfig.empty()) { std::cout << "WAN Ethernet Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanEthernetConfig) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanPotsLinkConfig.empty()) { std::cout << "WAN POTS Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanPotsLinkConfig) { printResourceCompact(r); std::cout << std::endl; } } if (!m_wanIPConnection.empty()) { std::cout << "WAN IP Connection Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_wanIPConnection) { printResourceCompact(r); std::cout << std::endl; } } if (!m_lanHostConfig.empty()) { std::cout << "LAN Host Config Service(s) found:" << std::endl; std::cout << "---------------------------------------------" << std::endl; for ( auto r : m_lanHostConfig) { printResourceCompact(r); std::cout << std::endl; } } } else if ("av" == cmd[0]) { std::unique_ptr<MenuAVTransport> menuItem(new MenuAVTransport); menuItem->init(m_avTransport); menuStack.push(std::move(menuItem)); } else if ("brightness" == cmd[0]) { std::unique_ptr<MenuBrightness> menuItem(new MenuBrightness); menuItem->init(m_brightness); menuStack.push(std::move(menuItem)); } else if ("switch" == cmd[0]) { std::unique_ptr<MenuBinarySwitch> menuItem(new MenuBinarySwitch); menuItem->init(m_binarySwitch); menuStack.push(std::move(menuItem)); } else if ("connection" == cmd[0]) { std::unique_ptr<MenuConnectionManager> menuItem(new MenuConnectionManager); menuItem->init(m_connectionManager); menuStack.push(std::move(menuItem)); } else if ("content" == cmd[0]) { std::unique_ptr<MenuContentDirectory> menuItem(new MenuContentDirectory); menuItem->init(m_contentDirectory); menuStack.push(std::move(menuItem)); } else if ("layer3" == cmd[0]) { std::unique_ptr<MenuLayer3Forwarding> menuItem(new MenuLayer3Forwarding); menuItem->init(m_layer3Forwarding); menuStack.push(std::move(menuItem)); } else if ("rendering" == cmd[0]) { std::unique_ptr<MenuRenderingControl> menuItem(new MenuRenderingControl); menuItem->init(m_renderingControl); menuStack.push(std::move(menuItem)); } else if ("recording" == cmd[0]) { std::cout << "Scheduled Recording Menu not yet Implemented" << std::endl; } else if ("ifconfig" == cmd[0]) { std::unique_ptr<MenuWANCommonInterface> menuItem(new MenuWANCommonInterface); menuItem->init(m_wanIfConfig); menuStack.push(std::move(menuItem)); } else if ("cableconfig" == cmd[0]) { std::cout << "WAN Cable Link Config Menu not yet Implemented" << std::endl; } else if ("dslconfig" == cmd[0]) { std::cout << "WAN DSL Link Config Menu not yet Implemented" << std::endl; } else if ("netconfig" == cmd[0]) { std::cout << "WAN Ethernet Config Menu not yet Implemented" << std::endl; } else if ("potsconfig" == cmd[0]) { std::cout << "WAN POTS Config Menu not yet Implemented" << std::endl; } else if ("ipconnection" == cmd[0]) { std::unique_ptr<MenuWANIpConnection> menuItem(new MenuWANIpConnection); menuItem->init(m_wanIPConnection); menuStack.push(std::move(menuItem)); } else if ("lanhost" == cmd[0]) { std::unique_ptr<MenuLANHostConfigManagement> menuItem(new MenuLANHostConfigManagement); menuItem->init(m_lanHostConfig); menuStack.push(std::move(menuItem)); } else if ("clear" == cmd[0]) { m_avTransport.clear(); m_binarySwitch.clear(); m_brightness.clear(); m_connectionManager.clear(); m_contentDirectory.clear(); m_layer3Forwarding.clear(); m_renderingControl.clear(); m_scheduledRecording.clear(); m_wanIfConfig.clear(); print(); } else if ("q" == cmd[0]) { m_quit = true; } else if ("b" == cmd[0]) { if (menuStack.size() <= 1) { print(); return; //do nothing } else { menuStack.pop(); menuStack.top()->print(); } } else if ("h" == cmd[0]) { help(); } else { std::cout << "unknown command." << std::endl; print(); } } }
void OnEndCluster(const std::string & id) { m_clusterStack.pop(); }
void PushExpValueCount(int count) { exp_value_count_.push(count); }
void endElement(void *ctx, const char *name) { CC_UNUSED_PARAM(ctx); SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top(); const std::string sName((char*)name); if( sName == "dict" ) { _stateStack.pop(); _dictStack.pop(); if ( !_dictStack.empty()) { _curDict = _dictStack.top(); } } else if (sName == "array") { _stateStack.pop(); _arrayStack.pop(); if (! _arrayStack.empty()) { _curArray = _arrayStack.top(); } } else if (sName == "true") { if (SAX_ARRAY == curState) { _curArray->push_back(Value(true)); } else if (SAX_DICT == curState) { (*_curDict)[_curKey] = Value(true); } } else if (sName == "false") { if (SAX_ARRAY == curState) { _curArray->push_back(Value(false)); } else if (SAX_DICT == curState) { (*_curDict)[_curKey] = Value(false); } } else if (sName == "string" || sName == "integer" || sName == "real") { if (SAX_ARRAY == curState) { if (sName == "string") _curArray->push_back(Value(_curValue)); else if (sName == "integer") _curArray->push_back(Value(atoi(_curValue.c_str()))); else _curArray->push_back(Value(atof(_curValue.c_str()))); } else if (SAX_DICT == curState) { if (sName == "string") (*_curDict)[_curKey] = Value(_curValue); else if (sName == "integer") (*_curDict)[_curKey] = Value(atoi(_curValue.c_str())); else (*_curDict)[_curKey] = Value(atof(_curValue.c_str())); } _curValue.clear(); } _state = SAX_NONE; }
void DroneController::popAllCommands() { m_mutex.lock(); while(!m_commandStack.empty()) m_commandStack.pop(); m_mutex.unlock(); }