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 #if defined(_LUCENE_PRAGMA_ONCE) 00010 # pragma once 00011 #endif 00012 00013 CL_NS_DEF(store) 00014 00015 00016 00021 class IndexOutput:LUCENE_BASE{ 00022 bool isclosed; 00023 public: 00024 IndexOutput(); 00025 virtual ~IndexOutput(); 00026 00030 virtual void writeByte(const uint8_t b) = 0; 00031 00037 virtual void writeBytes(const uint8_t* b, const int32_t length) = 0; 00038 00042 void writeInt(const int32_t i); 00043 00049 void writeVInt(const int32_t vi); 00050 00054 void writeLong(const int64_t i); 00055 00061 void writeVLong(const int64_t vi); 00062 00066 void writeString(const TCHAR* s, const int32_t length); 00067 00074 void writeChars(const TCHAR* s, const int32_t start, const int32_t length); 00075 00077 virtual void close() = 0; 00078 00083 virtual int64_t getFilePointer() const = 0; 00084 00088 virtual void seek(const int64_t pos) = 0; 00089 00091 virtual int64_t length() = 0; 00092 00094 virtual void flush() = 0; 00095 }; 00096 00098 class BufferedIndexOutput : public IndexOutput{ 00099 public: 00100 LUCENE_STATIC_CONSTANT(int32_t, BUFFER_SIZE=LUCENE_STREAM_BUFFER_SIZE); 00101 private: 00102 uint8_t* buffer; 00103 int64_t bufferStart; // position in file of buffer 00104 int32_t bufferPosition; // position in buffer 00105 00106 public: 00107 BufferedIndexOutput(); 00108 virtual ~BufferedIndexOutput(); 00109 00113 virtual void writeByte(const uint8_t b); 00114 00120 virtual void writeBytes(const uint8_t* b, const int32_t length); 00121 00123 virtual void close(); 00124 00129 int64_t getFilePointer() const; 00130 00134 virtual void seek(const int64_t pos); 00135 00137 virtual int64_t length() = 0; 00138 00140 void flush(); 00141 00142 protected: 00148 virtual void flushBuffer(const uint8_t* b, const int32_t len) = 0; 00149 }; 00150 00151 CL_NS_END 00152 #endif