bool Json::operator == (const Json& other) const { if (this == &other) return true; if (IsNull()) return other.IsNull(); if (other.IsNull()) return false; if (value_->type() != other.value_->type()) return false; if (IsInteger()) return integer() == other.integer(); if (IsUInteger()) return uinteger() == other.uinteger(); if (IsReal()) return real() == other.real(); if (IsString()) return string() == other.string(); if (IsArray()) return array() == other.array(); if (IsObject()) return object() == other.object(); return false; }
static void test_strutils() { // string conversion check(to_string(integer(0)) == "0"); check(to_string(integer(-1)) == "-1"); check(to_string(INTEGER_MAX) == INTEGER_MAX_STR); check(to_string(INTEGER_MIN) == INTEGER_MIN_STR); check(to_string(1, 10, 4, '0') == "0001"); check(to_string(integer(123456789)) == "123456789"); check(to_string(-123, 10, 7, '0') == "-000123"); check(to_string(0xabcde, 16, 6) == "0ABCDE"); bool e = true, o = true; check(from_string("0", &e, &o) == 0); check(!o); check(!e); check(from_string(INTEGER_MAX_STR, &e, &o) == INTEGER_MAX); check(from_string(INTEGER_MAX_STR_PLUS, &e, &o) == uinteger(INTEGER_MAX) + 1); check(from_string("92233720368547758070", &e, &o) == 0); check(o); check(from_string("-1", &e, &o) == 0 ); check(e); check(from_string("89abcdef", &e, &o, 16) == 0x89abcdef); check(from_string("afg", &e, &o, 16) == 0); check(e); check(remove_filename_path("/usr/bin/true") == "true"); check(remove_filename_path("usr/bin/true") == "true"); check(remove_filename_path("/true") == "true"); check(remove_filename_path("true") == "true"); check(remove_filename_path("c:\\Windows\\false") == "false"); check(remove_filename_path("\\Windows\\false") == "false"); check(remove_filename_path("Windows\\false") == "false"); check(remove_filename_path("\\false") == "false"); check(remove_filename_path("false") == "false"); check(remove_filename_ext("/usr/bin/true.exe") == "/usr/bin/true"); check(remove_filename_ext("true.exe") == "true"); check(remove_filename_ext("true") == "true"); check(to_printable('a') == "a"); check(to_printable('\\') == "\\\\"); check(to_printable('\'') == "\\'"); check(to_printable('\x00') == "\\x00"); check(to_printable('\x7f') == "\\x7F"); check(to_printable("abc \x01'\\") == "abc \\x01\\'\\\\"); }
//====================================================================== // ANTI2SPcal class member functions: // void ANTI2SPcal::build(){ // fill array of objects with data integer i,j,endflab; geant hthr,hdthr[ANTI2C::MAXANTI]; // hist-discr threshold(p.e.) geant dqthr,daqthr[ANTI2C::MAXANTI];//daq-readout thresh(adc-ch) geant ftdl[2],ftdel[ANTI2C::MAXANTI][2]; geant t0[2],tzer[ANTI2C::MAXANTI][2],m2p[4],m2pe[ANTI2C::MAXANTI][4]; char fname[1024]; char name[256]; int ctyp,ntypes; // char datt[3]; char ext[80]; int date[2],year,mon,day,hour,min,sec; uinteger iutct; tm begin; time_t utct; uinteger verids[10],verid; // // ---> read cal.files-versions file : // strcpy(name,"AccCflist");// basic name for vers.list-file if(AMSJob::gethead()->isMCData()){ strcpy(datt,"MC"); sprintf(ext,"%d",ATMCFFKEY.calvern);//MC-versn } else{ strcpy(datt,"RD"); sprintf(ext,"%d",ATREFFKEY.calutc);//RD-utc } strcat(name,datt); strcat(name,"."); strcat(name,ext); // if(ATCAFFKEY.cafdir==0)strcpy(fname,AMSDATADIR.amsdatadir); if(ATCAFFKEY.cafdir==1)strcpy(fname,""); strcat(fname,name); cout<<"====> ANTI2SPcal::build: Opening Calib_vers_list-file "<<fname<<'\n'; ifstream vlfile(fname,ios::in); // open needed verslist-file for reading if(!vlfile){ cout <<"<---- Error: missing vers_list-file "<<fname<<endl; exit(1); } vlfile >> ntypes;// total number of calibr. file types in the list for(i=0;i<ntypes;i++){ vlfile >> verids[i];// } if(AMSJob::gethead()->isMCData()){ vlfile >> date[0];//YYYYMMDD beg.validity of AccCflistMC.ext file vlfile >> date[1];//HHMMSS ...................................... year=date[0]/10000;//2004-> mon=(date[0]%10000)/100;//1-12 day=(date[0]%100);//1-31 hour=date[1]/10000;//0-23 min=(date[1]%10000)/100;//0-59 sec=(date[1]%100);//0-59 begin.tm_isdst=0; begin.tm_sec=sec; begin.tm_min=min; begin.tm_hour=hour; begin.tm_mday=day; begin.tm_mon=mon-1; begin.tm_year=year-1900; utct=mktime(& begin); iutct=uinteger(utct); cout<<" AccCflistMC-file begin_date: year:month:day = "<<year<<":"<<mon<<":"<<day<<endl; cout<<" hour:min:sec = "<<hour<<":"<<min<<":"<<sec<<endl; cout<<" UTC-time = "<<iutct<<endl; }
bool SQRGUIStyle::Initialize(void) { if(!m_isLoad) { ipkgstream iXML; TiXmlDocument XmlDoc; UIString Str = m_strStylePath + "Config.xml"; if (iXML.open(GUI_PATH_ALIAS_GUI.c_str(), Str.c_str())) return false; iXML>>XmlDoc; TiXmlNode* pStyle = XmlDoc.FirstChild("Style"); for( TiXmlNode* pNode = pStyle->FirstChild("GUI");pNode; pNode = pNode->NextSibling("GUI") ) { TiXmlElement* pElement = pNode->ToElement(); if (!pElement) continue; StyleStruct* pStyle = SetStyleStruct(pElement->Attribute("Name"),StyleStruct()); pStyle->m_TexString = pElement->Attribute("Texture"); Str = m_strTexture + pStyle->m_TexString; if(pStyle->m_TexString.size()>0) CGraphic::GetInst()->CreateTexture(GUI_PATH_ALIAS_GUITEX.c_str(), Str.c_str(), &(pStyle->pTexture)); for( TiXmlNode* pElemNode = pNode->FirstChild("Elem"); pElemNode; pElemNode = pElemNode->NextSibling("Elem") ) { TiXmlElement* pElem = pElemNode->ToElement(); if(!pElem) continue; int Type; pElem->QueryIntAttribute("EventState",&Type); BLOCK_POOL& BlockPool = pStyle->m_vecPool[static_cast<EventStateMask>(Type)]; for( TiXmlNode* pBlockPoolNode = pElemNode->FirstChild("BlockPool"); pBlockPoolNode; pBlockPoolNode = pBlockPoolNode->NextSibling("BlockPool") ) { TiXmlElement* pElemBlockPool = pBlockPoolNode->ToElement(); if (!pElemBlockPool) continue; int Index; pElemBlockPool->QueryIntAttribute("Index",&Index); if( static_cast<UINT>(Index)>BLOCK_POOL::MAX_BLOCK_NUM || Index < 1) continue; GUI_BLOCK& Block = BlockPool.InitBlock(Index); for( TiXmlNode* pBlockNode = pElemBlockPool->FirstChild("Block"); pBlockNode; pBlockNode = pBlockNode->NextSibling("Block") ) { CFRect Rect; int BlockMask; TiXmlElement* pElemBlock = pBlockNode->ToElement(); if (!pElemBlock) continue; pElemBlock->QueryIntAttribute("BlockMask",&BlockMask); pElemBlock->QueryFloatAttribute("Top",&(Rect.top)); pElemBlock->QueryFloatAttribute("Left",&(Rect.left)); pElemBlock->QueryFloatAttribute("Right",&(Rect.right)); pElemBlock->QueryFloatAttribute("Bottom",&(Rect.bottom)); Block[BlockMask] = Rect; } TiXmlNode* pFontNode = pElemBlockPool->FirstChild("Font"); if ( pFontNode ) { // 有font信息 TiXmlElement* pElemFont = pFontNode->ToElement(); if (!pElemFont) continue; if (pStyle->m_vecFont.find(Index) == pStyle->m_vecFont.end()) pStyle->m_vecFont[Index] = new GUI_FONT(); GUI_FONT* GuiFont = pStyle->m_vecFont[Index]; std::string winFontId = pElemFont->Attribute(GUILayoutHandler::PropertyNameFont.c_str()); int32 fontid; integer(winFontId,fontid); GuiFont->m_nFontID = fontid; std::string winFontSize = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontSize.c_str()); uint32 FontSize; uinteger(winFontSize,FontSize); GuiFont->m_FontSize = uint32(FontSize); std::string winFGCol = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontGCol.c_str()); uint32 tempCol; uinteger(winFGCol, tempCol); GuiFont->m_uFontGradualColor = (uint32)tempCol; std::string winFGEff = pElemFont->Attribute(GUILayoutHandler::PropertyNameFontEffe.c_str()); uint32 tempeff; uinteger(winFGEff, tempeff); GuiFont->m_uFontEffectMask = (uint32)tempeff; } TiXmlNode* pEvtFontNode = pElemBlockPool->FirstChild("EvtFont"); if (pEvtFontNode) { TiXmlElement* pElemFont = pEvtFontNode->ToElement(); if (!pElemFont) continue; // 有这类结点 if (pStyle->m_vecFont.find(Index) != pStyle->m_vecFont.end()) { // 只有创建过的才去读 GUI_FONT* GuiFont = pStyle->m_vecFont[Index]; if (GuiFont) { // 字体颜色 std::string sStateCol = pElemFont->Attribute(GUILayoutHandler::PropertyStateColor.c_str()); uint32 iStateCol; uinteger(sStateCol, iStateCol); GuiFont->m_EventFont[static_cast<EventStateMask>(Type)].m_FontColor = (uint32)iStateCol; std::string sRimCol = pElemFont->Attribute(GUILayoutHandler::PropertyRimColor.c_str()); uint32 iRimCol; uinteger(sRimCol, iRimCol); GuiFont->m_EventFont[static_cast<EventStateMask>(Type)].m_uFontBkColor = (uint32)iRimCol; } } } } } } m_isLoad = true; }