这篇教程C++ EncodeString函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EncodeString函数的典型用法代码示例。如果您正苦于以下问题:C++ EncodeString函数的具体用法?C++ EncodeString怎么用?C++ EncodeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EncodeString函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: EncodeDictistring EncodeDicti( const CAtomDicti &x ){ map<string, CAtom *> mapDicti = x.getValue( ); string strDest; strDest += "d"; for( map<string, CAtom *> :: iterator i = mapDicti.begin( ); i != mapDicti.end( ); i++ ) { strDest += EncodeString( CAtomString( (*i).first ) ); if( dynamic_cast<CAtomInt *>( (*i).second ) ) strDest += EncodeInt( *dynamic_cast<CAtomInt *>( (*i).second ) ); else if( dynamic_cast<CAtomLong *>( (*i).second ) ) strDest += EncodeLong( *dynamic_cast<CAtomLong *>( (*i).second ) ); else if( dynamic_cast<CAtomString *>( (*i).second ) ) strDest += EncodeString( *dynamic_cast<CAtomString *>( (*i).second ) ); else if( dynamic_cast<CAtomList *>( (*i).second ) ) strDest += EncodeList( *dynamic_cast<CAtomList *>( (*i).second ) ); else if( dynamic_cast<CAtomDicti *>( (*i).second ) ) strDest += EncodeDicti( *dynamic_cast<CAtomDicti *>( (*i).second ) ); } strDest += "e"; return strDest;}
开发者ID:comeby,项目名称:first_test,代码行数:28,
示例2: EncodeStringvoid TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const{ TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if (value.find ('/"') == TIXML_STRING::npos) { if ( cfile ) { fprintf (cfile, "%s=/"%s/"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=/""; (*str) += v; (*str) += "/""; } } else {#if 0 // disabled for the UIDesigner //if ( cfile ) { //fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); //} //if ( str ) { // (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; //}#else if ( cfile ) { fprintf (cfile, "%s=/"%s/"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=/""; (*str) += v; (*str) += "/""; }#endif }}
开发者ID:achellies,项目名称:DUI_LIb,代码行数:34,
示例3: EncodeString /** Write a new name/value pair. /param[in] name Name of value. /param[in] value Value. */ void SCXFilePersistDataWriter::WriteValue(const std::wstring& name, const std::wstring& value) { std::wostringstream os; os << m_Indentation << L"<Value Name=/"" << EncodeString(name) << L"/" Value=/"" << EncodeString(value) << L"/"/>" << std::endl; SCXStream::WriteAsUTF8(*m_Stream, os.str()); }
开发者ID:Microsoft,项目名称:pal,代码行数:13,
示例4: EncodeStringvoid TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const{ TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if ( value.find ( '/"' ) == TIXML_STRING::npos ) { if ( cfile ) { fprintf ( cfile, "%s=/"%s/"", n.c_str(), v.c_str() ); } if ( str ) { ( *str ) += n; ( *str ) += "=/""; ( *str ) += v; ( *str ) += "/""; } } else { if ( cfile ) { fprintf ( cfile, "%s='%s'", n.c_str(), v.c_str() ); } if ( str ) { ( *str ) += n; ( *str ) += "='"; ( *str ) += v; ( *str ) += "'"; } }}
开发者ID:Greyh0und,项目名称:TestProjects,代码行数:29,
示例5: EncodeStringvoid TiXmlAttribute::Print( FileOps *f, int /*depth*/, TIXML_STRING* str ) const{ TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if (value.find ('/"') == TIXML_STRING::npos) { const char *startVal = "=/""; const char *endVal = "/""; if (f) { f->write(n.c_str(), n.size(), 1); f->write(startVal, 2, 1); f->write(v.c_str(), v.size(), 1); f->write(endVal, 1, 1); } if ( str ) { (*str) += n; (*str) += "=/""; (*str) += v; (*str) += "/""; } } else { const char *startVal = "='"; const char *endVal = "'"; if (f) { f->write(n.c_str(), n.size(), 1); f->write(startVal, 2, 1); f->write(v.c_str(), v.size(), 1); f->write(endVal, 1, 1); } if ( str ) { (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; } }}
开发者ID:MoLAoS,项目名称:Mandate,代码行数:34,
示例6: switch/* EncodeElement is called by cat(), write.table() and deparsing. */const char *EncodeElement(SEXP x, int indx, int quote, char dec){ int w, d, e, wi, di, ei; const char *res; switch(TYPEOF(x)) { case LGLSXP: formatLogical(&LOGICAL(x)[indx], 1, &w); res = EncodeLogical(LOGICAL(x)[indx], w); break; case INTSXP: formatInteger(&INTEGER(x)[indx], 1, &w); res = EncodeInteger(INTEGER(x)[indx], w); break; case REALSXP: formatReal(&REAL(x)[indx], 1, &w, &d, &e, 0); res = EncodeReal(REAL(x)[indx], w, d, e, dec); break; case STRSXP: formatString(&STRING_PTR(x)[indx], 1, &w, quote); res = EncodeString(STRING_ELT(x, indx), w, quote, Rprt_adj_left); break; case CPLXSXP: formatComplex(&COMPLEX(x)[indx], 1, &w, &d, &e, &wi, &di, &ei, 0); res = EncodeComplex(COMPLEX(x)[indx], w, d, e, wi, di, ei, dec); break; case RAWSXP: res = EncodeRaw(RAW(x)[indx]); break; default: res = NULL; /* -Wall */ UNIMPLEMENTED_TYPE("EncodeElement", x); } return res;}
开发者ID:SensePlatform,项目名称:R,代码行数:36,
示例7: assertvoid TiXmlText::Print( FileOps *f, int depth ) const{ const char *newLine = "/n"; const char *tabSpacer = " "; const char *start = "<![CDATA["; const char *end = "]]>/n"; assert( f ); if ( cdata ) { int i; f->write(newLine, strlen(newLine), 1); for ( i=0; i<depth; i++ ) { f->write(tabSpacer, 3, 1); } f->write(start, strlen(start), 1); f->write(value.c_str(), value.size(), 1); f->write(end, strlen(end), 1); } else { TIXML_STRING buffer; EncodeString( value, &buffer ); f->write(buffer.c_str(), buffer.size(), 1); }}
开发者ID:MoLAoS,项目名称:Mandate,代码行数:25,
示例8: EncodeListstring EncodeList( const CAtomList &x ){ vector<CAtom *> v = x.getValue( ); string strDest; strDest += "l"; for( vector<CAtom *> :: iterator i = v.begin( ); i != v.end( ); i++ ) { if( dynamic_cast<CAtomInt *>( *i ) ) strDest += EncodeInt( *dynamic_cast<CAtomInt *>( *i ) ); else if( dynamic_cast<CAtomLong *>( *i ) ) strDest += EncodeLong( *dynamic_cast<CAtomLong *>( *i ) ); else if( dynamic_cast<CAtomString *>( *i ) ) strDest += EncodeString( *dynamic_cast<CAtomString *>( *i ) ); else if( dynamic_cast<CAtomList *>( *i ) ) strDest += EncodeList( *dynamic_cast<CAtomList *>( *i ) ); else if( dynamic_cast<CAtomDicti *>( *i ) ) strDest += EncodeDicti( *dynamic_cast<CAtomDicti *>( *i ) ); } strDest += "e"; return strDest;}
开发者ID:comeby,项目名称:first_test,代码行数:26,
示例9: EncodeStringvoid TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const{ TIXML_STRING n, v; EncodeString( name, &n ); EncodeString( value, &v ); if ( cfile ) { fprintf (cfile, "%s=/"%s/"", n.c_str(), v.c_str() ); } if ( str ) { (*str) += n; (*str) += "=/""; (*str) += v; (*str) += "/""; }}
开发者ID:fftyjw,项目名称:DirectUI,代码行数:17,
示例10: cat_newlinestatic void cat_newline(SEXP labels, int *width, int lablen, int ntot){ Rprintf("/n"); *width = 0; if (labels != R_NilValue) { Rprintf("%s ", EncodeString(STRING_ELT(labels, ntot % lablen), 1, 0, Rprt_adj_left)); *width += Rstrlen(STRING_ELT(labels, ntot % lablen), 0) + 1; }}
开发者ID:o-,项目名称:Rexperiments,代码行数:10,
示例11: _ASSERTvoid IOPropertyMappingCollection::Write(MdfStream& fd, PropertyMappingCollection* propMappings, Version* version, const std::string& name, MgTab& tab){ _ASSERT(NULL != propMappings); fd << tab.tab() << startStr(name) << std::endl; tab.inctab(); for (int i = 0; i < propMappings->GetCount(); ++i) { fd << tab.tab() << startStr(sPropertyMapping) << std::endl; tab.inctab(); PropertyMapping* propMapping = dynamic_cast<PropertyMapping*>(propMappings->GetAt(i)); _ASSERT(NULL != propMapping); // Property: TargetProperty fd << tab.tab() << startStr(sTargetProperty); fd << EncodeString(propMapping->GetTargetProperty()); fd << endStr(sTargetProperty) << std::endl; // Property: SourceProperty fd << tab.tab() << startStr(sSourceProperty); fd << EncodeString(propMapping->GetSourceProperty()); fd << endStr(sSourceProperty) << std::endl; // Property: SourceUnits fd << tab.tab() << startStr(sSourceUnits); fd << EncodeString(propMapping->GetSourceUnits()); fd << endStr(sSourceUnits) << std::endl; // Write any unknown XML / extended data IOUnknown::Write(fd, propMapping->GetUnknownXml(), version, tab); tab.dectab(); fd << tab.tab() << endStr(sPropertyMapping) << std::endl; } tab.dectab(); fd << tab.tab() << endStr(name) << std::endl;}
开发者ID:asir6,项目名称:Colt,代码行数:40,
示例12: str1std::string Game::GetEncodeString(const char* str){ const Settings & conf = Settings::Get(); std::string str1(str); std::string str2(_(str)); // encode name if(str1 == str2 && str1.size() && conf.Unicode() && conf.MapsCharset().size()) str2 = EncodeString(str1, conf.MapsCharset().c_str()); return str2;}
开发者ID:asimonov-im,项目名称:fheroes2,代码行数:13,
示例13: assertvoid TiXmlText::Print(FILE* cfile, int depth) const { assert(cfile); if (cdata) { int i; fprintf(cfile, "/n"); for (i = 0; i < depth; i++) { fprintf(cfile, " "); } fprintf(cfile, "<![CDATA[%s]]>/n", value.c_str()); // unformatted output } else { TIXML_STRING buffer; EncodeString(value, &buffer); fprintf(cfile, "%s", buffer.c_str()); }}
开发者ID:9aa5,项目名称:crtmpserver,代码行数:15,
示例14: ToStringOption std::string ToStringOption() { std::string ret; for( std::vector<TreeItem>::const_iterator i = TreeItems.begin() ; i != TreeItems.end(); i++ ) { const TreeItem& item = *i; if( item.Value != item.Defalut ) { std::string name; TVPUtf16ToUtf8( name, item.Parameter ); ret += name; ret += "="; ret += EncodeString( item.Select[item.Value].first ); ret += "/r/n"; } } return ret; }
开发者ID:LonghronShen,项目名称:krkrz,代码行数:15,
示例15: Encodestring Encode( CAtom *pAtom ){ if( dynamic_cast<CAtomInt *>( pAtom ) ) return EncodeInt( *dynamic_cast<CAtomInt *>( pAtom ) ); else if( dynamic_cast<CAtomLong *>( pAtom ) ) return EncodeLong( *dynamic_cast<CAtomLong *>( pAtom ) ); else if( dynamic_cast<CAtomString *>( pAtom ) ) return EncodeString( *dynamic_cast<CAtomString *>( pAtom ) ); else if( dynamic_cast<CAtomList *>( pAtom ) ) return EncodeList( *dynamic_cast<CAtomList *>( pAtom ) ); else if( dynamic_cast<CAtomDicti *>( pAtom ) ) return EncodeDicti( *dynamic_cast<CAtomDicti *>( pAtom ) ); return string( );}
开发者ID:comeby,项目名称:first_test,代码行数:15,
示例16: BeginDictionaryBOOL BEEncoder::EncodeDict(LPDICTIONARY d){ BeginDictionary(); // begin dictionary DictIterator it = d->GetIterator(); while (it.HasNext()) { Dictionary::ObjectEntry entry = it.GetNext(); EncodeString(entry.first); EncodeObject(entry.second); } EndObject(); return TRUE;}
开发者ID:trieck,项目名称:source,代码行数:15,
示例17: LeftMatrixColumnLabelstatic void LeftMatrixColumnLabel(SEXP cl, int j, int w){ int l; SEXP tmp; if (!isNull(cl)) { tmp= STRING_ELT(cl, j); if(tmp == NA_STRING) l = R_print.na_width_noquote; else l = Rstrlen(tmp, 0); Rprintf("%*s%s%*s", R_print.gap, "", EncodeString(tmp, l, 0, Rprt_adj_left), w-l, ""); } else { Rprintf("%*s[,%ld]%*s", R_print.gap, "", j+1, w-IndexWidth(j+1)-3, ""); }}
开发者ID:Patsylou,项目名称:Web-Classification,代码行数:16,
示例18: mainvoid main( void ){ uchar str[80]; while ( 1 ) { printf("Enter string:"); gets(str); printf("/n"); EncodeString( str ); printf("Encoded:%s/n", str ); DecodeString( str ); printf("Decoded:%s/n/n", str ); }}
开发者ID:Maximus5,项目名称:evil-programmers,代码行数:17,
示例19: MatrixRowLabelstatic void MatrixRowLabel(SEXP rl, int i, int rlabw, int lbloff){ int l; SEXP tmp; if (!isNull(rl)) { tmp= STRING_ELT(rl, i); if(tmp == NA_STRING) l = R_print.na_width_noquote; else l = Rstrlen(tmp, 0); Rprintf("/n%*s%s%*s", lbloff, "", EncodeString(tmp, l, 0, Rprt_adj_left), rlabw-l-lbloff, ""); } else { Rprintf("/n%*s[%ld,]", rlabw-3-IndexWidth(i + 1), "", i+1); }}
开发者ID:Patsylou,项目名称:Web-Classification,代码行数:17,
示例20: printStringVectorstatic void printStringVector(SEXP *x, R_xlen_t n, int quote, int indx){ int w, labwidth=0, width; DO_first_lab; formatString(x, n, &w, quote); for (R_xlen_t i = 0; i < n; i++) { if (i > 0 && width + w + R_print.gap > R_print.width) { DO_newline; } Rprintf("%*s%s", R_print.gap, "", EncodeString(x[i], w, quote, R_print.right)); width += w + R_print.gap; } Rprintf("/n");}
开发者ID:nirvananoob,项目名称:r-source,代码行数:17,
示例21: wxASSERTlong SjCPlugin::CallMaster(UINT msg, LPARAM param1, LPARAM param2, LPARAM param3){ wxASSERT( msg >= 20000 && msg <= 29999 ); if( g_mainFrame == NULL || g_tools == NULL ) return 0; // thread-safe mesages switch( msg ) { case SJ_GET_VERSION: return SjTools::VersionString2Long(SJ_VERSION_ASCII); } if( ! wxThread::IsMain() ) return 0; // no thread-save message switch( msg ) { case SJ_EXECUTE: #if SJ_USE_SCRIPTS if( m_see == NULL ) { m_see = new SjSee(); m_see->m_plugin = this; m_see->SetExecutionScope(m_file); } m_see->Execute(DecodeString(param1)); // seems to work recursively ;-) // ExecuteAsFunction() is no good idea - this avoids to define _any_ globals! if( param2 ) return EncodeString(m_see->GetResultString()); else return m_see->GetResultLong(); #else return 0; #endif } // not supported return 0;}
开发者ID:antonivich,项目名称:Silverjuke,代码行数:43,
示例22: printStringMatrixstatic void printStringMatrix(SEXP sx, int offset, int r_pr, int r, int c, int quote, int right, SEXP rl, SEXP cl, const char *rn, const char *cn){ _PRINT_INIT_rl_rn; SEXP *x = STRING_PTR(sx)+offset; for (j = 0; j < c; j++) { formatString(&x[j * r], (R_xlen_t) r, &w[j], quote); _PRINT_SET_clabw; if (w[j] < clabw) w[j] = clabw; } _PRINT_DEAL_c_eq_0; while (jmin < c) { width = rlabw; do { width += w[jmax] + R_print.gap; jmax++; } while (jmax < c && width + w[jmax] + R_print.gap < R_print.width); _PRINT_ROW_LAB; if (right) { for (j = jmin; j < jmax ; j++) RightMatrixColumnLabel(cl, j, w[j]); } else { for (j = jmin; j < jmax ; j++) LeftMatrixColumnLabel(cl, j, w[j]); } for (i = 0; i < r_pr; i++) { MatrixRowLabel(rl, i, rlabw, lbloff); for (j = jmin; j < jmax; j++) { Rprintf("%*s%s", R_print.gap, "", EncodeString(x[i + j * r], w[j], quote, right)); } } Rprintf("/n"); jmin = jmax; }}
开发者ID:Patsylou,项目名称:Web-Classification,代码行数:43,
示例23: switchBOOL BEEncoder::EncodeObject(LPBEOBJECT pObject){ switch (pObject->GetType()) { case BEObject::BET_DICT: return EncodeDict(static_cast<LPDICTIONARY>(pObject)); break; case BEObject::BET_LIST: return EncodeList(static_cast<LPLIST>(pObject)); break; case BEObject::BET_INTEGER: return EncodeInt(static_cast<LPINTEGER>(pObject)); break; case BEObject::BET_STRING: return EncodeString(static_cast<LPSTRING>(pObject)); break; } return FALSE;}
开发者ID:trieck,项目名称:source,代码行数:19,
示例24: RightMatrixColumnLabelstatic void RightMatrixColumnLabel(SEXP cl, int j, int w){ int l; SEXP tmp; if (!isNull(cl)) { tmp = STRING_ELT(cl, j); if(tmp == NA_STRING) l = R_print.na_width_noquote; else l = Rstrlen(tmp, 0); /* This does not work correctly at least on FC3 Rprintf("%*s", R_print.gap+w, EncodeString(tmp, l, 0, Rprt_adj_right)); */ Rprintf("%*s%s", R_print.gap+w-l, "", EncodeString(tmp, l, 0, Rprt_adj_right)); } else { Rprintf("%*s[,%ld]%*s", R_print.gap, "", j+1, w-IndexWidth(j+1)-3, ""); }}
开发者ID:Patsylou,项目名称:Web-Classification,代码行数:19,
示例25: _ASSERTvoid IOMapViewportDefinition::Write(MdfStream& fd, MapViewportDefinition* mapViewportDef, Version* version, MgTab& tab){ _ASSERT(NULL != mapViewportDef); // Set the expected version MdfString strVersion = L"2.0.0"; fd << tab.tab() << "<PrintLayoutElementDefinition xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xsi:noNamespaceSchemaLocation=/"PrintLayoutDefinition-" << EncodeString(strVersion) << ".xsd/" version=/"" << EncodeString(strVersion) << "/">" << std::endl; // NOXLATE tab.inctab(); fd << tab.tab() << startStr(sMapViewportDefinition) << std::endl; tab.inctab(); IOPrintLayoutElementDefinition::Write(fd, mapViewportDef, version, tab); // Property: MapName fd << tab.tab() << startStr(sMapName); fd << EncodeString(mapViewportDef->GetMapName()); fd << endStr(sMapName) << std::endl; // Property: HiddenLayerNames IOStringObjectCollection::Write(fd, mapViewportDef->GetHiddenLayerNames(), version, sHiddenLayerNames, sName, tab); // Property: Locked fd << tab.tab() << startStr(sLocked); fd << BoolToStr(mapViewportDef->GetIsLocked()); fd << endStr(sLocked) << std::endl; // Property: On fd << tab.tab() << startStr(sOn); fd << BoolToStr(mapViewportDef->GetIsOn()); fd << endStr(sOn) << std::endl; // Property: MapView IOMapView::Write(fd, mapViewportDef->GetMapView(), version, tab); tab.dectab(); fd << tab.tab() << endStr(sMapViewportDefinition) << std::endl; tab.dectab(); fd << tab.tab() << "</PrintLayoutElementDefinition>" << std::endl; // NOXLATE}
开发者ID:asir6,项目名称:Colt,代码行数:42,
示例26: assertvoid TiXmlText::Print( FILE* cfile, int depth ) const{ assert( cfile ); if ( cdata ) { int i; fprintf( cfile, "/n" ); const char* indent = GetDocument() ? GetDocument()->GetIndentChars() : DefaultIndentChars; for ( i=0; i<depth; i++ ) fprintf( cfile, "%s", indent ); fprintf( cfile, "<![CDATA[%s]]>/n", value.c_str() ); // unformatted output } else { String buffer; // sherm: Third argument says OK to keep quotes here EncodeString( value, &buffer, true ); fprintf( cfile, "%s", buffer.c_str() ); }}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:23,
示例27: PR_STATIC_ASSERTnsresultKey::EncodeJSVal(JSContext* aCx, const jsval aVal, PRUint8 aTypeOffset){ PR_STATIC_ASSERT(eMaxType * MaxArrayCollapse < 256); if (JSVAL_IS_STRING(aVal)) { nsDependentJSString str; if (!str.init(aCx, aVal)) { return NS_ERROR_OUT_OF_MEMORY; } EncodeString(str, aTypeOffset); return NS_OK; } if (JSVAL_IS_INT(aVal)) { EncodeNumber((double)JSVAL_TO_INT(aVal), eFloat + aTypeOffset); return NS_OK; } if (JSVAL_IS_DOUBLE(aVal)) { double d = JSVAL_TO_DOUBLE(aVal); if (DOUBLE_IS_NaN(d)) { return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; } EncodeNumber(d, eFloat + aTypeOffset); return NS_OK; } if (!JSVAL_IS_PRIMITIVE(aVal)) { JSObject* obj = JSVAL_TO_OBJECT(aVal); if (JS_IsArrayObject(aCx, obj)) { aTypeOffset += eMaxType; if (aTypeOffset == eMaxType * MaxArrayCollapse) { mBuffer.Append(aTypeOffset); aTypeOffset = 0; } NS_ASSERTION((aTypeOffset % eMaxType) == 0 && aTypeOffset < (eMaxType * MaxArrayCollapse), "Wrong typeoffset"); jsuint length; if (!JS_GetArrayLength(aCx, obj, &length)) { return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } for (jsuint index = 0; index < length; index++) { jsval val; if (!JS_GetElement(aCx, obj, index, &val)) { return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; } nsresult rv = EncodeJSVal(aCx, val, aTypeOffset); NS_ENSURE_SUCCESS(rv, rv); aTypeOffset = 0; } mBuffer.Append(eTerminator + aTypeOffset); return NS_OK; } if (JS_ObjectIsDate(aCx, obj)) { EncodeNumber(js_DateGetMsecSinceEpoch(aCx, obj), eDate + aTypeOffset); return NS_OK; } } return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;}
开发者ID:ThinkerYzu,项目名称:mozilla-central,代码行数:71,
示例28: NetworkExceptionbool CGUL::Network::HTTPRequest::PerformRequest(UInt32 timeout){ response = ""; responseHead = ""; responseBody = ""; if (!sock->IsConnected()) { throw NetworkException(NetworkExceptionCode::FAILED_HTTP_REQUEST, NetworkExceptionReason::SOCKET_INVALID); } sock->Send((const void*)request.GetCString(), request.GetSize()); char buffer[1024]; // Wait for the response. Timer timeoutTimer; timeoutTimer.Start(); while (sock->Peek(buffer, 1) == 0 && (timeoutTimer.GetElapsedMilliseconds() < timeout || timeout == 0)) { if (!sock->IsConnected()) { throw NetworkException(NetworkExceptionCode::FAILED_HTTP_REQUEST, NetworkExceptionReason::SOCKET_INVALID); } } timeoutTimer.Stop(); if (timeoutTimer.GetElapsedMilliseconds() >= timeout && timeout != 0) { throw NetworkException(NetworkExceptionCode::FAILED_HTTP_REQUEST, NetworkExceptionReason::TIMEOUT); } //Get the headers length. int headSize = 0; sock->Peek(buffer, 1024); CGUL::String bufferString = buffer; headSize = bufferString.FindFirstOf("/r/n/r/n")+4; //Get the reponse's head. char* bufferHead = new char[headSize]; sock->Receive(bufferHead, headSize); responseHead += bufferHead; //Parse the Response Header ParseResponseHead(); //Get the reponse's body. int amount = 0; switch (header.transferEncoding) { case HTTPTransferEncoding::CONTENT_LENGTH: { unsigned int count = 0; while (sock->IsConnected()) { unsigned int size = 1024; if (count + size > header.contentLength) { size = header.contentLength - count; } char* buff = new char[size]; amount = sock->Receive((void*)buff, size); count += amount; if (amount > 0) { responseBody += EncodeString(buff, size); } if (count >= header.contentLength) { break; } } break; } case HTTPTransferEncoding::CHUNKED: { char * sizeBuffer = new char[64]; while (sock->IsConnected()) { //Get the size. amount = sock->Peek(sizeBuffer, 64); if (amount <= 0) { break; } String sizeString = ""; for (int i = 0; i < amount; i++) { if (sizeBuffer[i] == '/r') { if (sizeBuffer[i+1] == '/n') { break; }//.........这里部分代码省略.........
开发者ID:Zethes,项目名称:CGUL,代码行数:101,
示例29: EncodeString//attribute_hiddenconst char *EncodeChar(SEXP x){ return EncodeString(x, 0, 0, Rprt_adj_left);}
开发者ID:LeviosaPumpkin,项目名称:picard-1.138,代码行数:5,
注:本文中的EncodeString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EncoderState函数代码示例 C++ EnchantmentSlot函数代码示例 |