当前位置: 首页>>代码示例>>C++>>正文


C++ NameValueCollection类代码示例

本文整理汇总了C++中NameValueCollection的典型用法代码示例。如果您正苦于以下问题:C++ NameValueCollection类的具体用法?C++ NameValueCollection怎么用?C++ NameValueCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了NameValueCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: name_value_collection___index

int name_value_collection___index(lua_State *L) {
  NameValueCollection *collection = GetCollection(L, 1);
  const char *name = luaL_checkstring(L, 2);
  if (strcmp(name, "Count") == 0) {
    lua_pushunsigned(L, collection->GetCount());
  } else if (strcmp(name, "AllKeys") == 0) {
    StringVectorToLuaArray(L, collection->AllKeys());
  } else if (strcmp(name, "Add") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Add, 1);
  } else if (strcmp(name, "Get") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Get, 1);
  } else if (strcmp(name, "GetKey") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_GetKey, 1);
  } else if (strcmp(name, "GetValues") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_GetValues, 1);
  } else if (strcmp(name, "Clear") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Clear, 1);
  } else if (strcmp(name, "Set") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Set, 1);
  } else if (strcmp(name, "Remove") == 0) {
    lua_pushlightuserdata(L, (void *)collection);
    lua_pushcclosure(L, name_value_collection_Remove, 1);
  } else {
    lua_pushstring(L, "Unknown property or method.");
    lua_error(L);
  }

  return 1;
}
开发者ID:apkbox,项目名称:asplite,代码行数:35,代码来源:name_value_collection_lua.cpp

示例2: validateProperties

/// private methods implementation
void BatchFilter::validateProperties( NameValueCollection& transportHeaders )
{
	if ( !m_Properties.ContainsKey( BatchFilter::BatchFILE ) )
		throw invalid_argument( "Required parameter missing : BatchFILE" );
		
	//Set Parameters for BatchFile
	int xlstParamsCount = transportHeaders.getCount();
		
  	if ( xlstParamsCount > 0 )
  	{
  		DEBUG( "The Batch has "  << xlstParamsCount << " parameters." );
  		vector< DictionaryEntry > params = transportHeaders.getData();
		for( int i = 0; i < xlstParamsCount; i++ )
		{
			if ( StringUtil::StartsWith( params[i].first, BatchFilter::BatchPARAM ) )
			{
				DEBUG( "Filter param [" << params[i].first << "] value is [" << params[i].second << "]" );
				getTransformer()->setStylesheetParam( params[i].first.data(), params[i].second.data() );		   		
			}
			else if ( ( params[i].first == BatchFilter::BatchUSEEXT ) && !m_ExtensionsInstalled )
			{
				DEBUG( "Using extension functions from http://extensions.bisnet.ro" );
				const XalanDOMString theNamespace( "http://extensions.bisnet.ro" );
				getTransformer()->installExternalFunction( theNamespace, XalanDOMString( "replace" ), FunctionReplace() );
				getTransformer()->installExternalFunction( theNamespace, XalanDOMString( "fill" ), FunctionFill() );
				m_ExtensionsInstalled = true;
			}
		}	
  	}
  	else
  		DEBUG( "The Batch doesn't have parameters" );
}
开发者ID:FinTP,项目名称:fintp_base,代码行数:33,代码来源:BatchFilter.cpp

示例3: fetchAccountPage

	void fetchAccountPage(HTTPSClientSession& clientSession, NameValueCollection& cookies)
	{
		HTTPRequest request(HTTPRequest::HTTP_GET, "/royalgreenwich/account", HTTPMessage::HTTP_1_1);
		request.setCookies(cookies);
		HTTPResponse response;

		std::ostream& ostr = clientSession.sendRequest(request);
		std::istream& rs = clientSession.receiveResponse(response);

		int statusCode = response.getStatus();

		poco_information_f1(logger(), "Status %d", statusCode);

		std::vector<HTTPCookie> newCookies;
		response.getCookies(newCookies);
		for (HTTPCookie cookie : newCookies)
		{
			poco_information_f1(logger(), "Cookie %s", cookie.toString());
			if (cookies.has(cookie.getName()))
			{
				cookies.set(cookie.getName(), cookie.getValue());
			}
			else
			{
				cookies.add(cookie.getName(), cookie.getValue());
			}
		}
		StreamCopier::copyStream(rs, std::cout);
	}
