00001 /****************************************************************************** 00002 * 00003 * Purpose: Declaration of the PCIDSKBuffer class 00004 * 00005 ****************************************************************************** 00006 * Copyright (c) 2009 00007 * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a 00010 * copy of this software and associated documentation files (the "Software"), 00011 * to deal in the Software without restriction, including without limitation 00012 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00013 * and/or sell copies of the Software, and to permit persons to whom the 00014 * Software is furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included 00017 * in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00020 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00022 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00024 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00025 * DEALINGS IN THE SOFTWARE. 00026 ****************************************************************************/ 00027 #ifndef __INCLUDE_PCIDSKBUFFER_H 00028 #define __INCLUDE_PCIDSKBUFFER_H 00029 00030 #include "pcidsk_config.h" 00031 00032 #include <string> 00033 00034 namespace PCIDSK 00035 { 00036 /************************************************************************/ 00037 /* PCIDSKBuffer */ 00038 /* */ 00039 /* Convenience class for managing ascii headers of various */ 00040 /* sorts. Primarily for internal use. */ 00041 /************************************************************************/ 00042 00043 class PCIDSKBuffer 00044 { 00045 friend class MetadataSegment; // ? 00046 public: 00047 PCIDSKBuffer( int size = 0 ); 00048 PCIDSKBuffer( const char *src, int size ); 00049 ~PCIDSKBuffer(); 00050 00051 char *buffer; 00052 int buffer_size; 00053 00054 PCIDSKBuffer &operator=(const PCIDSKBuffer& src); 00055 00056 const char *Get( int offset, int size ); 00057 void Get( int offset, int size, std::string &target, int unpad=1 ); 00058 00059 double GetDouble( int offset, int size ); 00060 int GetInt( int offset, int size ); 00061 int64 GetInt64( int offset, int size ); 00062 uint64 GetUInt64( int offset, int size ); 00063 00064 void Put( const char *value, int offset, int size ); 00065 void Put( uint64 value, int offset, int size ); 00066 void Put( double value, int offset, int size, const char *fmt=NULL ); 00067 void Put( int value, int offset, int size ) 00068 { Put( (uint64) value, offset, size ); } 00069 00070 void SetSize( int size ); 00071 00072 private: 00073 std::string work_field; 00074 }; 00075 } // end namespace PCIDSK 00076 #endif // __INCLUDE_PCIDSKBUFFER_H