std::string pciEntry::verbose() const { std::ostringstream oss(std::ostringstream::out); oss << " (vendor:" << hexFmt(vendor, 4, false) << " device:" << hexFmt(device, 4, false); if (subvendor != 0xffff || subdevice != 0xffff) oss << " subv:" << hexFmt(subvendor, 4, false) << " subd:" << hexFmt(subdevice, 4, false); oss << ")"; return oss.str(); }
std::string BaseDeviate::make_repr(bool incl_seed) { // Remember: Don't start with nothing! See discussion in FormatAndThrow in Std.h std::ostringstream oss(" "); oss << "galsim.BaseDeviate("; if (incl_seed) oss << "seed='"<<serialize()<<"'"; oss<<")"; return oss.str(); }
std::string BinomialDeviate::make_repr(bool incl_seed) { std::ostringstream oss(" "); oss << "galsim.BinomialDeviate("; if (incl_seed) oss << seedstring(split(serialize(), ' ')) << ", "; oss << "N="<<getN()<<", "; oss << "p="<<getP()<<")"; return oss.str(); }
std::string GammaDeviate::make_repr(bool incl_seed) { std::ostringstream oss(" "); oss << "galsim.GammaDeviate("; if (incl_seed) oss << "seed='"<<serialize()<<"',"; oss << "k="<<getK()<<", "; oss << "theta="<<getTheta()<<")"; return oss.str(); }
std::string WeibullDeviate::make_repr(bool incl_seed) { std::ostringstream oss(" "); oss << "galsim.WeibullDeviate("; if (incl_seed) oss << "seed='"<<serialize()<<"',"; oss << "a="<<getA()<<", "; oss << "b="<<getB()<<")"; return oss.str(); }
std::string SBMoffat::SBMoffatImpl::serialize() const { std::ostringstream oss(" "); oss.precision(std::numeric_limits<double>::digits10 + 4); oss << "galsim._galsim.SBMoffat("<<getBeta()<<", "<<getScaleRadius(); oss << ", None, None, "<<getTrunc()<<", "<<getFlux(); oss << ", galsim.GSParams("<<*gsparams<<"))"; return oss.str(); }
std::string GaussianDeviate::make_repr(bool incl_seed) { std::ostringstream oss(" "); oss << "galsim.GaussianDeviate("; if (incl_seed) oss << seedstring(split(serialize(), ' ')) << ", "; oss << "mean="<<getMean()<<", "; oss << "sigma="<<getSigma()<<")"; return oss.str(); }
int main(int argc, char* argv[]) { if (argc != 3) { std::cout << "usage: " << argv[0] << " hash file " << std::endl; std::cout << " check the MD5 hash of a file" << std::endl; std::cout << " Adobe Source Libraries v" << ADOBE_VERSION_MAJOR << "." << ADOBE_VERSION_MINOR << "." << ADOBE_VERSION_SUBMINOR << std::endl; std::cout << " Boost v" << BOOST_VERSION / 100000 << "." << BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << std::endl; return 1; } bool success = false; try { adobe::md5_t m; boost::filesystem::path file_path(argv[2]); boost::filesystem::ifstream stream(file_path, std::ios::binary | std::ios::in); while (stream.good()) { boost::array<std::ifstream::char_type, 256 * 1024> buffer; stream.read(&buffer[0], static_cast<std::streamsize>(buffer.size())); std::streamsize gcount(stream.gcount()); if (gcount > 0) m.update(&buffer[0], static_cast<std::size_t>(gcount)); } adobe::md5_t::digest_t hash(m.final()); adobe::md5_t::digest_t::iterator first(hash.begin()); adobe::md5_t::digest_t::iterator last(hash.end()); std::string actual; std::ostringstream oss(actual); for (; first != last; ++first) { oss.width(2); oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(*first); } std::string expected(argv[1]); success = oss.str() == expected; if (!success) std::cout << "Expected: " << expected << " actual: " << oss.str() << std::endl; } catch (const std::exception& error) { std::cerr << "Exception: " << error.what() << std::endl; } catch (...) { std::cerr << "Unknown exception" << std::endl; } return success ? 0 : 1; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializePlan // // @doc: // Verifies that after parsing the given DXL file into a DXL tree, // it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializePlan ( IMemoryPool *pmp, const CHAR *szDXLFileName, BOOL fValidate ) { CWStringDynamic str(pmp); COstreamString oss(&str); // read DXL file CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName); GPOS_CHECK_ABORT; const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree ULLONG ullPlanId = ULLONG_MAX; ULLONG ullPlanSpaceSize = ULLONG_MAX; CDXLNode *pdxlnRoot = CDXLUtils::PdxlnParsePlan(pmp, szDXL, szValidationPath, &ullPlanId, &ullPlanSpaceSize); GPOS_CHECK_ABORT; oss << "Serializing parsed tree" << std::endl; CWStringDynamic strPlan(pmp); COstreamString osPlan(&strPlan); CDXLUtils::SerializePlan(pmp, osPlan, pdxlnRoot, ullPlanId, ullPlanSpaceSize, true /*fSerializeHeaderFooter*/, true /*fIndent*/); GPOS_CHECK_ABORT; CWStringDynamic dstrExpected(pmp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL); if (!dstrExpected.FEquals(&strPlan)) { GPOS_TRACE(dstrExpected.Wsz()); GPOS_TRACE(strPlan.Wsz()); GPOS_ASSERT(!"Not matching"); } // cleanup pdxlnRoot->Release(); GPOS_DELETE_ARRAY(szDXL); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializePlan // // @doc: // Verifies that after parsing the given DXL file into a DXL tree, // it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializePlan ( IMemoryPool *mp, const CHAR *dxl_filename, BOOL fValidate ) { CWStringDynamic str(mp); COstreamString oss(&str); // read DXL file CHAR *dxl_string = CDXLUtils::Read(mp, dxl_filename); GPOS_CHECK_ABORT; const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree ULLONG plan_id = gpos::ullong_max; ULLONG plan_space_size = gpos::ullong_max; CDXLNode *root_dxl_node = CDXLUtils::GetPlanDXLNode(mp, dxl_string, szValidationPath, &plan_id, &plan_space_size); GPOS_CHECK_ABORT; oss << "Serializing parsed tree" << std::endl; CWStringDynamic strPlan(mp); COstreamString osPlan(&strPlan); CDXLUtils::SerializePlan(mp, osPlan, root_dxl_node, plan_id, plan_space_size, true /*serialize_header_footer*/, true /*indentation*/); GPOS_CHECK_ABORT; CWStringDynamic dstrExpected(mp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), dxl_string); if (!dstrExpected.Equals(&strPlan)) { GPOS_TRACE(dstrExpected.GetBuffer()); GPOS_TRACE(strPlan.GetBuffer()); GPOS_ASSERT(!"Not matching"); } // cleanup root_dxl_node->Release(); GPOS_DELETE_ARRAY(dxl_string); return GPOS_OK; }
std::string SBAdd::SBAddImpl::repr() const { std::ostringstream oss(" "); oss << "galsim._galsim.SBAdd(["; ConstIter sptr = _plist.begin(); oss << sptr->repr(); for (++sptr; sptr!=_plist.end(); ++sptr) oss << ", " << sptr->repr(); oss << "], galsim.GSParams("<<*gsparams<<"))"; return oss.str(); }
void NodeMetadata::serialize(std::ostream &os) { u8 buf[2]; writeU16(buf, typeId()); os.write((char*)buf, 2); std::ostringstream oss(std::ios_base::binary); serializeBody(oss); os<<serializeString(oss.str()); }
string uniqAlUnitColumnCollection::print(const vocTable & voc) const { ostringstream oss(""); int count=0; for (vector<uniqAlUnitColumn>::const_iterator it=collection.begin();it!=collection.end();++it){ // if (it != collection.begin()){oss<<", ";} oss<<count<<" ["<<it->print(voc)<<"] "; ++count; } return oss.str(); }
std::string SBAutoCorrelate::SBAutoCorrelateImpl::serialize() const { std::ostringstream oss(" "); oss.precision(std::numeric_limits<double>::digits10 + 4); oss << "galsim._galsim.SBAutoCorrelate(" << _adaptee.serialize() << ", "; if (_real_space) oss << "True"; else oss << "False"; oss << ", galsim.GSParams("<<*gsparams<<"))"; return oss.str(); }
std::string SBConvolve::SBConvolveImpl::serialize() const { std::ostringstream oss(" "); oss.precision(std::numeric_limits<double>::digits10 + 4); oss << "galsim._galsim.SBConvolve(["; ConstIter sptr = _plist.begin(); oss << sptr->serialize(); for (++sptr; sptr!=_plist.end(); ++sptr) oss << ", " << sptr->serialize(); oss << "], galsim.GSParams("<<*gsparams<<"))"; return oss.str(); }
//--------------------------------------------------------------------------- // @function: // CMDAccessorTest::EresUnittest_Navigate // // @doc: // Test fetching a MD object from the cache and navigating its dependent // objects // //--------------------------------------------------------------------------- GPOS_RESULT CMDAccessorTest::EresUnittest_Navigate() { CAutoMemoryPool amp; IMemoryPool *mp = amp.Pmp(); // setup a file-based provider CMDProviderMemory *pmdp = CTestUtils::m_pmdpf; pmdp->AddRef(); CMDAccessor mda(mp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp); // lookup a function in the MD cache CMDIdGPDB *mdid_func = GPOS_NEW(mp) CMDIdGPDB(GPDB_FUNC_TIMEOFDAY /* OID */, 1 /* major version */, 0 /* minor version */); const IMDFunction *pmdfunc = mda.RetrieveFunc(mdid_func); // lookup function return type IMDId *pmdidFuncReturnType = pmdfunc->GetResultTypeMdid(); const IMDType *pimdtype = mda.RetrieveType(pmdidFuncReturnType); // lookup equality operator for function return type IMDId *pmdidEqOp = pimdtype->GetMdidForCmpType(IMDType::EcmptEq); #ifdef GPOS_DEBUG const IMDScalarOp *md_scalar_op = #endif mda.RetrieveScOp(pmdidEqOp); #ifdef GPOS_DEBUG // print objects CWStringDynamic str(mp); COstreamString oss(&str); oss << std::endl; oss << std::endl; pmdfunc->DebugPrint(oss); oss << std::endl; pimdtype->DebugPrint(oss); oss << std::endl; md_scalar_op->DebugPrint(oss); oss << std::endl; GPOS_TRACE(str.GetBuffer()); #endif mdid_func->Release(); return GPOS_OK; }
// Generates a human-readable string representation of a token. std::string Token::toString() { std::ostringstream oss(""); oss << "[Token]" << "\nText: \"" << stringValue << "\"" << "\nFile: \"" << tokenFileName << "\"" << "\nLocation: Line " << tokenLocation.first_line << "." << tokenLocation.first_column << " - " << tokenLocation.last_line << "." << tokenLocation.last_column << std::endl; return oss.str(); }
void tryStringFind() { std::ostringstream oss(std::ostringstream::out); oss<<"ls -l | wc -w"; std::string cmd = oss.str(); std::string mem1(10,' '); std::copy(cmd.begin(), std::find(cmd.begin(), cmd.end(), '|'), mem1.begin()); std::cout<<"cmd : "<<cmd<<std::endl; std::cout<<"membre1 : "<<mem1<<std::endl; }
bool v4l_capture::init_all(size_t _width, size_t _height, unsigned int _devId) { width = _width; height = _height; std::ostringstream oss(""); oss << "/dev/video" << _devId; dev_name = oss.str(); if (!open_device()) return false; init_device(); if (!start_capturing()) return false; return true; }
void writeConfigurationToFile() { std::ofstream oss("settings.lua"); oss << "setfenv(1, Configuration);" << std::endl; oss << "setResolution( " << int(screenWidth) << ", " << int(screenHeight) << " );" << std::endl; oss << "setBpp( " << int(bpp) << " );" << std::endl; oss << "useFullscreen( " << std::boolalpha << fullscreenenabled << " );" << std::endl; oss << "showDebugStdout( " << std::boolalpha << debug_stdout << " );" << std::endl; oss << "showDebugFileout( " << std::boolalpha << debug_fileout << " );" << std::endl; oss << "showInfoMessages( " << std::boolalpha << show_info_messages << " );" << std::endl; oss << "showWarningMessages( " << std::boolalpha << show_warn_messages << " );" << std::endl; }
std::string spliceVectorToStringByDelim(const std::vector<std::string> &elts, const std::string& delim) { std::ostringstream oss(""); if (elts.empty() == false) { std::vector<std::string>::const_iterator it = elts.begin(), end = elts.end(); std::copy(it, end - 1, std::ostream_iterator<std::string>(oss, delim.c_str())); oss << *(end - 1); } return oss.str(); }
string linkCluster::print() const { ostringstream oss(""); for (vector<int>::const_iterator p=sPosis.begin();p!=sPosis.end();++p){ if (p != sPosis.begin()){oss<<",";} oss<<*p; } oss<<"-"; for (vector<int>::const_iterator p=tPosis.begin();p!=tPosis.end();++p){ if (p != tPosis.begin()){oss<<",";} oss<<*p; } return oss.str(); }
bool loadGameConfAndInitWorld(const std::string &path, const SubgameSpec &gamespec) { // Override defaults with those provided by the game. // We clear and reload the defaults because the defaults // might have been overridden by other subgame config // files that were loaded before. g_settings->clearDefaults(); set_default_settings(g_settings); Settings game_defaults; getGameMinetestConfig(gamespec.path, game_defaults); override_default_settings(g_settings, &game_defaults); infostream << "Initializing world at " << path << std::endl; fs::CreateAllDirs(path); // Create world.mt if does not already exist std::string worldmt_path = path + DIR_DELIM "world.mt"; if (!fs::PathExists(worldmt_path)) { Settings conf; conf.set("gameid", gamespec.id); conf.set("backend", "sqlite3"); conf.set("player_backend", "sqlite3"); conf.setBool("creative_mode", g_settings->getBool("creative_mode")); conf.setBool("enable_damage", g_settings->getBool("enable_damage")); if (!conf.updateConfigFile(worldmt_path.c_str())) return false; } // Create map_meta.txt if does not already exist std::string map_meta_path = path + DIR_DELIM + "map_meta.txt"; if (!fs::PathExists(map_meta_path)) { verbosestream << "Creating map_meta.txt (" << map_meta_path << ")" << std::endl; fs::CreateAllDirs(path); std::ostringstream oss(std::ios_base::binary); Settings conf; MapgenParams params; params.readParams(g_settings); params.writeParams(&conf); conf.writeLines(oss); oss << "[end_of_params]\n"; fs::safeWriteToFile(map_meta_path, oss.str()); } return true; }
std::string AuthStore::BinarySerializerDeserializer:: serialize_digest(const Digest* digest) { std::ostringstream oss(std::ostringstream::out|std::ostringstream::binary); oss << digest->_ha1 << '\0'; oss << digest->_opaque << '\0'; oss << digest->_nonce << '\0'; oss << digest->_impi << '\0'; oss << digest->_realm << '\0'; oss.write((const char *)&digest->_nonce_count, sizeof(int)); oss << digest->_impu << '\0'; return oss.str(); }
CraftInput createInput(const CraftPointerInput &cpi) { std::vector<std::string> items; for(u32 i=0; i<cpi.items.size(); i++){ if(cpi.items[i] == NULL) items.push_back(""); else{ std::ostringstream oss(std::ios::binary); cpi.items[i]->serialize(oss); items.push_back(oss.str()); } } return CraftInput(cpi.width, items); }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeQuery // // @doc: // Verifies that after parsing the given DXL file into a DXL tree // representing a query, it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeQuery ( IMemoryPool *mp, const CHAR *dxl_filename, BOOL fValidate ) { CWStringDynamic str(mp); COstreamString oss(&str); // read DXL file CHAR *dxl_string = CDXLUtils::Read(mp, dxl_filename); const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree CQueryToDXLResult *pq2dxlresult = CDXLUtils::ParseQueryToQueryDXLTree(mp, dxl_string, szValidationPath); GPOS_ASSERT(NULL != pq2dxlresult); oss << "Serializing parsed tree" << std::endl; CDXLNode *root_dxlnode = const_cast<CDXLNode *>(pq2dxlresult->CreateDXLNode()); CDXLNodeArray* dxl_array = const_cast<CDXLNodeArray* >(pq2dxlresult->GetOutputColumnsDXLArray()); CDXLNodeArray* cte_producers = const_cast<CDXLNodeArray* >(pq2dxlresult->GetCTEProducerDXLArray()); CWStringDynamic wstrQuery(mp); COstreamString osQuery(&wstrQuery); CDXLUtils::SerializeQuery(mp, osQuery, root_dxlnode, dxl_array, cte_producers, true /*serialize_header_footer*/, true /*indentation*/); CWStringDynamic dstrExpected(mp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), dxl_string); if (!dstrExpected.Equals(&wstrQuery)) { GPOS_TRACE(wstrQuery.GetBuffer()); } // cleanup GPOS_DELETE(pq2dxlresult); GPOS_DELETE_ARRAY(dxl_string); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeMetadata // // @doc: // Verifies that after parsing the given DXL file containing metadata into // a list of metadata objects, which should be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeMetadata ( IMemoryPool *mp, const CHAR *dxl_filename, BOOL fValidate ) { CWStringDynamic str(mp); COstreamString oss(&str); // read DXL file CHAR *dxl_string = CDXLUtils::Read(mp, dxl_filename); GPOS_CHECK_ABORT; // parse the metadata objects into a dynamic array const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } IMDCacheObjectArray *mdcache_obj_array = CDXLUtils::ParseDXLToIMDObjectArray(mp, dxl_string, szValidationPath); GPOS_ASSERT(NULL != mdcache_obj_array); GPOS_CHECK_ABORT; oss << "Serializing metadata objects" << std::endl; CWStringDynamic *metadata_str = CDXLUtils::SerializeMetadata(mp, mdcache_obj_array, true /*serialize_header_footer*/, true /*indentation*/); GPOS_CHECK_ABORT; CWStringDynamic dstrExpected(mp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), dxl_string); if (!dstrExpected.Equals(metadata_str)) { GPOS_TRACE(metadata_str->GetBuffer()); GPOS_ASSERT(false); } mdcache_obj_array->Release(); GPOS_DELETE(metadata_str); GPOS_DELETE_ARRAY(dxl_string); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeQuery // // @doc: // Verifies that after parsing the given DXL file into a DXL tree // representing a query, it will be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeQuery ( IMemoryPool *pmp, const CHAR *szDXLFileName, BOOL fValidate ) { CWStringDynamic str(pmp); COstreamString oss(&str); // read DXL file CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName); const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } // the root of the parsed DXL tree CQueryToDXLResult *pq2dxlresult = CDXLUtils::PdxlnParseDXLQuery(pmp, szDXL, szValidationPath); GPOS_ASSERT(NULL != pq2dxlresult); oss << "Serializing parsed tree" << std::endl; CDXLNode *pdxlnRoot = const_cast<CDXLNode *>(pq2dxlresult->Pdxln()); DrgPdxln* pdrgpdxln = const_cast<DrgPdxln* >(pq2dxlresult->PdrgpdxlnOutputCols()); DrgPdxln* pdrgpdxlnCTE = const_cast<DrgPdxln* >(pq2dxlresult->PdrgpdxlnCTE()); CWStringDynamic wstrQuery(pmp); COstreamString osQuery(&wstrQuery); CDXLUtils::SerializeQuery(pmp, osQuery, pdxlnRoot, pdrgpdxln, pdrgpdxlnCTE, true /*fSerializeHeaderFooter*/, true /*fIndent*/); CWStringDynamic dstrExpected(pmp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL); if (!dstrExpected.FEquals(&wstrQuery)) { GPOS_TRACE(wstrQuery.Wsz()); } // cleanup GPOS_DELETE(pq2dxlresult); GPOS_DELETE_ARRAY(szDXL); return GPOS_OK; }
//--------------------------------------------------------------------------- // @function: // CParseHandlerTest::EresParseAndSerializeMetadata // // @doc: // Verifies that after parsing the given DXL file containing metadata into // a list of metadata objects, which should be serialized back to the same string. // //--------------------------------------------------------------------------- GPOS_RESULT CParseHandlerTest::EresParseAndSerializeMetadata ( IMemoryPool *pmp, const CHAR *szDXLFileName, BOOL fValidate ) { CWStringDynamic str(pmp); COstreamString oss(&str); // read DXL file CHAR *szDXL = CDXLUtils::SzRead(pmp, szDXLFileName); GPOS_CHECK_ABORT; // parse the metadata objects into a dynamic array const CHAR *szValidationPath = NULL; if (fValidate) { szValidationPath = CTestUtils::m_szXSDPath; } DrgPimdobj *pdrgpmdobj = CDXLUtils::PdrgpmdobjParseDXL(pmp, szDXL, szValidationPath); GPOS_ASSERT(NULL != pdrgpmdobj); GPOS_CHECK_ABORT; oss << "Serializing metadata objects" << std::endl; CWStringDynamic *pstr = CDXLUtils::PstrSerializeMetadata(pmp, pdrgpmdobj, true /*fSerializeHeaderFooter*/, true /*fIndent*/); GPOS_CHECK_ABORT; CWStringDynamic dstrExpected(pmp); dstrExpected.AppendFormat(GPOS_WSZ_LIT("%s"), szDXL); if (!dstrExpected.FEquals(pstr)) { GPOS_TRACE(pstr->Wsz()); GPOS_ASSERT(false); } pdrgpmdobj->Release(); GPOS_DELETE(pstr); GPOS_DELETE_ARRAY(szDXL); return GPOS_OK; }
QString TelescopeClient::getInfoString(const StelCore* core, const InfoStringGroup& flags) const { QString str; QTextStream oss(&str); if (flags&Name) { oss << "<h2>" << nameI18n << "</h2>"; } oss << getPositionInfoString(core, flags); postProcessInfoString(str, flags); return str; }