开发者ID:gazzyt,项目名称:HTMLRegex,代码行数:29,代码来源:HTMLRegex.cpp

示例4: replyOutputFormat

void BatchFilter::replyOutputFormat( NameValueCollection& transportHeaders, int format )
{
	XALAN_USING_XALAN( FormatterListener );
	string formatAsString = "";
	
	switch( format )
	{
		case FormatterListener::OUTPUT_METHOD_TEXT :
			formatAsString = BatchFilter::OUTPUT_METHOD_TEXT;
			break;
			
		case FormatterListener::OUTPUT_METHOD_XML :
		case FormatterListener::OUTPUT_METHOD_DOM :
			formatAsString = BatchFilter::OUTPUT_METHOD_XML;
			break;
			
		default :
			formatAsString = BatchFilter::OUTPUT_METHOD_NONE;
			break;
	}
	
	if ( transportHeaders.ContainsKey( BatchOUTPUTFORMAT ) )
		transportHeaders[ BatchOUTPUTFORMAT ] = formatAsString;
	else
		transportHeaders.Add( BatchOUTPUTFORMAT, formatAsString );
}
开发者ID:FinTP,项目名称:fintp_base,代码行数:26,代码来源:BatchFilter.cpp

示例5: addFormFields

//------------------------------------------------------------------------------
void ofxHTTPBaseRequest::addFormFields(const NameValueCollection& formFields) {
    NameValueCollection::ConstIterator iter = formFields.begin();
    while(iter != formFields.end()) {
        addFormField((*iter).first,(*iter).second);
        ++iter;
    }
}
开发者ID:yyolk,项目名称:ofxHTTP,代码行数:8,代码来源:ofxHTTPBaseRequest.cpp

示例6: addHeaders

//------------------------------------------------------------------------------
void ofxHTTPBaseRequest::addHeaders(const NameValueCollection& _headers) {
    NameValueCollection::ConstIterator iter = _headers.begin();
    while(iter != _headers.end()) {
        addHeader((*iter).first,(*iter).second);
        ++iter;
    }
}
开发者ID:yyolk,项目名称:ofxHTTP,代码行数:8,代码来源:ofxHTTPBaseRequest.cpp

示例7: fetchLoginPage

	void fetchLoginPage(HTTPSClientSession& clientSession, NameValueCollection& cookies)
	{
		HTTPRequest request(HTTPRequest::HTTP_GET, "/royalgreenwich/login?message=borrowerservices_notloggedin&referer=https%3A%2F%2Fcapitadiscovery.co.uk%2Froyalgreenwich%2Faccount", HTTPMessage::HTTP_1_1);
		request.setCookies(cookies);
		HTTPResponse response;

		std::ostream& ostr = clientSession.sendRequest(request);
		std::istream& rs = clientSession.receiveResponse(response);

		int statusCode = response.getStatus();

		poco_information_f1(logger(), "Status %d", statusCode);

		std::vector<HTTPCookie> newCookies;
		response.getCookies(newCookies);
		for (HTTPCookie cookie : newCookies)
		{
			poco_information_f1(logger(), "Cookie %s", cookie.toString());
			if (cookies.has(cookie.getName()))
			{
				cookies.set(cookie.getName(), cookie.getValue());
			}
			else
			{
				cookies.add(cookie.getName(), cookie.getValue());
			}
		}
	}
开发者ID:gazzyt,项目名称:HTMLRegex,代码行数:28,代码来源:HTMLRegex.cpp

