strigi/src/streams
substreamprovider.h
Go to the documentation of this file.00001 /* This file is part of Strigi Desktop Search 00002 * 00003 * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 #ifndef STRIGI_SUBSTREAMPROVIDER 00021 #define STRIGI_SUBSTREAMPROVIDER 00022 00023 #include <string> 00024 #include <map> 00025 #include "streambase.h" 00026 00027 namespace Strigi { 00028 00032 struct EntryInfo { 00038 std::string filename; 00042 std::map<std::string, std::string> properties; 00044 int64_t size; 00046 time_t mtime; 00048 enum Type { 00049 Unknown=0 , 00050 Dir=1 , 00051 File=2 00052 }; 00054 Type type; 00056 EntryInfo() :size(-1), mtime(0), type(Unknown) {} 00057 }; 00058 00067 class STREAMS_EXPORT SubStreamProvider { 00068 protected: 00070 StreamStatus m_status; 00075 std::string m_error; 00077 InputStream *m_input; 00079 InputStream *m_entrystream; 00081 EntryInfo m_entryinfo; 00082 public: 00091 SubStreamProvider(InputStream *input) 00092 : m_status(Ok) 00093 , m_input(input) 00094 , m_entrystream(0) 00095 {} 00101 virtual ~SubStreamProvider() 00102 { 00103 if (m_entrystream) { 00104 delete m_entrystream; 00105 } 00106 } 00110 StreamStatus status() const 00111 { 00112 return m_status; 00113 } 00136 virtual InputStream* nextEntry() = 0; 00140 InputStream* currentEntry() 00141 { 00142 return m_entrystream; 00143 } 00147 const EntryInfo &entryInfo() const 00148 { 00149 return m_entryinfo; 00150 } 00155 const char* error() const 00156 { 00157 return m_error.c_str(); 00158 } 00159 }; 00160 00161 } // end namespace Strigi 00162 00163 #endif
KDE 4.4 API Reference