Reading
headers in a WSP buffer
TWspField
object holds the name and value pair
of the WSP header field.
TWspHeaderSegmenter
pulls the header
/ value pair out of the WSP buffer (into
TWspField
). Call
TWspHeaderSegmenter::NextL()
to
iterate through the WSP buffer. It calls
TWspPrimitiveDecoder
.
CWspHeaderEncoder
allows you to encode
the values and parameters of the header field. It creates one header at a
time from the name / value pairs.
The following are the steps to encode the WSP header:
-
Create a header encoder object.
//creates a pointer to CWspHeaderEncoder object
CWspHeaderEncoder* primEncoder = CWspHeaderEncoder::NewLC();
-
Start a new encoded header to encode the parameter value.
// start a new encoded header
primEncoder->StartHeaderL(0x27);
-
Call
CWspHeaderEncoder::StartValueLengthL()
to calculate
the length of encodings that are added subsequently. The value calculated,
is stored as part of the encoded string, as specified in the WSP standard.
primEncoder->StartValueLengthL();
-
Encode the header field and add it to the encoded field.
Note
: The appropriate WSP method is used for encoding the header
field of a data type such as integer, date, text string and so on.
primEncoder->AddIntegerL(0x7F);
primEncoder->AddUintVarL(0xff);
primEncoder->AddLongIntL(999999);
_LIT8(KString, "WSP Encode: String");
primEncoder->AddTextStringL(KString);
TDateTime time(2006,EMarch,20,06,36,30,000000); //create a date time object
primEncoder->AddDateL(time); // add
TUInt intVal=489;
primEncoder->AddLTokenL(intVal);
_LIT8(KTokenText, "WSP Encode: Token Text");
primEncoder->AddLTokenTextL(KTokenText);
-
Call
CWspHeaderEncoder::EndValuesLengthL()
at the
time of header construction when ValueLength can be calculated.
-
Assuming that the length of the header encodings has been calculated
and added to the encoder field, call
CWspHeaderEncoder::EndValuesLengthL()
.
primEncoder->EndValueLengthL();
-
Call
CWspHeaderEncoder::EndHeaderL()
, to complete
the header encoding. This completes and returns the encoded header field's
8 bit buffer.
EndHeaderL()
panics if
EndValueLengthL()
is
not called after
CWspHeaderEncoder::StartValueLengthL()
.
HBufC8* buf = primEncoder->EndHeaderL();
This returns a pointer to the buffer containing the encoded
field.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.