示例8: submitLoginPage

	void submitLoginPage(HTTPSClientSession& clientSession, NameValueCollection& cookies)
	{
		HTTPRequest request(HTTPRequest::HTTP_POST, "/royalgreenwich/sessions", HTTPMessage::HTTP_1_1);
		request.setCookies(cookies);
		HTTPResponse response;
		HTMLForm loginForm;
		loginForm.add("barcode", "28028005913354");
		loginForm.add("pin", "3347");
		loginForm.prepareSubmit(request);

		std::ostream& ostr = clientSession.sendRequest(request);
		loginForm.write(ostr);
		std::istream& rs = clientSession.receiveResponse(response);

		int statusCode = response.getStatus();

		poco_information_f1(logger(), "Status %d", statusCode);

		std::vector<HTTPCookie> newCookies;
		response.getCookies(newCookies);
		for (HTTPCookie cookie : newCookies)
		{
			poco_information_f1(logger(), "Cookie %s", cookie.toString());
			if (cookies.has(cookie.getName()))
			{
				cookies.set(cookie.getName(), cookie.getValue());
			}
			else
			{
				cookies.add(cookie.getName(), cookie.getValue());
			}
		}
	}
开发者ID:gazzyt,项目名称:HTMLRegex,代码行数:33,代码来源:HTMLRegex.cpp

示例9: name_value_collection_GetKey

int name_value_collection_GetKey(lua_State *L) {
  NameValueCollection *collection = GetCollection(L, lua_upvalueindex(1));
  lua_Unsigned index = luaL_checkunsigned(L, 1);
  std::string key;
  if (collection->GetKey(index, &key))
    lua_pushlstring(L, key.data(), key.length());
  else
    lua_pushnil(L);
  return 1;
}
开发者ID:apkbox,项目名称:asplite,代码行数:10,代码来源:name_value_collection_lua.cpp

示例10: name_value_collection_Add

int name_value_collection_Add(lua_State *L) {
  NameValueCollection *collection = GetCollection(L, lua_upvalueindex(1));

  // TODO: permit nil
  const char *name = luaL_checkstring(L, 1);
  const char *value = luaL_checkstring(L, 2);

  lua_pushboolean(L, collection->Add(name, value));
  return 1;
}
开发者ID:apkbox,项目名称:asplite,代码行数:10,代码来源:name_value_collection_lua.cpp

示例11: name

std::string WebSessionManager::getId(const std::string& appName, const Poco::Net::HTTPServerRequest& request)
{
	std::string id;
	std::string name(cookieName(appName));
	NameValueCollection cookies;
	request.getCookies(cookies);
	NameValueCollection::ConstIterator it = cookies.find(name);
	if (it != cookies.end())
		id = it->second;
	
	return id;
}
开发者ID:JoneXie,项目名称:macchina.io,代码行数:12,代码来源:WebSessionManager.cpp

示例12: setCookies

void HTTPRequest::setCookies(const NameValueCollection& cookies) {
    std::string cookie;
    cookie.reserve(64);
    for (NameValueCollection::ConstIterator it = cookies.begin(); it != cookies.end(); ++it) {
        if (it != cookies.begin())
            cookie.append("; ");
        cookie.append(it->first);
        cookie.append("=");
        cookie.append(it->second);
    }
    add(COOKIE, cookie);
}
开发者ID:liyustar,项目名称:liblyx,代码行数:12,代码来源:lyxHTTPRequest.cpp

示例13: _version

HTTPCookie::HTTPCookie(const NameValueCollection& nvc):
	_version(0),
	_secure(false),
	_maxAge(-1),
	_httpOnly(false)
{
	for (NameValueCollection::ConstIterator it = nvc.begin(); it != nvc.end(); ++it)
	{
		const std::string& name  = it->first;
		const std::string& value = it->second;
		if (icompare(name, "comment") == 0)
		{
			setComment(value);
		}
		else if (icompare(name, "domain") == 0)
		{
			setDomain(value);
		}
		else if (icompare(name, "path") == 0)
		{
			setPath(value);
		}
		else if (icompare(name, "max-age") == 0)
		{
			setMaxAge(NumberParser::parse(value));
		}
		else if (icompare(name, "secure") == 0)
		{
			setSecure(true);
		}
		else if (icompare(name, "expires") == 0)
		{
			int tzd;
			DateTime exp = DateTimeParser::parse(value, tzd);
			Timestamp now;
			setMaxAge((int) ((exp.timestamp() - now) / Timestamp::resolution()));
		}
		else if (icompare(name, "version") == 0)
		{
			setVersion(NumberParser::parse(value));
		}
		else if (icompare(name, "HttpOnly") == 0)
		{
			setHttpOnly(true);
		}
		else
		{
			setName(name);
			setValue(value);
		}
	}
}
开发者ID:Chingliu,项目名称:poco,代码行数:52,代码来源:HTTPCookie.cpp

