CLucene - a full-featured, c++ search engine
API Documentation
00001 /*------------------------------------------------------------------------------ 00002 * Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team 00003 * 00004 * Distributable under the terms of either the Apache License (Version 2.0) or 00005 * the GNU Lesser General Public License, as specified in the COPYING file. 00006 ------------------------------------------------------------------------------*/ 00007 #ifndef _lucene_store_IndexOutput_ 00008 #define _lucene_store_IndexOutput_ 00009 00010 CL_NS_DEF(store) 00011 00012 class IndexInput; 00013 00019 class IndexOutput:LUCENE_BASE{ 00020 bool isclosed; 00021 public: 00022 IndexOutput(); 00023 virtual ~IndexOutput(); 00024 00028 virtual void writeByte(const uint8_t b) = 0; 00029 00035 virtual void writeBytes(const uint8_t* b, const int32_t length) = 0; 00036 00040 void writeInt(const int32_t i); 00041 00047 void writeVInt(const int32_t vi); 00048 00052 void writeLong(const int64_t i); 00053 00059 void writeVLong(const int64_t vi); 00060 00064 void writeString(const TCHAR* s, const int32_t length); 00065 00072 void writeChars(const TCHAR* s, const int32_t start, const int32_t length); 00073 00075 virtual void close() = 0; 00076 00081 virtual int64_t getFilePointer() const = 0; 00082 00086 virtual void seek(const int64_t pos) = 0; 00087 00089 virtual int64_t length() const = 0; 00090 00092 virtual void flush() = 0; 00093 00094 private: 00095 LUCENE_STATIC_CONSTANT(int32_t, COPY_BUFFER_SIZE = 16384); 00096 uint8_t* copyBuffer; 00097 00098 public: 00100 void copyBytes(CL_NS(store)::IndexInput* input, int64_t numBytes); 00101 }; 00102 00104 class BufferedIndexOutput : public IndexOutput{ 00105 public: 00106 LUCENE_STATIC_CONSTANT(int32_t, BUFFER_SIZE=16384); 00107 private: 00108 uint8_t* buffer; 00109 int64_t bufferStart; // position in file of buffer 00110 int32_t bufferPosition; // position in buffer 00111 00112 public: 00113 BufferedIndexOutput(); 00114 virtual ~BufferedIndexOutput(); 00115 00119 virtual void writeByte(const uint8_t b); 00120 00126 virtual void writeBytes(const uint8_t* b, const int32_t length); 00127 00129 virtual void close(); 00130 00135 int64_t getFilePointer() const; 00136 00140 virtual void seek(const int64_t pos); 00141 00143 virtual int64_t length() const = 0; 00144 00146 void flush(); 00147 00148 protected: 00154 virtual void flushBuffer(const uint8_t* b, const int32_t len) = 0; 00155 }; 00156 00157 CL_NS_END 00158 #endif