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


C++ NameValuePair::setValue方法代码示例

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


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

示例1: testAccessors

    void testAccessors()
    {
        const char* name = "xxx";
        const char* name_different_case = "XXX";
        const char* value = "xxx-value";
        const char* valueRef;

        NameValuePair* nv = new NameValuePair(name);
        NameValuePair* nv_different_case = new NameValuePair(name_different_case);

        valueRef = nv->getValue();
        CPPUNIT_ASSERT_MESSAGE("value should be null", NULL == valueRef);

        nv->setValue(value);
        valueRef = nv->getValue();
        ASSERT_STR_EQUAL_MESSAGE("incorrect value retrieved", value, valueRef);

        nv->setValue(name);
        valueRef = nv->getValue();
        ASSERT_STR_EQUAL_MESSAGE("incorrect value retrieved", valueRef, name);

        CPPUNIT_ASSERT_MESSAGE("nv should be == nv", nv->compareTo(nv) == 0);
        CPPUNIT_ASSERT_MESSAGE("nv should be != nv_different_case",
                               nv->compareTo(nv_different_case) != 0);

        delete nv;
        delete nv_different_case;
    }
开发者ID:chemeris,项目名称:sipxecs,代码行数:28,代码来源:NameValuePairTest.cpp

示例2: setUrlParameter

void Url::setUrlParameter(const char* name, const char* value)
{
    NameValuePair* nv = new NameValuePair(name ? name : "",
        value ? value : "");

    // ensure that mpUrlParameters is initialized
    if (! (mpUrlParameters || parseUrlParameters()))
    {
       mpUrlParameters = new UtlDList;
    }
    
    NameValuePair* existingParam = static_cast<NameValuePair*>(mpUrlParameters->find(nv));

    if (existingParam)
    {
       existingParam->setValue(value);
    }
    else
    {
    mpUrlParameters->append(nv);
}

}
开发者ID:John-Chan,项目名称:sipXtapi,代码行数:23,代码来源:Url.cpp

示例3: parseCgiVariables

void HttpRequestContext::parseCgiVariables(const char* queryString,
                                           UtlList& cgiVariableList,
                                           const char* pairSeparator,
                                           const char* nameValueSeparator,
                                           UtlBoolean nameIsCaseInsensitive,
                                           UnEscapeFunction unescape)
{
#if 0
   printf("HttpRequestContext::parseCgiVariables queryString = '%s', pairSeparator = '%s', nameValueSeparator = '%s', nameIsCaseInsensitive = %d\n",
          queryString, pairSeparator, nameValueSeparator,
          nameIsCaseInsensitive);
#endif
   //UtlString nameAndValue;
   const char* nameAndValuePtr;
   int nameAndValueLength;
   //UtlString name;
   const char* namePtr;
   int nameLength;
   int nameValueIndex = 0;
   UtlString value;
   int lastCharIndex = 0;
   int relativeIndex;
   int nameValueRelativeIndex;
   int queryStringLength = strlen(queryString);

   do
   {
      // Pull out a name value pair
      //osPrintf("HttpRequestContext::parseCgiVariables parseCgiVariables: \"%s\" lastCharIndex: %d",
      //    &(queryString[lastCharIndex]), lastCharIndex);
      NameValueTokenizer::getSubField(&(queryString[lastCharIndex]),
                                      queryStringLength - lastCharIndex,
                                      0,
                                      pairSeparator,
                                      nameAndValuePtr,
                                      nameAndValueLength,
                                      &relativeIndex);
      lastCharIndex += relativeIndex;

      if(nameAndValuePtr && nameAndValueLength > 0)
      {
         // Separate the name and value
         NameValueTokenizer::getSubField(nameAndValuePtr,
                                         nameAndValueLength,
                                         0,
                                         nameValueSeparator,
                                         namePtr,
                                         nameLength,
                                         &nameValueRelativeIndex);

         // Get rid of leading white space in the name
         while(nameLength > 0 &&
               (*namePtr == ' ' ||
                *namePtr == '\t'))
         {
            nameLength--;
            namePtr++;
         }

         if(nameLength > 0)
         {
            // Ignore any subsequent name value separators should they exist
            //int nvSeparatorIndex = nameAndValue.index(nameValueSeparator);
            int valueSeparatorOffset = strspn(&(namePtr[nameLength]),
                                              nameValueSeparator);
            const char* valuePtr = &(namePtr[nameLength]) + valueSeparatorOffset;
            int valueLength = nameAndValueLength -
               (valuePtr - nameAndValuePtr);

            // If there is a value
            if(valueSeparatorOffset <= 0 ||
               *valuePtr == '\0' ||
               valueLength <= 0)
            {
               valuePtr = NULL;
               valueLength = 0;
            }

            // Construct the new pair of the right subclass of NameValuePair
            // to have the compareTo method we want.
            NameValuePair* newNvPair =
               nameIsCaseInsensitive ?
               new NameValuePairInsensitive("") :
               new NameValuePair("");

            newNvPair->append(namePtr, nameLength);
            if(valuePtr)
            {
               value.remove(0);
               value.append(valuePtr, valueLength);
               NameValueTokenizer::frontBackTrim(&value, " \t\n\r");
               unescape(value);
               newNvPair->setValue(value);
            }
            else
            {
               newNvPair->setValue("");
            }

            // Unescape the name.
//.........这里部分代码省略.........
开发者ID:Konnekt,项目名称:lib-sipx,代码行数:101,代码来源:HttpRequestContext.cpp


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