Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Member Functions | Private Attributes
Arc::ByteArray Class Reference

#include <ByteArray.h>

List of all members.

Public Member Functions

 ByteArray ()
 ByteArray (size_t length)
 ByteArray (void *buf, size_t size)
 ~ByteArray ()
void append (const void *buf, size_t size)
void append (const std::string &str)
void append (ByteArray &buf)
void clean (void)
char * data (void)
size_t size (void)
 operator std::string (void) const

Private Member Functions

void resize (size_t new_size)
void init (size_t length)

Private Attributes

char * data_
size_t size_
size_t length_

Detailed Description

Definition at line 18 of file ByteArray.h.


Constructor & Destructor Documentation

Definition at line 26 of file ByteArray.h.

                {
      data_ = NULL;
      size_ = 0;
      length_ = 0;
    }
Arc::ByteArray::ByteArray ( size_t  length)

Definition at line 26 of file ByteArray.cpp.

                                    {
    init(length);
  }

Here is the call graph for this function:

Arc::ByteArray::ByteArray ( void *  buf,
size_t  size 
)

Definition at line 30 of file ByteArray.cpp.

                                          {
    init(s);
    append(buf, s);
  }

Here is the call graph for this function:

Definition at line 35 of file ByteArray.cpp.

                        {
    if (data_ != NULL)
      free(data_);
    size_ = 0;
    length_ = 0;
  }

Member Function Documentation

void Arc::ByteArray::append ( const void *  buf,
size_t  size 
)

Definition at line 54 of file ByteArray.cpp.

                                                  {
    unsigned int new_size = size_ + s;
    if (new_size > length_)
      resize(new_size);
    memcpy(data_ + size_, buf, s);
    size_ = new_size;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::ByteArray::append ( const std::string &  str)

Definition at line 62 of file ByteArray.cpp.

                                             {
    append(str.c_str(), str.size() + 1);
  }

Here is the call graph for this function:

Definition at line 66 of file ByteArray.cpp.

                                       {
    size_t s = buf.size();
    append(&s, sizeof(size_t));
    append(buf.data(), buf.size());
  }

Here is the call graph for this function:

void Arc::ByteArray::clean ( void  )

Definition at line 72 of file ByteArray.cpp.

                            {
    memset(data_, 0, length_);
    size_ = 0;
  }

Here is the caller graph for this function:

char* Arc::ByteArray::data ( void  ) [inline]

Definition at line 38 of file ByteArray.h.

                     {
      return data_;
    }

Here is the caller graph for this function:

void Arc::ByteArray::init ( size_t  length) [private]

Definition at line 17 of file ByteArray.cpp.

                                    {
    size_t new_length = length + BYTE_ARRAY_PAD_SIZE;
    data_ = (char*)calloc(new_length, sizeof(char));
    if (data_ == NULL)
      throw MemoryAllocationException();
    size_ = 0;
    length_ = new_length;
  }

Here is the caller graph for this function:

Arc::ByteArray::operator std::string ( void  ) const

Definition at line 77 of file ByteArray.cpp.

                                          {
    std::ostringstream o;
    for (int i = 0; i < length_; i++) {
      o << std::hex << std::setiosflags(std::ios_base::showbase);
      o << (int)data_[i] << " ";
    }
    return o.str();
  }
void Arc::ByteArray::resize ( size_t  new_size) [private]

Definition at line 42 of file ByteArray.cpp.

                                        {
    size_t new_length = new_size + BYTE_ARRAY_PAD_SIZE;
    char *new_data = (char*)calloc(new_length, sizeof(char));
    if (new_data == NULL)
      throw MemoryAllocationException();
    // memmove?
    memcpy(new_data, data_, size_);
    free(data_);
    data_ = new_data;
    length_ = new_length;
  }

Here is the caller graph for this function:

size_t Arc::ByteArray::size ( void  ) [inline]

Definition at line 41 of file ByteArray.h.

                      {
      return size_;
    }

Here is the caller graph for this function:


Member Data Documentation

char* Arc::ByteArray::data_ [private]

Definition at line 20 of file ByteArray.h.

size_t Arc::ByteArray::length_ [private]

Definition at line 22 of file ByteArray.h.

size_t Arc::ByteArray::size_ [private]

Definition at line 21 of file ByteArray.h.


The documentation for this class was generated from the following files: