SASC
DVBSoftCAM

SI::CharArray Class Reference

#include <util.h>

List of all members.

Classes

class  Data
class  DataForeignData
class  DataOwnData

Public Member Functions

 CharArray ()
 CharArray (const CharArray &source)
CharArray & operator= (const CharArray &source)
 ~CharArray ()
void assign (const unsigned char *data, int size, bool doCopy=true)
bool operator== (const char *string) const
bool operator== (const CharArray &other) const
CharArray operator+ (const int offset) const
const unsigned char * getData () const
const unsigned char * getData (int offset) const
template<typename T >
const T * getData () const
template<typename T >
const T * getData (int offset) const
template<typename T >
void setPointerAndOffset (const T *&p, int &offset) const
unsigned char operator[] (const int index) const
int getLength () const
u_int16_t TwoBytes (const int index) const
u_int32_t FourBytes (const int index) const
bool isValid () const
bool checkSize (int offset)
void addOffset (int offset)

Detailed Description

Definition at line 31 of file util.h.


Constructor & Destructor Documentation

SI::CharArray::CharArray ( )

Definition at line 20 of file util.c.

                     : data_(0), off(0) {
}
SI::CharArray::CharArray ( const CharArray &  source)

Definition at line 30 of file util.c.

                                       : data_(f.data_), off(f.off) {
   if (data_)
      ++ data_->count_;
}
SI::CharArray::~CharArray ( )

Definition at line 23 of file util.c.

                      {
   if (!data_)
      return;
   if (--data_->count_ == 0)
      delete data_;
}

Member Function Documentation

void SI::CharArray::addOffset ( int  offset) [inline]

Definition at line 64 of file util.h.

Referenced by SI::StructureLoop< Rating >::getNext(), and SI::StructureLoop< Rating >::getNextAsPointer().

{ off+=offset; }
void SI::CharArray::assign ( const unsigned char *  data,
int  size,
bool  doCopy = true 
)

Definition at line 50 of file util.c.

Referenced by SI::Object::setData().

                                                                      {
    //immutable
    if (!data_)
      data_= doCopy ? (Data*)new DataOwnData() : (Data*)new DataForeignData();
    // This method might need to change things in *data_
    // Thus it first checks if this is the only pointer to *data_
    if (data_->count_ > 1) {
      Data* d = doCopy ? (Data*)new DataOwnData() : (Data*)new DataForeignData();
      -- data_->count_;
      data_ = d;
    }
    data_->assign(data, size);
}
bool SI::CharArray::checkSize ( int  offset) [inline]

Definition at line 62 of file util.h.

Referenced by SI::Object::checkSize().

{ return (data_->valid && (data_->valid=(offset>=0 && off+offset < data_->size))); }
u_int32_t SI::CharArray::FourBytes ( const int  index) const [inline]

Definition at line 59 of file util.h.

Referenced by SI::AIT::Application::getOrganisationId(), and SI::TypeLoop< SixteenBit >::operator[]().

{ return data_->data ? data_->FourBytes(off+index) : 0; }
template<typename T >
const T* SI::CharArray::getData ( int  offset) const [inline]

Definition at line 53 of file util.h.

{ return (T*)(data_->data+offset+off); }
template<typename T >
const T* SI::CharArray::getData ( ) const [inline]

Definition at line 52 of file util.h.

{ return (T*)(data_->data+off); }
const unsigned char* SI::CharArray::getData ( ) const [inline]

Definition at line 50 of file util.h.

Referenced by SI::DescriptorLoop::createDescriptor(), SI::String::decodeText(), SI::NumberedSection::getCurrentNextIndicator(), SI::Descriptor::getDescriptor(), SI::Descriptor::getDescriptorTag(), SI::DescriptorLoop::getDescriptorTags(), SI::NumberedSection::getLastSectionNumber(), SI::Descriptor::getLength(), SI::Section::getLength(), SI::DescriptorLoop::getNext(), SI::DescriptorLoop::getNumberOfDescriptors(), SI::NumberedSection::getSectionNumber(), SI::Section::getTableId(), SI::NumberedSection::getTableIdExtension(), SI::NumberedSection::getVersionNumber(), SI::CRCSection::isCRCValid(), SI::RST::RunningInfo::Parse(), SI::TDT::Parse(), SI::PAT::Association::Parse(), SI::MHP_DVBJApplicationDescriptor::ApplicationEntry::Parse(), SI::MHP_ApplicationNameDescriptor::NameEntry::Parse(), SI::MHP_ApplicationDescriptor::Profile::Parse(), SI::ApplicationSignallingDescriptor::ApplicationEntryDescriptor::Parse(), SI::PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry::Parse(), SI::PremiereContentTransmissionDescriptor::StartDayEntry::Parse(), SI::PremiereContentTransmissionDescriptor::Parse(), SI::ISO639LanguageDescriptor::Language::Parse(), SI::LinkageDescriptor::Parse(), SI::LocalTimeOffsetDescriptor::LocalTimeOffset::Parse(), SI::ServiceMoveDescriptor::Parse(), SI::SubtitlingDescriptor::Subtitling::Parse(), SI::PrivateDataSpecifierDescriptor::Parse(), SI::TimeShiftedServiceDescriptor::Parse(), SI::NVODReferenceDescriptor::Service::Parse(), SI::TerrestrialDeliverySystemDescriptor::Parse(), SI::CableDeliverySystemDescriptor::Parse(), SI::SatelliteDeliverySystemDescriptor::Parse(), SI::ServiceListDescriptor::Service::Parse(), SI::CarouselIdentifierDescriptor::Parse(), SI::StreamIdentifierDescriptor::Parse(), SI::CaDescriptor::Parse(), SI::TeletextDescriptor::Teletext::Parse(), SI::ParentalRatingDescriptor::Rating::Parse(), SI::ContentDescriptor::Nibble::Parse(), SI::TimeShiftedEventDescriptor::Parse(), and setPointerAndOffset().

{ return data_->data+off; }
const unsigned char* SI::CharArray::getData ( int  offset) const [inline]

Definition at line 51 of file util.h.

{ return data_->data+offset+off; }
int SI::CharArray::getLength ( ) const [inline]

Definition at line 57 of file util.h.

{ return data_->size; }
bool SI::CharArray::isValid ( ) const [inline]

Definition at line 61 of file util.h.

{ return data_->valid; }
CharArray SI::CharArray::operator+ ( const int  offset) const

Definition at line 85 of file util.c.

                                                     {
   CharArray f(*this);
   f.off+=offset;
   return f;
}
CharArray & SI::CharArray::operator= ( const CharArray &  source)

Definition at line 35 of file util.c.

                                                  {
    // DO NOT CHANGE THE ORDER OF THESE STATEMENTS!
    // (This order properly handles self-assignment)
    if (f.data_) {
      ++ f.data_->count_;
    }
    if (data_) {
      if (--data_->count_ == 0)
         delete data_;
    }
    data_ = f.data_;
    off = f.off;
    return *this;
}
bool SI::CharArray::operator== ( const CharArray &  other) const

Definition at line 71 of file util.c.

References i.

                                                       {
   if (!data_ || !other.data_)
      return !(data_ || other.data_); //true if both empty

   if (data_->size != other.data_->size)
      return false;

   //do _not_ use strcmp! Data is not necessarily null-terminated.
   for (int i=0;i<data_->size;i++)
      if (data_->data[i] != other.data_->data[i])
         return false;
   return true;
}
bool SI::CharArray::operator== ( const char *  string) const

Definition at line 64 of file util.c.

                                                   {
   //here we can use strcmp, string is null-terminated.
   if (!data_)
      return false;
   return data_->size ? (!strcmp((const char*)data_->data, string)) : string[0]==0;
}
unsigned char SI::CharArray::operator[] ( const int  index) const [inline]

Definition at line 56 of file util.h.

{ return data_->data ? data_->data[off+index] : 0; }
u_int16_t SI::CharArray::TwoBytes ( const int  index) const [inline]

Definition at line 58 of file util.h.

Referenced by SI::TypeLoop< SixteenBit >::operator[]().

{ return data_->data ? data_->TwoBytes(off+index) : 0; }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines