libopenraw

rawcontainer.h

00001 /*
00002  * libopenraw - rawcontainer.h
00003  *
00004  * Copyright (C) 2006-2007 Hubert Figuiere
00005  *
00006  * This library is free software: you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation, either version 3 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library.  If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00022 
00023 
00024 #ifndef _RAWCONTAINER_H_
00025 #define _RAWCONTAINER_H_
00026 
00027 #include <sys/types.h>
00028 
00029 #include <libopenraw/io.h>
00030 #include <libopenraw/types.h>
00031 
00032 
00033 namespace OpenRaw {
00034     namespace IO {
00035         class Stream;
00036     }
00037 
00038     namespace Internals {
00039 
00040         
00044         class RawContainer
00045         {
00046         public:
00048             typedef enum {
00049                 ENDIAN_NULL = 0, 
00050                 ENDIAN_BIG,      
00051                 ENDIAN_LITTLE    
00052             } EndianType;
00053 
00059             RawContainer(IO::Stream *_file, off_t offset);
00061             virtual ~RawContainer();
00062             
00063             IO::Stream *file()
00064                 {
00065                     return m_file;
00066                 }
00067             EndianType endian() const
00068                 {
00069                     return m_endian;
00070                 }
00071 
00072             bool readInt8(IO::Stream *f, int8_t & v);
00073             bool readUInt8(IO::Stream *f, uint8_t & v);
00075             bool readInt16(IO::Stream *f, int16_t & v);
00077             bool readInt32(IO::Stream *f, int32_t & v);
00079             bool readUInt16(IO::Stream *f, uint16_t & v);
00081             bool readUInt32(IO::Stream *f, uint32_t & v);
00089             size_t fetchData(void *buf, const off_t offset, const size_t buf_size);
00090 
00091         protected:
00092 
00093             RawContainer(const RawContainer&);
00094             RawContainer & operator=(const RawContainer &);
00095 
00096             void setEndian(EndianType _endian)
00097                 {
00098                     m_endian = _endian;
00099                 }
00100 
00102             IO::Stream *m_file;
00104             off_t m_offset;
00105             EndianType m_endian;
00106         };
00107         
00108     }
00109 }
00110 
00111 
00112 #endif