本文整理汇总了C++中TLFrame::tail方法的典型用法代码示例。如果您正苦于以下问题:C++ TLFrame::tail方法的具体用法?C++ TLFrame::tail怎么用?C++ TLFrame::tail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLFrame
的用法示例。
在下文中一共展示了TLFrame::tail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void TLUserData::write(TLFrame& dest, size_t& wp) const
{
#if 1
// First write TP-User-Data-Length
dest.writeField(wp,mLength,8);
// Then write TP-User-Data
// This tail() works because UD is always the last field in the PDU.
BitVector ud_dest = dest.tail(wp);
mRawData.copyTo(ud_dest);
ud_dest.LSB8MSB();
#else
// Stuff we don't support...
assert(!mUDHI);
assert(mDCS==0);
unsigned numChar = strlen(mData);
dest.writeField(wp,numChar,8);
// This tail() works because UD is always the last field in the PDU.
BitVector chars = dest.tail(wp);
chars.zero();
for (unsigned i=0; i<numChar; i++) {
char gsm = encodeGSMChar(mData[i]);
dest.writeFieldReversed(wp,gsm,7);
}
chars.LSB8MSB();
#endif
}
示例2: parse
void TLUserData::parse(const TLFrame& src, size_t& rp)
{
// The DCS is defined in GSM 03.38 4.
assert(mDCS<0x100); // Someone forgot to initialize the DCS.
// TP-User-Data-Length
mLength = src.readField(rp,8);
#if 1
// This tail() works because UD is always the last field in the PDU.
mRawData.clone(src.tail(rp));
// Should we do this here?
mRawData.LSB8MSB();
#else
assert(!mUDHI); // We don't support user headers.
switch (mDCS) {
case 0:
case 244:
case 245:
case 246:
case 247:
{
// GSM 7-bit encoding, GSM 03.38 6.
// Check bounds.
if (numChar*7 > (src.size()-rp)) {
LOG(NOTICE) << "badly formatted TL-UD";
SMS_READ_ERROR;
}
BitVector chars(src.tail(rp));
chars.LSB8MSB();
size_t crp=0;
for (unsigned i=0; i<numChar; i++) {
char gsm = chars.readFieldReversed(crp,7);
mData[i] = decodeGSMChar(gsm);
}
mData[numChar]='\0';
if (crp%8) crp += 8 - crp%8;
rp += crp;
return;
}
default:
{
rp += numChar;
sprintf(mData,"unsupported DCS 0x%x", mDCS);
LOG(NOTICE) << mData;
SMS_READ_ERROR;
}
}
#endif
}
示例3: write
void TLUserData::write(TLFrame& dest, size_t& wp) const
{
// Stuff we don't support...
assert(!mUDHI);
assert(mDCS==0);
unsigned numChar = strlen(mData);
dest.writeField(wp,numChar,8);
// This tail() works because UD is always the last field in the PDU.
BitVector chars = dest.tail(wp);
chars.zero();
for (unsigned i=0; i<numChar; i++) {
char gsm = encodeGSMChar(mData[i]);
dest.writeFieldReversed(wp,gsm,7);
}
chars.LSB8MSB();
}
示例4: parse
void TLUserData::parse(const TLFrame& src, size_t& rp)
{
assert(!mUDHI); // We don't support user headers.
// The DCS is defined in GSM 03.38 4.
assert(mDCS<0x100); // Someone forgot to initialize the DCS.
unsigned numChar = src.readField(rp,8);
switch (mDCS) {
case 0:
case 244:
case 245:
case 246:
case 247:
{
// GSM 7-bit encoding, GSM 03.38 6.
// Check bounds.
if (numChar*7 > (src.size()-rp)) {
LOG(NOTICE) << "badly formatted TL-UD";
SMS_READ_ERROR;
}
BitVector chars(src.tail(rp));
chars.LSB8MSB();
size_t crp=0;
for (unsigned i=0; i<numChar; i++) {
char gsm = chars.readFieldReversed(crp,7);
mData[i] = decodeGSMChar(gsm);
}
mData[numChar]='\0';
if (crp%8) crp += 8 - crp%8;
rp += crp;
return;
}
default:
{
rp += numChar;
sprintf(mData,"unsupported DCS 0x%x", mDCS);
LOG(NOTICE) << mData;
SMS_READ_ERROR;
}
}
}