示例14: isValidRequest

//------------------------------------------------------------------------------
bool ofxWebServerBaseRouteHandler::isValidRequest(const Settings& settings,
                                                  HTTPServerRequest& request,
                                                  HTTPServerResponse& response) {
    
    string sessionId = "";
    
    // extract cookie from request
    NameValueCollection cookies;
    request.getCookies(cookies);
    NameValueCollection::ConstIterator it = cookies.find(settings.sessionCookieName);
    if (it != cookies.end()) {
        sessionId = it->second;
    } else {
        sessionId = ofxWebServerSessionManager::generateSessionKey(request);
        HTTPCookie cookie(settings.sessionCookieName,sessionId);
        cookie.setPath("/");
        // set no age, so it expires @ end of session
        response.addCookie(cookie);
    }
    
    // TODO: update session manager
    
    URI uri(request.getURI());
    
    const string path = uri.getPath(); // just get the path

    if(settings.requireAuthentication) {
        if(request.hasCredentials()) {
            HTTPBasicCredentials credentials(request);
            const string& user = credentials.getUsername();
            const string& pwd = credentials.getPassword();
            
            if(settings.username == credentials.getUsername() &&
               settings.password == credentials.getPassword()) {
                // add an authentication cookie?
                return true;
            } else {
                response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
                sendErrorResponse(response);
                return false;
            }
        } else {
            response.requireAuthentication(settings.realm);
            response.setContentLength(0);
            response.send();
            return false;
        }
    } else {
        return true;
    }
}
开发者ID:bakercp,项目名称:ofxWebServer,代码行数:52,代码来源:ofxWebServerBaseRouteHandler.cpp

示例15: TEST

TEST(MessageHeader, testSplitParameters)
{
	std::string s;
	std::string v;
	NameValueCollection p;
	
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v.empty());
	EXPECT_TRUE (p.empty());
	
	s = "multipart/related";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "multipart/related");
	EXPECT_TRUE (p.empty());
	
	s = "multipart/related; boundary=MIME_boundary_01234567";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "multipart/related");
	EXPECT_TRUE (p.size() == 1);
	EXPECT_TRUE (p["boundary"] == "MIME_boundary_01234567");
	
	s = "multipart/related; boundary=\"MIME_boundary_76543210\"";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "multipart/related");
	EXPECT_TRUE (p.size() == 1);
	EXPECT_TRUE (p["boundary"] == "MIME_boundary_76543210");
	
	s = "text/plain; charset=us-ascii";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "text/plain");
	EXPECT_TRUE (p.size() == 1);
	EXPECT_TRUE (p["charset"] == "us-ascii");
	
	s = "value; p1=foo; p2=bar";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "value");
	EXPECT_TRUE (p.size() == 2);
	EXPECT_TRUE (p["p1"] == "foo");
	EXPECT_TRUE (p["p2"] == "bar");
	
	s = "value; p1=\"foo; bar\"";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "value");
	EXPECT_TRUE (p.size() == 1);
	EXPECT_TRUE (p["p1"] == "foo; bar");	

	s = "value ; p1=foo ; p2=bar ";
	MessageHeader::splitParameters(s, v, p);
	EXPECT_TRUE (v == "value");
	EXPECT_TRUE (p.size() == 2);
	EXPECT_TRUE (p["p1"] == "foo");
	EXPECT_TRUE (p["p2"] == "bar");
}
开发者ID:ichenq,项目名称:PocoNet,代码行数:53,代码来源:MessageHeaderTest.cpp


注:本文中的NameValueCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。