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
.
The following are the steps to encode the WSP header:
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.
//creates a pointer to CWspHeaderEncoder object CWspHeaderEncoder* primEncoder = CWspHeaderEncoder::NewLC();
// start a new encoded header primEncoder->StartHeaderL(0x27);
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();
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);
CWspHeaderEncoder::EndValuesLengthL()
at the
time of header construction when ValueLength can be calculated.
CWspHeaderEncoder::EndValuesLengthL()
.
primEncoder->EndValueLengthL();
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.