本文整理汇总了C++中NameValuePair::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NameValuePair::getValue方法的具体用法?C++ NameValuePair::getValue怎么用?C++ NameValuePair::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameValuePair
的用法示例。
在下文中一共展示了NameValuePair::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: getFieldParameters
UtlBoolean Url::getFieldParameters(int iMaxReturn, UtlString* pNames, UtlString *pValues, int& iActualReturn)
{
if(!(mpFieldParameters || parseFieldParameters()))
{
iActualReturn = 0;
}
// If the pValue is null, return false and set the actual return to the actual
// number of items.
else if (pNames == NULL || pValues == NULL)
{
iActualReturn = mpFieldParameters->entries() ;
return FALSE ;
}
else
{
iActualReturn = sipx_min(iMaxReturn, ((int)(mpFieldParameters->entries()))) ;
for (int i=0; i<iActualReturn; i++)
{
NameValuePair *pair = (NameValuePair*) mpFieldParameters->at(i) ;
pNames[i] = *pair;
pValues[i] = pair->getValue() ;
}
}
return (iActualReturn > 0) ;
}
示例3: iterator
// Copy constructor
SipRequestContext::SipRequestContext(const SipRequestContext& rSipRequestContext)
{
// delete the old values in the UtlDList
if(!mVariableList.isEmpty())
{
mVariableList.destroyAll();
}
//copy mVariableList memebers individually
UtlDListIterator iterator((UtlDList&)rSipRequestContext.mVariableList);
NameValuePair* nameValuePair = NULL;
UtlString value;
UtlString name;
int index = 0;
do
{
nameValuePair = (NameValuePair*)iterator();
if(nameValuePair)
{
name.append(*nameValuePair);
value.append(nameValuePair->getValue());
NameValuePair* newNvPair = new NameValuePair(name, value);
mVariableList.insertAt(index, newNvPair);
index ++;
name.remove(0);
value.remove(0);
}
}
while (nameValuePair != NULL);
}
示例4: getHeaderParameter
UtlBoolean Url::getHeaderParameter(const char* name, UtlString& value, int index)
{
int foundIndex = 0;
UtlBoolean found = FALSE;
value = "";
if(mpHeaderOrQueryParameters || parseHeaderOrQueryParameters())
{
UtlDListIterator headerParamIterator(*mpHeaderOrQueryParameters);
NameValuePair* headerParam = NULL;
UtlString paramName;
while ((headerParam = (NameValuePair*) headerParamIterator()))
{
paramName = *headerParam;
if(paramName.compareTo(name, UtlString::ignoreCase) == 0)
{
if(index == foundIndex)
{
found = TRUE;
value = headerParam->getValue();
break;
}
foundIndex++;
}
}
}
return(found);
}
示例5: iterator
// Construct a MimeBodyPart from an HttpBody and a list of parameters.
MimeBodyPart::MimeBodyPart(const HttpBody& httpBody,
//< Provides the bytes of the body.
const UtlDList& parameters
//< Provides the parameters.
) :
HttpBody(httpBody),
mpParentBody(NULL),
mParentBodyRawStartIndex(-1),
mRawBodyLength(-1),
mParentBodyStartIndex(-1),
mBodyLength(-1)
{
// Copy the parameters to mNameValues.
UtlDListIterator iterator(parameters);
NameValuePair* nvp;
while((nvp = (NameValuePair*) iterator()))
{
mNameValues.append(new NameValuePair(nvp->data(), nvp->getValue()));
}
// Add the Content-Type parameter, taken from the HttpBody.
mNameValues.append(new NameValuePair(HTTP_CONTENT_TYPE_FIELD,
httpBody.getContentType()));
// Add the Content-Transfer-Encoding parameter.
mNameValues.append(new NameValuePair(HTTP_CONTENT_TRANSFER_ENCODING_FIELD,
HTTP_CONTENT_TRANSFER_ENCODING_BINARY));
// Members that reference the parent will be corrected later.
}
示例6: getFieldParameter
UtlBoolean Url::getFieldParameter(const char* name, UtlString& value, int index) const
{
int foundIndex = 0;
UtlBoolean found = FALSE;
value = "";
if(mpFieldParameters || const_cast<Url*>(this)->parseFieldParameters())
{
UtlDListIterator fieldParamIterator(*mpFieldParameters);
NameValuePair* fieldParam = NULL;
UtlString paramName;
while ((fieldParam = (NameValuePair*) fieldParamIterator()))
{
paramName = *fieldParam;
if(paramName.compareTo(name, UtlString::ignoreCase) == 0)
{
if(index == foundIndex)
{
found = TRUE;
value = fieldParam->getValue();
break;
}
foundIndex++;
}
}
}
return(found);
}
示例7: iterator
// Copy constructor
HttpRequestContext::HttpRequestContext(const HttpRequestContext& rHttpRequestContext)
{
//copy mEnvironmentVars[HTTP_ENV_LAST]
int count = 0;
for (count = HttpRequestContext::HTTP_ENV_RAW_URL;
count < HttpRequestContext::HTTP_ENV_LAST ;
count ++)
{
if(!rHttpRequestContext.mEnvironmentVars[count].isNull())
{
mEnvironmentVars[count].remove(0);
mEnvironmentVars[count].append(rHttpRequestContext.mEnvironmentVars[count]);
}
}
// delete the old values in the UtlSList
if(!mCgiVariableList.isEmpty())
{
mCgiVariableList.destroyAll();
}
//copy mCgiVariableList memebers individually
mUsingInsensitive = rHttpRequestContext.mUsingInsensitive;
UtlSListIterator iterator((UtlSList&)rHttpRequestContext.mCgiVariableList);
NameValuePair* nameValuePair = NULL;
UtlString value;
UtlString name;
int index = 0;
do
{
nameValuePair = (NameValuePair*)iterator();
if(nameValuePair)
{
name = *nameValuePair;
value = nameValuePair->getValue();
NameValuePair* newNvPair = ( mUsingInsensitive
? new NameValuePair(name, value)
: new NameValuePairInsensitive(name, value)
);
mCgiVariableList.insertAt(index, newNvPair);
index ++;
}
}
while (nameValuePair != NULL);
mConnectionEncrypted = rHttpRequestContext.mConnectionEncrypted;
mPeerCertTrusted = rHttpRequestContext.mPeerCertTrusted;
if ( mPeerCertTrusted )
{
UtlSListIterator rPeerNames(rHttpRequestContext.mPeerIdentities);
UtlString* peerName;
while ( (peerName = dynamic_cast<UtlString*>(rPeerNames())) )
{
mPeerIdentities.append(new UtlString(*peerName));
}
}
}
示例8: getPartHeaderValue
UtlBoolean MimeBodyPart::getPartHeaderValue(const char* headerName, UtlString& headerValue) const
{
headerValue.remove(0);
NameValuePair matchName(headerName);
NameValuePair* nvp = (NameValuePair*) mNameValues.find(&matchName);
if(nvp)
{
headerValue.append(nvp->getValue());
}
return(nvp != NULL);
}
示例9: getPath
UtlBoolean Url::getPath(UtlString& path, UtlBoolean getStyle)
{
path = mPath;
// If the desire is to have an HTTP GET style path with CGI variables
if(getStyle)
{
if ( ( mpHeaderOrQueryParameters
|| const_cast<Url*>(this)->parseHeaderOrQueryParameters()
)
&& mpHeaderOrQueryParameters->entries()
)
{
UtlDListIterator headerParamIterator(*mpHeaderOrQueryParameters);
NameValuePair* headerParam = NULL;
UtlString headerParamValue ;
UtlBoolean firstHeader = TRUE;
while ((headerParam = (NameValuePair*) headerParamIterator()))
{
// Add separator for first header parameter
if(firstHeader)
{
path.append("?", 1);
firstHeader = FALSE;
}
else
{
path.append("&", 1);
}
path.append(*headerParam);
headerParamValue = headerParam->getValue();
if(!headerParamValue.isNull())
{
path.append("=", 1);
HttpMessage::escape(headerParamValue);
path.append(headerParamValue);
}
}
} // endif mpHeaderOrQueryParameters
}
return(!mPath.isNull());
}
示例10: getCgiVariable
UtlBoolean HttpRequestContext::getCgiVariable(int index, UtlString& name, UtlString& value) const
{
NameValuePair* nameValuePair = NULL;
name.remove(0);
value.remove(0);
if((int)(mCgiVariableList.entries()) > index && index >= 0)
{
nameValuePair = (NameValuePair*)mCgiVariableList.at(index);
if(nameValuePair)
{
name = *nameValuePair;
value.append(nameValuePair->getValue());
}
}
return(nameValuePair != NULL);
}
示例11: getUrlParameter
UtlBoolean Url::getUrlParameter(int urlIndex, UtlString& name, UtlString& value)
{
NameValuePair* url = NULL;
if ( (urlIndex >= 0)
&& (mpUrlParameters || parseUrlParameters())
&& (((int)(mpUrlParameters->entries())) > urlIndex)
)
{
url = (NameValuePair*) mpUrlParameters->at(urlIndex);
}
if(url)
{
name = *url;
value = url->getValue();
}
return(NULL != url);
}
示例12: getVariable
UtlBoolean SipRequestContext::getVariable(const char* name,
UtlString& value,
int occurance) const
{
UtlDListIterator iterator((UtlDList&)mVariableList);
NameValuePair* nameValuePair = NULL;
int fieldIndex = 0;
UtlString upperCaseName;
UtlBoolean foundName = FALSE;
value.remove(0);
if(name)
{
upperCaseName.append(name);
upperCaseName.toUpper();
}
NameValuePair matchName(upperCaseName);
// For each name value:
while(fieldIndex <= occurance)
{
// Go to the next header field
nameValuePair = (NameValuePair*) iterator.findNext(&matchName);
if(!nameValuePair || fieldIndex == occurance)
{
break;
}
fieldIndex++;
}
if(fieldIndex == occurance && nameValuePair)
{
value.append(nameValuePair->getValue());
foundName = TRUE;
}
upperCaseName.remove(0);
return(foundName);
}
示例13: partHeaders
// Constructor
MimeBodyPart::MimeBodyPart(const HttpBody* parent, int parentBodyStartIndex, int rawBodyLength)
{
mpParentBody = parent;
mParentBodyRawStartIndex = parentBodyStartIndex;
mRawBodyLength = rawBodyLength;
mParentBodyStartIndex = parentBodyStartIndex;
mBodyLength = 0;
if(rawBodyLength > 0 && parent)
{
const char* parentBodyBytes;
const char* bodyBytes;
int parentBodyLength;
parent->getBytes(&parentBodyBytes, &parentBodyLength);
bodyBytes = parentBodyBytes + parentBodyStartIndex;
if(parentBodyLength >= parentBodyStartIndex + rawBodyLength)
{
int parsedBytes = HttpMessage::parseHeaders(bodyBytes, rawBodyLength,
mNameValues);
// search the part headers for a Content-Type
NameValuePair* partType;
UtlDListIterator partHeaders(mNameValues);
for( partType = static_cast<NameValuePair*>(partHeaders());
partType && partType->compareTo(HTTP_CONTENT_TYPE_FIELD, UtlString::ignoreCase);
partType = static_cast<NameValuePair*>(partHeaders())
)
{
}
if (partType)
{
// the content-type of the part is stored in the parent UtlString
append(partType->getValue());
}
mParentBodyStartIndex = parentBodyStartIndex + parsedBytes;
mBodyLength = mRawBodyLength - parsedBytes;
}
}
}
示例14: toString
void Url::toString(UtlString& urlString) const
{
UtlBoolean isNameAddr = FALSE;
// This is a replace operation; clear the storage string
urlString.remove(0);
if ( !mDisplayName.isNull() )
{
urlString.append(mDisplayName);
isNameAddr = TRUE;
}
bool haveUrlParams = ( ( mpUrlParameters
|| const_cast<Url*>(this)->parseUrlParameters()
)
&& mpUrlParameters->entries()
);
bool haveHdrParams = ( ( mpHeaderOrQueryParameters
|| const_cast<Url*>(this)->parseHeaderOrQueryParameters()
)
&& mpHeaderOrQueryParameters->entries()
);
bool haveFldParams = ( ( mpFieldParameters
|| const_cast<Url*>(this)->parseFieldParameters()
)
&& mpFieldParameters->entries()
);
// If this should be nameAddr as opposed to addrSpec
// (i.e. do we need anglebrackets)
if ( isNameAddr // There was a Display name
|| mAngleBracketsIncluded // Explicit setting from the caller
|| haveFldParams
|| ( ( SipUrlScheme == mScheme || SipsUrlScheme == mScheme )
&& ( haveUrlParams || haveHdrParams )
)
)
{
urlString.append("<", 1);
isNameAddr = TRUE;
}
UtlString theAddrSpec;
const_cast<Url*>(this)->getUri(theAddrSpec);
urlString.append(theAddrSpec);
// Add the terminating angle bracket
if(isNameAddr)
{
urlString.append(">", 1);
}
// Add the field parameters
if(haveFldParams)
{
UtlDListIterator fieldParamIterator(*mpFieldParameters);
NameValuePair* fieldParam = NULL;
UtlString fieldParamValue;
while ((fieldParam = (NameValuePair*) fieldParamIterator()))
{
urlString.append(";", 1);
urlString.append(*fieldParam);
fieldParamValue = fieldParam->getValue();
if(!fieldParamValue.isNull())
{
urlString.append("=", 1);
Url::gen_value_escape(fieldParamValue);
urlString.append(fieldParamValue);
}
}
}
}
示例15: parseCgiVariables
//.........这里部分代码省略.........
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.
unescape(*newNvPair);
NameValueTokenizer::frontBackTrim(newNvPair, " \t\n\r");
# ifdef TEST_DEBUG
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"HttpRequestContext::parseCgiVariables adding %p '%s' -> '%s'",
&cgiVariableList, newNvPair->data(), newNvPair->getValue()
);
# endif
// Add the name, value pair to the list
cgiVariableList.insert(newNvPair);
nameValueIndex++;
}
}
} while(nameAndValuePtr &&
nameAndValueLength > 0 &&
queryString[lastCharIndex] != '\0');
}