Changeset 1038 for trunk/src/core/RpBuffer.h
- Timestamp:
- Jun 10, 2008 7:53:44 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpBuffer.h
r1030 r1038 5 5 * AUTHOR: Derrick Kearney, Purdue University 6 6 * 7 * Copyright (c) 2004-200 7Purdue Research Foundation7 * Copyright (c) 2004-2008 Purdue Research Foundation 8 8 * ---------------------------------------------------------------------- 9 9 * See the file "license.terms" for information on usage and 10 10 * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 * ======================================================================12 *13 * This code is based on the Tcl_DString facility included in the14 * Tcl source release, which includes the following copyright:15 *16 * Copyright (c) 1987-1993 The Regents of the University of California.17 * Copyright (c) 1994-1998 Sun Microsystems, Inc.18 * Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.19 *20 * This software is copyrighted by the Regents of the University of21 * California, Sun Microsystems, Inc., Scriptics Corporation,22 * and other parties. The following terms apply to all files associated23 * with the software unless explicitly disclaimed in individual files.24 *25 * The authors hereby grant permission to use, copy, modify, distribute,26 * and license this software and its documentation for any purpose, provided27 * that existing copyright notices are retained in all copies and that this28 * notice is included verbatim in any distributions. No written agreement,29 * license, or royalty fee is required for any of the authorized uses.30 * Modifications to this software may be copyrighted by their authors31 * and need not follow the licensing terms described here, provided that32 * the new terms are clearly indicated on the first page of each file where33 * they apply.34 *35 * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY36 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES37 * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY38 * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE39 * POSSIBILITY OF SUCH DAMAGE.40 *41 * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,42 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,43 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE44 * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE45 * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR46 * MODIFICATIONS.47 *48 * GOVERNMENT USE: If you are acquiring this software on behalf of the49 * U.S. government, the Government shall have only "Restricted Rights"50 * in the software and related documentation as defined in the Federal·51 * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you52 * are acquiring the software on behalf of the Department of Defense, the53 * software shall be classified as "Commercial Computer Software" and the54 * Government shall have only "Restricted Rights" as defined in Clause55 * 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the56 * authors grant the U.S. Government and others acting in its behalf57 * permission to use and distribute the software in accordance with the58 * terms specified in this license.·59 *60 11 * ====================================================================== 61 12 */ … … 64 15 #define RAPPTURE_BUFFER_H 65 16 66 #define RP_BUFFER_MIN_SIZE 20067 68 17 #include <RpOutcome.h> 18 #include <RpSimpleBuffer.h> 69 19 70 20 #ifdef __cplusplus … … 79 29 namespace Rappture { 80 30 81 class SimpleBuffer {82 public:83 SimpleBuffer();84 SimpleBuffer(const char* bytes, int nbytes=-1);85 SimpleBuffer(const SimpleBuffer& b);86 SimpleBuffer& operator=(const SimpleBuffer& b);87 SimpleBuffer operator+(const SimpleBuffer& b) const;88 SimpleBuffer& operator+=(const SimpleBuffer& b);89 virtual ~SimpleBuffer();90 91 const char* bytes() const;92 unsigned int size() const;93 94 SimpleBuffer& clear();95 int append(const char* bytes, int nbytes=-1);96 int read(const char* bytes, int nbytes);97 int seek(int offset, int whence);98 int tell();99 SimpleBuffer& rewind();100 101 bool good() const;102 bool bad() const;103 bool eof() const;104 105 SimpleBuffer& move(SimpleBuffer& b);106 107 protected:108 109 void bufferInit();110 void bufferFree();111 112 private:113 114 /// Pointer to the memory that holds our buffer's data115 char* _buf;116 117 /// Position offset within the buffer's memory118 unsigned int _pos;119 120 /// Size of the used memory in the buffer121 unsigned int _size;122 123 /// Total space available in the buffer124 unsigned int _spaceAvl;125 126 /// State of the last file like operation.127 bool _fileState;128 };129 31 130 32 /** … … 138 40 public: 139 41 Buffer(); 42 Buffer(int nbytes); 140 43 Buffer(const char* bytes, int nbytes=-1); 141 44 Buffer(const Buffer& buffer);
Note: See TracChangeset
for help on using the changeset viewer.