Back to index

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

Wraper for CheckSum class. More...

#include <CheckSum.h>

Inheritance diagram for Arc::CheckSumAny:
Inheritance graph
[legend]
Collaboration diagram for Arc::CheckSumAny:
Collaboration graph
[legend]

List of all members.

Public Types

enum  type {
  none, unknown, undefined, cksum,
  md5, adler32
}

Public Member Functions

 CheckSumAny (CheckSum *c=NULL)
 CheckSumAny (type type)
 CheckSumAny (const char *type)
virtual ~CheckSumAny (void)
virtual void start (void)
virtual void add (void *buf, unsigned long long int len)
virtual void end (void)
virtual void result (unsigned char *&res, unsigned int &len) const
virtual int print (char *buf, int len) const
virtual void scan (const char *buf)
virtual operator bool (void) const
virtual bool operator! (void) const
bool active (void)
type Type (void) const
void operator= (const char *type)
bool operator== (const char *s)
bool operator== (const CheckSumAny &ck)

Static Public Member Functions

static type Type (const char *crc)

Private Attributes

CheckSumcs
type tp

Detailed Description

Wraper for CheckSum class.

To be used for manipulation of any supported checksum type in a transparent way.

Definition at line 145 of file CheckSum.h.


Member Enumeration Documentation

Enumerator:
none 
unknown 
undefined 
cksum 
md5 
adler32 

Definition at line 148 of file CheckSum.h.


Constructor & Destructor Documentation

Arc::CheckSumAny::CheckSumAny ( CheckSum c = NULL) [inline]

Definition at line 160 of file CheckSum.h.

      : cs(c),
        tp(none) {}

Definition at line 425 of file CheckSum.cpp.

                                    {
    if (type == cksum) {
      cs = new CRC32Sum;
      tp = type;
      return;
    }
    if (type == md5) {
      cs = new MD5Sum;
      tp = type;
      return;
    }
    if (type == adler32) {
      cs = new Adler32Sum;
      tp = type;
      return;
    }
  }
Arc::CheckSumAny::CheckSumAny ( const char *  type)

Definition at line 403 of file CheckSum.cpp.

    : cs(NULL),
      tp(CheckSumAny::none) {
    if (!type)
      return;
    if (strncasecmp("cksum", type, 5) == 0) {
      cs = new CRC32Sum;
      tp = cksum;
      return;
    }
    if (strncasecmp("md5", type, 3) == 0) {
      cs = new MD5Sum;
      tp = md5;
      return;
    }
    if(strncasecmp("adler32",type,7) == 0) {
      cs=new Adler32Sum; 
      tp=adler32; 
      return;
    }
  }
virtual Arc::CheckSumAny::~CheckSumAny ( void  ) [inline, virtual]

Definition at line 165 of file CheckSum.h.

                               {
      if (cs)
        delete cs;
    }

Member Function Documentation

bool Arc::CheckSumAny::active ( void  ) [inline]

Definition at line 209 of file CheckSum.h.

                      {
      return (cs != NULL);
    }
virtual void Arc::CheckSumAny::add ( void *  buf,
unsigned long long int  len 
) [inline, virtual]

Implements Arc::CheckSum.

Definition at line 173 of file CheckSum.h.

                                                            {
      if (cs)
        cs->add(buf, len);
    }

Here is the call graph for this function:

virtual void Arc::CheckSumAny::end ( void  ) [inline, virtual]

Implements Arc::CheckSum.

Definition at line 177 of file CheckSum.h.

                           {
      if (cs)
        cs->end();
    }

Here is the call graph for this function:

virtual Arc::CheckSumAny::operator bool ( void  ) const [inline, virtual]

Reimplemented from Arc::CheckSum.

Definition at line 199 of file CheckSum.h.

                                      {
      if (!cs)
        return false;
      return *cs;
    }
virtual bool Arc::CheckSumAny::operator! ( void  ) const [inline, virtual]

Reimplemented from Arc::CheckSum.

Definition at line 204 of file CheckSum.h.

                                       {
      if (!cs)
        return true;
      return !(*cs);
    }
void Arc::CheckSumAny::operator= ( const char *  type)

Definition at line 469 of file CheckSum.cpp.

                                              {
    if (cs)
      delete cs;
    cs = NULL;
    tp = none;
    if (!type)
      return;
    if (strncasecmp("cksum", type, 5) == 0) {
      cs = new CRC32Sum;
      tp = cksum;
      return;
    }
    if (strncasecmp("md5", type, 3) == 0) {
      cs = new MD5Sum;
      tp = md5;
      return;
    }
    if (strncasecmp("adler32", type, 7) == 0) {
      cs = new Adler32Sum;
      tp = adler32;
      return;
    }
  }
bool Arc::CheckSumAny::operator== ( const char *  s)

Definition at line 493 of file CheckSum.cpp.

                                            {
    if (!cs)
      return false;
    if (!(*cs))
      return false;
    if (!s)
      return false;
    CheckSumAny c(s);
    if (!(c.cs))
      return false;
    c.cs->scan(s);
    if (!(*(c.cs)))
      return false;
    if (c.tp != tp)
      return false;
    unsigned char *res;
    unsigned char *res_;
    unsigned int len;
    unsigned int len_;
    cs->result(res, len);
    c.cs->result(res_, len_);
    if (len != len_)
      return false;
    if (memcmp(res, res_, len) != 0)
      return false;
    return true;
  }

Here is the call graph for this function:

bool Arc::CheckSumAny::operator== ( const CheckSumAny ck)

Definition at line 521 of file CheckSum.cpp.

                                                   {
    if (!cs)
      return false;
    if (!(*cs))
      return false;
    if (!c)
      return false;
    unsigned char *res;
    unsigned char *res_;
    unsigned int len;
    unsigned int len_;
    cs->result(res, len);
    c.cs->result(res_, len_);
    if (len != len_)
      return false;
    if (memcmp(res, res_, len) != 0)
      return false;
    return true;
  }

Here is the call graph for this function:

virtual int Arc::CheckSumAny::print ( char *  buf,
int  len 
) const [inline, virtual]

Reimplemented from Arc::CheckSum.

Definition at line 188 of file CheckSum.h.

                                                {
      if (cs)
        return cs->print(buf, len);
      if (len > 0)
        buf[0] = 0;
      return 0;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Arc::CheckSumAny::result ( unsigned char *&  res,
unsigned int &  len 
) const [inline, virtual]

Implements Arc::CheckSum.

Definition at line 181 of file CheckSum.h.

                                                                      {
      if (cs) {
        cs->result(res, len);
        return;
      }
      len = 0;
    }

Here is the call graph for this function:

virtual void Arc::CheckSumAny::scan ( const char *  buf) [inline, virtual]

Implements Arc::CheckSum.

Definition at line 195 of file CheckSum.h.

                                       {
      if (cs)
        cs->scan(buf);
    }

Here is the call graph for this function:

virtual void Arc::CheckSumAny::start ( void  ) [inline, virtual]

Implements Arc::CheckSum.

Definition at line 169 of file CheckSum.h.

                             {
      if (cs)
        cs->start();
    }

Here is the call graph for this function:

CheckSumAny::type Arc::CheckSumAny::Type ( const char *  crc) [static]

Definition at line 443 of file CheckSum.cpp.

                                                   {
    if (!crc)
      return none;
    if (!crc[0])
      return none;
    const char *p = strchr(crc, ':');
    if (!p) {
      p = crc + strlen(crc);
      int i;
      for (i = 0; crc[i]; i++)
        if (!isxdigit(crc[i]))
          break;
      if (!(crc[i]))
        return cksum;
    }
    if (((p - crc) == 5) && (strncasecmp(crc, "cksum", 5) == 0))
      return cksum;
    if (((p - crc) == 3) && (strncasecmp(crc, "md5", 3) == 0))
      return md5;
    if (((p - crc) == 7) && (strncasecmp(crc, "adler32", 7) == 0))
      return adler32;
    if (((p - crc) == 9) && (strncasecmp(crc, "undefined", 9) == 0))
      return undefined;
    return unknown;
  }

Here is the caller graph for this function:

type Arc::CheckSumAny::Type ( void  ) const [inline]

Definition at line 213 of file CheckSum.h.

                          {
      return tp;
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 157 of file CheckSum.h.

Definition at line 158 of file CheckSum.h.


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