#ifndef ByteArray_First #define ByteArray_First #ifdef __GNUG__ #pragma interface #endif #include "Object.h" extern const char *cAtPutName, *cOutOfBoundsError; //---- ByteArray -------------------------------------------------------------- class ByteArray: public Object { public: MetaDef(ByteArray); //---- creation, destruction ByteArray(int size); ByteArray(const byte *s, int l= -1); ByteArray(const char *s, int l= -1); ~ByteArray(); //---- accessing const byte *Str() const; const char *CharStr() const; void SetString(const char *s, int l= -1); void SetString(const byte *s, int l= -1) { SetString((const char*)s, l); } char At(int i) const; void AtPut(int i, byte c); //---- standard overriden methods const char *AsString(); u_long Hash(); bool IsEqual(Object*); int Compare(Object*); OStream &PrintOn(OStream&); IStream &ReadFrom(IStream&); private: void AllocByteArray(const byte *s, int l= -1); byte *cont; int cap; }; inline const byte *ByteArray::Str() const { return cont; } inline const char *ByteArray::CharStr() const { return (char*)cont; } inline char ByteArray::At(int i) const { return cont[i]; } inline void ByteArray::AtPut(int i, byte c) { if (i < 0 || i >= cap) Error(cAtPutName, cOutOfBoundsError); else cont[i]= c; } #endif