(file) Return to Buffer.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Buffer.h between version 1.4.2.1 and 1.12

version 1.4.2.1, 2006/07/28 20:06:32 version 1.12, 2008/12/01 17:49:47
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; Symantec Corporation; The Open Group.  
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // Permission is hereby granted, free of charge, to any person obtaining a
 // of this software and associated documentation files (the "Software"), to  // copy of this software and associated documentation files (the "Software"),
 // deal in the Software without restriction, including without limitation the  // to deal in the Software without restriction, including without limitation
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // sell copies of the Software, and to permit persons to whom the Software is  // and/or sell copies of the Software, and to permit persons to whom the
 // furnished to do so, subject to the following conditions:  // Software is furnished to do so, subject to the following conditions:
 // //
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // The above copyright notice and this permission notice shall be included
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // in all copies or substantial portions of the Software.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 // Author: Michael E. Brasher (mike-brasher@austin.rr.com -- Inova Europe)  //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 44 
Line 40 
  
 struct BufferRep struct BufferRep
 { {
     size_t size;      Uint32 size;
     size_t cap;      Uint32 cap;
     char data[1];     char data[1];
 }; };
  
Line 53 
Line 49 
 { {
 public: public:
  
     Buffer();      Buffer(Uint32 minCap=2048);
  
     Buffer(const Buffer& x);     Buffer(const Buffer& x);
  
     Buffer(const char* data, size_t size);      Buffer(const char* data, Uint32 size, Uint32 minCap=2048);
  
     ~Buffer();     ~Buffer();
  
Line 65 
Line 61 
  
     void swap(Buffer& x);     void swap(Buffer& x);
  
     size_t size() const;      Uint32 size() const;
  
     size_t capacity() const;      Uint32 capacity() const;
  
     /**     /**
         Returns a pointer to a character buffer with the Buffer contents.         Returns a pointer to a character buffer with the Buffer contents.
Line 76 
Line 72 
      */      */
     const char* getData() const;     const char* getData() const;
  
     char get(size_t i) const;      char get(Uint32 i) const;
  
     void set(size_t i, char x);      void set(Uint32 i, char x);
  
     const char& operator[](size_t i) const;      const char& operator[](Uint32 i) const;
  
     void reserveCapacity(size_t cap);      void reserveCapacity(Uint32 cap);
  
     void grow(size_t size, char x = '\0');      void grow(Uint32 size, char x = '\0');
  
     void append(char x);     void append(char x);
  
     void append(const char* data, size_t size);      void append(const char* data, Uint32 size);
  
     void append(char c1, char c2, char c3, char c4);     void append(char c1, char c2, char c3, char c4);
  
     void append(     void append(
         char c1, char c2, char c3, char c4, char c5, char c6, char c7, char c8);         char c1, char c2, char c3, char c4, char c5, char c6, char c7, char c8);
  
     void insert(size_t pos, const char* data, size_t size);      void insert(Uint32 pos, const char* data, Uint32 size);
  
     void remove(size_t pos, size_t size);      void remove(Uint32 pos, Uint32 size);
  
     void remove(size_t pos);      void remove(Uint32 pos);
  
     void clear();     void clear();
  
 private: private:
  
     void _reserve_aux(size_t cap);      void _reserve_aux(Uint32 cap);
  
     void _append_char_aux();     void _append_char_aux();
  
     BufferRep* _rep;     BufferRep* _rep;
     static BufferRep _empty_rep;     static BufferRep _empty_rep;
       Uint32 _minCap;
 }; };
  
 inline Buffer::Buffer() : _rep(&_empty_rep)  inline Buffer::Buffer(Uint32 minCap) : _rep(&_empty_rep), _minCap(minCap)
 { {
 } }
  
Line 130 
Line 127 
     x._rep = tmp;     x._rep = tmp;
 } }
  
 inline size_t Buffer::size() const  inline Uint32 Buffer::size() const
 { {
     return _rep->size;     return _rep->size;
 } }
  
 inline size_t Buffer::capacity() const  inline Uint32 Buffer::capacity() const
 { {
     return _rep->cap;     return _rep->cap;
 } }
Line 152 
Line 149 
     return _rep->data;     return _rep->data;
 } }
  
 inline char Buffer::get(size_t i) const  inline char Buffer::get(Uint32 i) const
 { {
     return _rep->data[i];     return _rep->data[i];
 } }
  
 inline void Buffer::set(size_t i, char x)  inline void Buffer::set(Uint32 i, char x)
 { {
     _rep->data[i] = x;     _rep->data[i] = x;
 } }
  
 inline const char& Buffer::operator[](size_t i) const  inline const char& Buffer::operator[](Uint32 i) const
 { {
     return _rep->data[i];     return _rep->data[i];
 } }
  
 inline void Buffer::reserveCapacity(size_t cap)  inline void Buffer::reserveCapacity(Uint32 cap)
 { {
     if (cap > _rep->cap)     if (cap > _rep->cap)
         _reserve_aux(cap);         _reserve_aux(cap);
 } }
  
 inline void Buffer::grow(size_t size, char x)  inline void Buffer::grow(Uint32 size, char x)
 { {
     size_t cap = _rep->size + size;      Uint32 cap = _rep->size + size;
  
     if (cap > _rep->cap)     if (cap > _rep->cap)
         _reserve_aux(cap);         _reserve_aux(cap);
Line 192 
Line 189 
     _rep->data[_rep->size++] = x;     _rep->data[_rep->size++] = x;
 } }
  
 inline void Buffer::append(const char* data, size_t size)  inline void Buffer::append(const char* data, Uint32 size)
 { {
     size_t cap = _rep->size + size;      Uint32 cap = _rep->size + size;
  
     if (cap > _rep->cap)     if (cap > _rep->cap)
         _reserve_aux(cap);         _reserve_aux(cap);
Line 209 
Line 206 
         _rep->size = 0;         _rep->size = 0;
 } }
  
 inline void Buffer::remove(size_t pos)  inline void Buffer::remove(Uint32 pos)
 { {
     remove(pos, 1);     remove(pos, 1);
 } }
  
 inline void Buffer::append(char c1, char c2, char c3, char c4) inline void Buffer::append(char c1, char c2, char c3, char c4)
 { {
     size_t cap = _rep->size + 4;      Uint32 cap = _rep->size + 4;
  
     if (cap > _rep->cap)     if (cap > _rep->cap)
         _reserve_aux(cap);         _reserve_aux(cap);
Line 232 
Line 229 
 inline void Buffer::append( inline void Buffer::append(
     char c1, char c2, char c3, char c4, char c5, char c6, char c7, char c8)     char c1, char c2, char c3, char c4, char c5, char c6, char c7, char c8)
 { {
     size_t cap = _rep->size + 8;      Uint32 cap = _rep->size + 8;
  
     if (cap > _rep->cap)     if (cap > _rep->cap)
         _reserve_aux(cap);         _reserve_aux(cap);


Legend:
Removed from v.1.4.2.1  
changed lines
  Added in v.1.12

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2