本文整理汇总了C++中SjByteVector::mid方法的典型用法代码示例。如果您正苦于以下问题:C++ SjByteVector::mid方法的具体用法?C++ SjByteVector::mid怎么用?C++ SjByteVector::mid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SjByteVector
的用法示例。
在下文中一共展示了SjByteVector::mid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
SjByteVector ID3v2_Frame::fieldData(const SjByteVector &frameData) const
{
SjUint headerSize = ID3v2_FrameHeader::size(m_header->version());
SjUint frameDataOffset = headerSize;
SjUint frameDataLength = size();
if(m_header->compression() || m_header->dataLengthIndicator()) {
frameDataLength = frameData.mid(headerSize, 4).toUInt();
frameDataOffset += 4;
}
if(m_header->compression()) {
SjByteVector data(frameDataLength);
uLongf uLongTmp = data.size(); // normally, this should be same as frameDataLength - however, on allocation errors, this may be 0!
::uncompress((Bytef *) data.getWriteableData(),
(uLongf *) &uLongTmp,
(Bytef *) frameData.getReadableData() + frameDataOffset,
size());
return data;
}
else
return frameData.mid(frameDataOffset, frameDataLength);
}
示例2:
void ID3v2_PopularimeterFrame::parseFields(const SjByteVector& data)
{
m_email.Empty();
m_rating255 = 0;
m_counter = 0;
int offset, pos = 0, size = (int)data.size();
offset = data.find(textDelimiter(SJ_LATIN1), pos);
if( offset < pos ) {
return;
}
m_email = data.mid(pos, offset - pos).toString(SJ_LATIN1);
pos = offset + 1;
if(pos < size)
{
m_rating255 = (int)(data[pos]);
pos++;
if(pos < size)
{
m_counter = data.mid(pos, 4).toUInt();
}
}
}
示例3: parse
void MPEG_XingHeader::parse(const SjByteVector &data)
{
// Check to see if a valid Xing header is available.
if(!data.startsWith((unsigned char*)"Xing"))
{
return;
}
// If the XingHeader doesn't contain the number of frames and the total stream
// info it's invalid.
if(!(data[7] & 0x02))
{
wxLogDebug(wxT("MPEG::XingHeader::parse() -- Xing header doesn't contain the total number of frames."));
return;
}
if(!(data[7] & 0x04))
{
wxLogDebug(wxT("MPEG::XingHeader::parse() -- Xing header doesn't contain the total stream size."));
return;
}
m_frames = data.mid(8, 4).toUInt();
m_size = data.mid(12, 4).toUInt();
m_valid = true;
}
示例4: s
void ID3v2_TextIdentificationFrame::parseFields(const SjByteVector &data)
{
// read the string data type (the first byte of the field data)
m_textEncoding = (SjStringType)(data[0]);
// split the byte array into chunks based on the string type (two byte delimiter
// for unicode encodings)
int byteAlign = m_textEncoding == SJ_LATIN1 || m_textEncoding == SJ_UTF8 ? 1 : 2;
//ByteVectorList l = ByteVectorList::split(data.mid(1), textDelimiter(d->textEncoding), byteAlign);
SjArrayByteVector l = data.mid(1).splitToArray(textDelimiter(m_textEncoding), byteAlign);
m_fieldList.Empty();
// append those split values to the list and make sure that the new string's
// type is the same specified for this frame
/*for(ByteVectorList::Iterator it = l.begin(); it != l.end(); it++) {
String s(*it, d->textEncoding);
d->fieldList.append(s);
}
*/
int i, iCount = l.GetCount();
for( i = 0; i < iCount; i++ )
{
m_fieldList.Add(l.Item(i).toString(m_textEncoding));
}
}
示例5: parse
void APE_Item::parse(const SjByteVector &data)
{
// 11 bytes is the minimum size for an APE item
if(data.size() < 11)
{
wxLogDebug(wxT("APE::Item::parse() -- no data in item"));
return;
}
SjUint valueLength = data.mid(0, 4).toUInt(false);
SjUint flags = data.mid(4, 4).toUInt(false);
m_key = data.mid(8).toString(SJ_UTF8); // data.mid(8) contains more than just the string -- but SjBytevector only converts up to the first null-byte at (***)
m_binary = data.mid(8 + m_key.size() + 1, valueLength);
setReadOnly(flags & 1);
setType((APE_ItemType)((flags >> 1) & 3));
if(int(m_type) < 2)
{
m_stringList = m_binary.splitToStrings((unsigned char)'\0', SJ_UTF8);
}
}
示例6: String
void ID3v2_CommentsFrame::parseFields(const SjByteVector &data)
{
if(data.size() < 5) {
wxLogDebug(wxT("A comment frame must contain at least 5 bytes."));
return;
}
m_textEncoding = (SjStringType)(data[0]);
m_language = data.mid(1, 3);
int byteAlign = (m_textEncoding == SJ_LATIN1 || m_textEncoding == SJ_UTF8) ? 1 : 2;
//ByteVectorList l = ByteVectorList::split(data.mid(4), textDelimiter(d->textEncoding), byteAlign, 2);
SjArrayByteVector l = data.mid(4).splitToArray(textDelimiter(m_textEncoding), byteAlign, 2);
if(l.GetCount() == 2) {
/*d->description = String(l.front(), d->textEncoding);
d->text = String(l.back(), d->textEncoding);
*/
m_description = l.Item(0).toString(m_textEncoding);
m_text = l.Item(1).toString(m_textEncoding);
}
}
示例7:
void ID3v2_Tag::parse(const SjByteVector &data)
{
SjUint frameDataPosition = 0;
SjUint frameDataLength = data.size();
// check for extended header
if(m_header.extendedHeader()) {
if(!m_extendedHeader)
m_extendedHeader = new ID3v2_ExtendedHeader;
m_extendedHeader->setData(data);
if(m_extendedHeader->size() <= data.size()) {
frameDataPosition += m_extendedHeader->size();
frameDataLength -= m_extendedHeader->size();
}
}
// check for footer -- we don't actually need to parse it, as it *must*
// contain the same data as the header, but we do need to account for its
// size.
if(m_header.footerPresent() && ID3v2_Footer::size() <= frameDataLength)
frameDataLength -= ID3v2_Footer::size();
// parse frames
// Make sure that there is at least enough room in the remaining frame data for
// a frame header.
while(frameDataPosition < frameDataLength - ID3v2_Frame::headerSize(m_header.majorVersion())) {
// If the next data is position is 0, assume that we've hit the padding
// portion of the frame data.
if(data.at(frameDataPosition) == 0) {
if(m_header.footerPresent())
wxLogDebug(wxT("Padding *and* a footer found. This is not allowed by the spec."));
m_paddingSize = frameDataLength - frameDataPosition;
return;
}
ID3v2_Frame *frame = m_factory->createFrame(data.mid(frameDataPosition),
m_header.majorVersion());
if(!frame)
return;
// get the next frame position
frameDataPosition += frame->size() + ID3v2_Frame::headerSize(m_header.majorVersion());
// add the frame if it has a size of at least 1 byte (smaller frames are not allowed
// by the specification, but they're returned from createFrame() to allow seeking to the
// next frame).
// modification by me
if(frame->size() <= 0) {
delete frame;
}
else {
addFrame(frame);
}
}
}
示例8:
void ID3v2_FrameHeader::setFrameID(const SjByteVector &id)
{
m_frameID = id.mid(0, 4);
}