diff options
| author | 2008-08-29 23:36:08 +0000 | |
|---|---|---|
| committer | 2008-08-29 23:36:08 +0000 | |
| commit | 2859af2e4ecc2039958e63d61b4b2960402cb5a3 (patch) | |
| tree | dc273ee7afa7f3ff28e0ca7dc715f3ec6bfeb502 | |
| parent | added Doxygen comments (diff) | |
| download | KVIrc-2859af2e4ecc2039958e63d61b4b2960402cb5a3.tar.gz KVIrc-2859af2e4ecc2039958e63d61b4b2960402cb5a3.tar.bz2 KVIrc-2859af2e4ecc2039958e63d61b4b2960402cb5a3.zip | |
added return values
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2359 17fca916-40b9-46aa-a4ea-0a15b648b75c
| -rw-r--r-- | TODO-doxygen | 1 | ||||
| -rw-r--r-- | src/kvilib/config/kvi_buildinfo.h | 107 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_error.cpp | 5 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_error.h | 18 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_pointerhashtable.h | 34 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_pointerlist.h | 871 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_qcstring.h | 1 | ||||
| -rw-r--r-- | src/kvilib/core/kvi_qstring.h | 17 | ||||
| -rw-r--r-- | src/kvilib/file/kvi_fileutils.h | 32 | ||||
| -rw-r--r-- | src/kvilib/file/kvi_packagefile.h | 41 |
10 files changed, 660 insertions, 467 deletions
diff --git a/TODO-doxygen b/TODO-doxygen index 46daf09dd..798987167 100644 --- a/TODO-doxygen +++ b/TODO-doxygen @@ -83,7 +83,6 @@ core/kvi_pointerhashtable.h - incomplete from line 42 to 283 core/kvi_malloc.h core/kvi_bswap.h - incomplete from line 40 core/kvi_heapobject.h - incomplete from line 75 to 80 -core/kvi_error.h - incomplete from line 192 to 194 core/kvi_strasm.h core/kvi_string.h core/kvi_qstring.h - incomplete lines 56-61, 70-75 diff --git a/src/kvilib/config/kvi_buildinfo.h b/src/kvilib/config/kvi_buildinfo.h index 1aa5f1328..1a97831f4 100644 --- a/src/kvilib/config/kvi_buildinfo.h +++ b/src/kvilib/config/kvi_buildinfo.h @@ -25,77 +25,98 @@ // //============================================================================= -/// \file kvi_buildinfo.h -/// \author Szymon Stefanek -/// \brief Useful functions which returns compilation and runtime info +/** +* \file kvi_buildinfo.h +* \author Szymon Stefanek +* \brief Useful functions which returns compilation and runtime info +*/ #include "kvi_settings.h" #include "kvi_sourcesdate.h" #include <QString> -/// -/// \namespace KviBuildInfo -/// \brief This namespace contains informations gathered at KVIrc build time. -/// This, in fact, is the last time that "cmake" ran and successfully generated the -/// kvilib Makefile. Since kvilib is generally built with the kvirc -/// executable, then you can assume that the information returned -/// from this namespace strictly applies also to kvirc. -/// +/** +* \namespace KviBuildInfo +* \brief This namespace contains informations gathered at KVIrc build time. +* This, in fact, is the last time that "cmake" ran and successfully generated the +* kvilib Makefile. Since kvilib is generally built with the kvirc +* executable, then you can assume that the information returned +* from this namespace strictly applies also to kvirc. +*/ namespace KviBuildInfo { - /// Retrieve the latest kvilib/kvirc build date. + /** + * \brief Retrieve the latest kvilib/kvirc build date. + * \return QString + */ extern KVILIB_API QString buildDate(); - /// Returns the date tag applied to the currently compiled SVN sources. + /** + * \brief Returns the date tag applied to the currently compiled SVN sources. + * \return QString + */ extern KVILIB_API QString buildSourcesDate(); - /// Returns the build command used by cmake to create the KVIrc executable. + /** + * \brief Returns the build command used by cmake to create the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildCommand(); - /// - /// \brief Returns the build flags - /// The build flags were worked out by CMake at compilation time. - /// + /** + * \brief Returns the build flags + * The build flags were worked out by CMake at compilation time. + * \return QString + */ extern KVILIB_API QString buildFlags(); - /// - /// \brief Returns a description of the system - /// The system refers to the one used to build the KVIrc executable. - /// + /** + * \brief Returns a description of the system + * The system refers to the one used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildSystem(); - /// - /// \brief Returns the name part of the system - /// The system name refers to the one used to build the KVIrc executable. - /// + /** + * \brief Returns the name part of the system + * The system name refers to the one used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildSystemName(); - /// - /// \brief Returns the version part of the system - /// The system version refers to the one used to build the KVIrc executable. - /// + /** + * \brief Returns the version part of the system + * The system version refers to the one used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildSystemVersion(); - /// - /// \brief Returns a description of the CPU - /// The CPU refers to the one used to build the KVIrc executable. - /// + /** + * \brief Returns a description of the CPU + * The CPU refers to the one used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildCPU(); - /// - /// \brief Returns a description of the compiler - /// The compiler refers to the one used to build the KVIrc executable. - /// + /** + * \brief Returns a description of the compiler + * The compiler refers to the one used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildCompiler(); - /// - /// \brief Returns a description of the compiler flags - /// The flags refer to the ones used to build the KVIrc executable. - /// + /** + * \brief Returns a description of the compiler flags + * The flags refer to the ones used to build the KVIrc executable. + * \return QString + */ extern KVILIB_API QString buildCompilerFlags(); - /// Returns the SVN revision number of the local repository + /** + * \brief Returns the SVN revision number of the local repository + * \return QString + */ extern KVILIB_API QString buildRevision(); }; diff --git a/src/kvilib/core/kvi_error.cpp b/src/kvilib/core/kvi_error.cpp index c627d62c6..071476c03 100644 --- a/src/kvilib/core/kvi_error.cpp +++ b/src/kvilib/core/kvi_error.cpp @@ -192,7 +192,7 @@ namespace KviError #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) switch(iErrNo) { - case EBADF: return KviError_badFileDescriptor; break; + case EBADF: return KviError_badFileDescriptor; break; case WSAEINVAL: case WSAEFAULT: case EFAULT: return KviError_outOfAddressSpace; break; @@ -200,9 +200,8 @@ namespace KviError case WSAENOTSOCK: return KviError_kernelNetworkingPanic; break; case WSAETIMEDOUT: return KviError_connectionTimedOut; break; case WSAENETUNREACH: return KviError_networkUnreachable; break; - case EPIPE: return KviError_brokenPipe; break; + case EPIPE: return KviError_brokenPipe; break; case WSAENOTCONN: return KviError_socketNotConnected; break; - case WSAEACCES: return KviError_accessDenied; break; case WSAEADDRINUSE: return KviError_addressAlreadyInUse; break; case WSAEADDRNOTAVAIL: return KviError_cantAssignRequestedAddress; break; diff --git a/src/kvilib/core/kvi_error.h b/src/kvilib/core/kvi_error.h index 2755b7142..5d47d7138 100644 --- a/src/kvilib/core/kvi_error.h +++ b/src/kvilib/core/kvi_error.h @@ -186,11 +186,29 @@ /** * \namespace KviError +* \brief This namespace handle the error codes */ namespace KviError { + /** + * \brief Returns the description of the error + * \param iErrorCode The code number of the error + * \return QString + */ KVILIB_API QString getDescription(int iErrorCode); + + /** + * \brief Returns an untranslated description of the error + * \param iErrorCode The code number of the error + * \return const char * + */ KVILIB_API const char * getUntranslatedDescription(int iErrorCode); + + /** + * \brief Gets system errors and returns their code number + * \param iErrNo The code number of the system error + * \return int + */ KVILIB_API int translateSystemError(int iErrNo); }; diff --git a/src/kvilib/core/kvi_pointerhashtable.h b/src/kvilib/core/kvi_pointerhashtable.h index 334da375a..b2adf30a6 100644 --- a/src/kvilib/core/kvi_pointerhashtable.h +++ b/src/kvilib/core/kvi_pointerhashtable.h @@ -347,6 +347,7 @@ public: * Returns NULL if no such item exists in the hash table. * Places the hash table iterator at the position of the item found. * \param hKey The key to find + * \return T * */ T * find(const Key & hKey) { @@ -365,19 +366,26 @@ public: * Places the hash table iterator at the position of the item found. * This is an alias to find(). * \param hKey The key to find + * \return T * */ T * operator[](const Key & hKey) { return find(hKey); } - /// Returns the number of items in this hash table + /** + * \brief Returns the number of items in this hash table + * \return unsigned int + */ unsigned int count() const { return m_uCount; } - /// Returns true if the hash table is empty + /** + * \brief Returns true if the hash table is empty + * \return bool + */ bool isEmpty() const { return m_uCount == 0; @@ -390,6 +398,7 @@ public: * The hash table iterator is placed at the newly inserted item. * \param hKey The key where to insert data * \param pData The data to insert + * \return void */ void insert(const Key & hKey, T * pData) { @@ -426,6 +435,7 @@ public: * This is just an alias to insert() with a different name. * \param hKey The key where to insert data * \param pData The new data to insert + * \return void */ void replace(const Key & hKey, T * pData) { @@ -438,6 +448,7 @@ public: * item was found and removed and false if it wasn't found. * Invalidates the hash table iterator. * \param hKey The key where to remove the pointer + * \return bool */ bool remove(const Key & hKey) { @@ -468,6 +479,7 @@ public: * pointer was found and false otherwise. * Invalidates the hash table iterator. * \param pRef The pointer to remove the first occurence + * \return bool */ bool removeRef(const T * pRef) { @@ -500,6 +512,7 @@ public: * \brief Removes all the items from the hash table. * The items are deleted if autodeletion is enabled. * Invalidates the hash table iterator. + * \return void */ void clear() { @@ -525,6 +538,7 @@ public: * Returns its hash table entry, if found, and NULL otherwise. * The hash table iterator is placed at the item found. * \param pRef The pointer to search + * \return KviPointerHashTableEntry<Key,T> * */ KviPointerHashTableEntry<Key,T> * findRef(const T * pRef) { @@ -545,6 +559,7 @@ public: * \brief Returns the entry pointed by the hash table iterator. * This function must be preceeded by a call to firstEntry(), first() * or findRef(). + * \return KviPointerHashTableEntry<Key,T> * */ KviPointerHashTableEntry<Key,T> * currentEntry() { @@ -553,7 +568,10 @@ public: return 0; } - /// Places the hash table iterator at the first entry and returns it. + /** + * \brief Places the hash table iterator at the first entry and returns it. + * \return KviPointerHashTableEntry<Key,T> * + */ KviPointerHashTableEntry<Key,T> * firstEntry() { m_uIteratorIdx = 0; @@ -569,6 +587,7 @@ public: * \brief Places the hash table iterator at the next entry and returns it. * This function must be preceeded by a call to firstEntry(), first() * or findRef(). + * \return KviPointerHashTableEntry<Key,T> * */ KviPointerHashTableEntry<Key,T> * nextEntry() { @@ -597,6 +616,7 @@ public: * \brief Returns the data value pointer pointed by the hash table iterator. * This function must be preceeded by a call to firstEntry(), first() * or findRef(). + * \return T * */ T * current() { @@ -614,6 +634,7 @@ public: * \brief Returns the key pointed by the hash table iterator. * This function must be preceeded by a call to firstEntry(), first() * or findRef(). + * \return const Key & */ const Key & currentKey() { @@ -629,6 +650,7 @@ public: /** \brief Places the hash table iterator at the first entry * It returns the associated data value pointer. + * \return T * */ T * first() { @@ -647,6 +669,7 @@ public: * \brief Places the hash table iterator at the next entry and returns the associated data value pointer. * This function must be preceeded by a call to firstEntry(), first() * or findRef(). + * \return T * */ T * next() { @@ -682,6 +705,7 @@ public: * Does not change autodelete flag: make sure you don't delete the * items twice :) * \param t The data to copy + * \return void */ void copyFrom(KviPointerHashTable<Key,T> & t) { @@ -694,6 +718,7 @@ public: * \brief Inserts a complete shallow copy of the data contained in t. * The hash table iterator is invalidated. * \param t The data to insert + * \return void */ void insert(KviPointerHashTable<Key,T> & t) { @@ -705,6 +730,7 @@ public: * \brief Enables or disabled the autodeletion feature. * Items are deleted upon removal when the feature is enabled. * \param bAutoDelete Set the autodelete state + * \return void */ void setAutoDelete(bool bAutoDelete) { @@ -717,6 +743,7 @@ public: * \param uSize The number of hash buckets: does NOT necesairly need to be prime * \param bCaseSensitive Are the key comparisons case sensitive ? * \param bDeepCopyKeys Do we need to mantain deep copies of keys ? + * \return KviPointerHashTable */ KviPointerHashTable(unsigned int uSize = 32, bool bCaseSensitive = true, bool bDeepCopyKeys = true) { @@ -733,6 +760,7 @@ public: * \brief First creates an empty hash table and then inserts a copy of all the item pointers present in t. * The autodelete feature is automatically disabled (take care!). * \param t The data to copy + * \return KviPointerHashTable */ KviPointerHashTable(KviPointerHashTable<Key,T> & t) { diff --git a/src/kvilib/core/kvi_pointerlist.h b/src/kvilib/core/kvi_pointerlist.h index ba6c4fdfd..9302d7532 100644 --- a/src/kvilib/core/kvi_pointerlist.h +++ b/src/kvilib/core/kvi_pointerlist.h @@ -55,9 +55,10 @@ template<typename T> class KviPointerListIterator; #define NULL 0 #endif -/// -/// \class KviPointerListNode -/// \brief A KviPointerList node pointers. +/** +* \class KviPointerListNode +* \brief A KviPointerList node pointers. +*/ class KviPointerListNode { public: @@ -66,152 +67,159 @@ public: KviPointerListNode * m_pNext; }; -/// -/// \class KviPointerListIterator -/// \brief A fast KviPointerList iterator. -/// -/// This class allows traversing the list sequentially. -/// Multilpe iterators can traverse the list at the same time. -/// -/// Iteration example 1: -/// -/// \verbatim -/// KviPointerListIterator<T> it(list); -/// for(bool b = it.moveFirst(); b; b = it.moveNext()) -/// { -/// T * pData = it.data(); -/// doSomethingWithData(pData); -/// } -/// \endverbatim -/// -/// Iteration example 2: -/// -/// \verbatim -/// KviPointerListIterator<T> it(list); -/// if(it.moveFirst()) -/// { -/// do { -/// T * pData = it.data(); -/// doSomethingWithData(pData); -/// } while(it.moveNext()); -/// } -/// \endverbatim -/// -/// Iteration example 3: -/// -/// \verbatim -/// KviPointerListIterator<T> it(list.iteratorAt(10)); -/// if(it.isValid()) -/// { -/// do { -/// T * pData = it.data(); -/// doSomethingWithData(pData); -/// while(it.movePrev()); -/// } -/// \endverbatim -/// -/// Please note that you must NOT remove any item from -/// the list when using the iterators. An iterator pointing -/// to a removed item will crash your application if you use it. -/// The following code will NOT work (and crash): -/// -/// \verbatim -/// KviPointerList<T> l; -/// l.append(new KviStr("x")); -/// l.append(new KviStr("y")); -/// KviPointerListIterator<T> it(l); -/// it.moveFirst(); -/// l.removeFirst(); -/// KviStr * tmp = it.data(); <-- this will crash -/// \endverbatim -/// -/// In the rare cases in that you need to remove items -/// while traversing the list you should put them -/// in a temporary list and remove them after the iteration. -/// -/// I've choosen this way because usually you don't modify -/// the list while traversing it and a fix for this -/// would add a constant overhead to several list operation. -/// You just must take care of it yourself. -/// -/// \warning This class is not thread safe by itself. -/// +/** +* \class KviPointerListIterator +* \brief A fast KviPointerList iterator. +* +* This class allows traversing the list sequentially. +* Multilpe iterators can traverse the list at the same time. +* +* Iteration example 1: +* +* \verbatim +* KviPointerListIterator<T> it(list); +* for(bool b = it.moveFirst(); b; b = it.moveNext()) +* { +* T * pData = it.data(); +* doSomethingWithData(pData); +* } +* \endverbatim +* +* Iteration example 2: +* +* \verbatim +* KviPointerListIterator<T> it(list); +* if(it.moveFirst()) +* { +* do { +* T * pData = it.data(); +* doSomethingWithData(pData); +* } while(it.moveNext()); +* } +* \endverbatim +* +* Iteration example 3: +* +* \verbatim +* KviPointerListIterator<T> it(list.iteratorAt(10)); +* if(it.isValid()) +* { +* do { +* T * pData = it.data(); +* doSomethingWithData(pData); +* while(it.movePrev()); +* } +* \endverbatim +* +* Please note that you must NOT remove any item from +* the list when using the iterators. An iterator pointing +* to a removed item will crash your application if you use it. +* The following code will NOT work (and crash): +* +* \verbatim +* KviPointerList<T> l; +* l.append(new KviStr("x")); +* l.append(new KviStr("y")); +* KviPointerListIterator<T> it(l); +* it.moveFirst(); +* l.removeFirst(); +* KviStr * tmp = it.data(); <-- this will crash +* \endverbatim +* +* In the rare cases in that you need to remove items +* while traversing the list you should put them +* in a temporary list and remove them after the iteration. +* +* I've choosen this way because usually you don't modify +* the list while traversing it and a fix for this +* would add a constant overhead to several list operation. +* You just must take care of it yourself. +* +* \warning This class is not thread safe by itself. +*/ template<typename T> class KviPointerListIterator { protected: KviPointerList<T> * m_pList; KviPointerListNode * m_pNode; public: - /// - /// \brief Creates an iterator copy. - /// The new iterator points exactly to the item pointed by src. - /// \param src The source item to point to - /// + /** + * \brief Creates an iterator copy. + * The new iterator points exactly to the item pointed by src. + * \param src The source item to point to + * \return KviPointerListIterator + */ KviPointerListIterator(const KviPointerListIterator<T> & src) { m_pList = src.m_pList; m_pNode = src.m_pNode; } - /// - /// \brief Creates an iterator for the list l. - /// The iterator points to the first list item, if any. - /// \param l The source list to point to - /// + /** + * \brief Creates an iterator for the list l. + * The iterator points to the first list item, if any. + * \param l The source list to point to + * \return KviPointerListIterator + */ KviPointerListIterator(KviPointerList<T> & l) { m_pList = (KviPointerList<T> *)&l; m_pNode = m_pList->m_pHead; } - /// - /// \brief Creates an iterator for the list l. - /// The iterator points to the specified list node. - /// \param l The source list - /// \param pNode The list node to point to - /// + /** + * \brief Creates an iterator for the list l. + * The iterator points to the specified list node. + * \param l The source list + * \param pNode The list node to point to + * \return KviPointerListIterator + */ KviPointerListIterator(KviPointerList<T> & l,KviPointerListNode * pNode) { m_pList = (KviPointerList<T> *)&l; m_pNode = pNode; } - /// - /// \brief Creates an iterator copy. - /// The new iterator points exactly to the item pointed by src. - /// \param src The source item to copy - /// + /** + * \brief Creates an iterator copy. + * The new iterator points exactly to the item pointed by src. + * \param src The source item to copy + * \return void + */ void operator = (const KviPointerListIterator<T> & src) { m_pList = src.m_pList; m_pNode = src.m_pNode; } public: - /// - /// \brief Moves the iterator to the first element of the list. - /// Returns true in case of success or false if the list is empty. - /// + /** + * \brief Moves the iterator to the first element of the list. + * Returns true in case of success or false if the list is empty. + * \return bool + */ bool moveFirst() { m_pNode = m_pList->m_pHead; return m_pNode != NULL; } - /// - /// \brief Moves the iterator to the last element of the list. - /// Returns true in case of success or false if the list is empty. - /// + /** + * \brief Moves the iterator to the last element of the list. + * Returns true in case of success or false if the list is empty. + * \return bool + */ bool moveLast() { m_pNode = m_pList->m_pTail; return m_pNode != NULL; } - /// - /// \brief Moves the iterator to the next element of the list. - /// The iterator must be actually valid for this function to work. - /// Returns true in case of success or false if there is no next item. - /// + /** + * \brief Moves the iterator to the next element of the list. + * The iterator must be actually valid for this function to work. + * Returns true in case of success or false if there is no next item. + * \return bool + */ bool moveNext() { if(!m_pNode)return false; @@ -219,12 +227,13 @@ public: return m_pNode != NULL; } - /// - /// \brief Moves the iterator to the next element of the list. - /// The iterator must be actually valid for this operator to work. - /// Returns true in case of success or false if there is no next item. - /// This is just a convenient alias to moveNext(). - /// + /** + * \brief Moves the iterator to the next element of the list. + * The iterator must be actually valid for this operator to work. + * Returns true in case of success or false if there is no next item. + * This is just a convenient alias to moveNext(). + * \return bool + */ bool operator ++() { if(!m_pNode)return false; @@ -232,12 +241,13 @@ public: return m_pNode != NULL; } - /// - /// \brief Moves the iterator to the previous element of the list. - /// The iterator must be actually valid for this function to work. - /// Returns true in case of success or false if there is no previous - /// item. - /// + /** + * \brief Moves the iterator to the previous element of the list. + * The iterator must be actually valid for this function to work. + * Returns true in case of success or false if there is no previous + * item. + * \return bool + */ bool movePrev() { if(!m_pNode)return false; @@ -245,13 +255,14 @@ public: return m_pNode != NULL; } - /// - /// \brief Moves the iterator to the previous element of the list. - /// The iterator must be actually valid for this operator to work. - /// Returns true in case of success or false if there is no previous - /// item. - /// This is just a convenient alias to movePrev(). - /// + /** + * \brief Moves the iterator to the previous element of the list. + * The iterator must be actually valid for this operator to work. + * Returns true in case of success or false if there is no previous + * item. + * This is just a convenient alias to movePrev(). + * \return bool + */ bool operator --() { if(!m_pNode)return false; @@ -259,79 +270,82 @@ public: return m_pNode != NULL; } - /// - /// \brief Returs the value pointed by the iterator. - /// If the iterator is not valid, returns NULL. - /// + /** + * \brief Returs the value pointed by the iterator. + * If the iterator is not valid, returns NULL. + * \return T * + */ T * current() { return m_pNode ? (T *)(m_pNode->m_pData) : NULL; } - /// - /// \brief Returs the value pointed by the iterator. - /// If the iterator is not valid, returns NULL. - /// This is just an alias to current(). - /// + /** + * \brief Returs the value pointed by the iterator. + * If the iterator is not valid, returns NULL. + * This is just an alias to current(). + * \return T * + */ T * operator *() { return m_pNode ? (T *)(m_pNode->m_pData) : NULL; } - /// - /// \brief Returns true if this iterator points to a valid element - /// Returns false otherwise. - /// + /** + * \brief Returns true if this iterator points to a valid element + * Returns false otherwise. + * \return bool + */ bool isValid() { return m_pNode != NULL; } }; -/// -/// \class KviPointerList -/// \brief A template double linked list of pointers. -/// -/// The main advantage of this type of list is speed. -/// Insertion of pointers is very fast when compared to the typical "copy -/// constructor" call used in the "plain type" template list implementations. -/// -/// Iterating over pointers is also very fast and this class contains an -/// internal iterator that allows to write loops in a compact and clean way. -/// See the first(), next(), current() and findRef() functions for the -/// description of this feature. -/// -/// There is also a non-const external iterator that you can use to traverse -/// the list concurrently. -/// There is no const iterator (and no const access methods) since the list -/// provides the autoDelete() method which vould implicitly violate -/// constness. -/// If you have to deal with const objects then you need to use a QList -/// instead. -/// -/// Your objects also do not need to support copy constructors or >= -/// operators. -/// This class will work fine without them as opposed to a plain QList. -/// -/// This class also supports automatic deletion of the inseted items. -/// See the setAutoDelete() and autoDelete() members for the description of -/// the feature. -/// -/// Typcal usage: -/// -/// \verbatim -/// KviPointerList<MyClass> list(); -/// list.append(new MyClass()); -/// list.append(new MyClass()); -/// ... -/// for(MyClass * c = list.first(); c; c = list.next()) doSomethingWith(c); -/// delete list; // autodelete is set to true in the constructor -/// \endverbatim -/// -/// \warning This class is absolutely NOT thread safe. You must protect -/// concurrent access from multiple threads by using an external -/// synchronization tool (such as KviMutex). -/// +/** +* \class KviPointerList +* \brief A template double linked list of pointers. +* +* The main advantage of this type of list is speed. +* Insertion of pointers is very fast when compared to the typical "copy +* constructor" call used in the "plain type" template list implementations. +* +* Iterating over pointers is also very fast and this class contains an +* internal iterator that allows to write loops in a compact and clean way. +* See the first(), next(), current() and findRef() functions for the +* description of this feature. +* +* There is also a non-const external iterator that you can use to traverse +* the list concurrently. +* There is no const iterator (and no const access methods) since the list +* provides the autoDelete() method which vould implicitly violate +* constness. +* If you have to deal with const objects then you need to use a QList +* instead. +* +* Your objects also do not need to support copy constructors or >= +* operators. +* This class will work fine without them as opposed to a plain QList. +* +* This class also supports automatic deletion of the inseted items. +* See the setAutoDelete() and autoDelete() members for the description of +* the feature. +* +* Typcal usage: +* +* \verbatim +* KviPointerList<MyClass> list(); +* list.append(new MyClass()); +* list.append(new MyClass()); +* ... +* for(MyClass * c = list.first(); c; c = list.next()) doSomethingWith(c); +* delete list; // autodelete is set to true in the constructor +* \endverbatim +* +* \warning This class is absolutely NOT thread safe. You must protect +* concurrent access from multiple threads by using an external +* synchronization tool (such as KviMutex). +*/ template<typename T> class KviPointerList { friend class KviPointerListIterator<T>; @@ -344,14 +358,15 @@ protected: unsigned int m_uCount; //< the count of items in the list protected: - /// - /// \brief Inserts the item d before the item ref - /// If ref is not found in the list, it inserts d at the beginning - /// Also sets the current iteration pointer to the newly inserted - /// item - /// \param ref The source list node - /// \param d The item to insert - /// + /** + * \brief Inserts the item d before the item ref + * If ref is not found in the list, it inserts d at the beginning + * Also sets the current iteration pointer to the newly inserted + * item + * \param ref The source list node + * \param d The item to insert + * \return void + */ void insertBeforeSafe(KviPointerListNode * ref, const T * d) { m_pAux = ref; @@ -369,11 +384,12 @@ protected: m_uCount++; } - /// - /// Grabs the first element from the list src - /// and puts it as the first element of this list. - /// \param src The source list - /// + /** + * Grabs the first element from the list src + * and puts it as the first element of this list. + * \param src The source list + * \return void + */ void grabFirstAndPrepend(KviPointerList<T> * src) { KviPointerListNode * pNewHead = src->m_pHead; @@ -403,9 +419,10 @@ protected: src->m_uCount--; } - /// - /// \brief Removes the current iteration item assuming that it is valid. - /// + /** + * \brief Removes the current iteration item assuming that it is valid. + * \return void + */ void removeCurrentSafe() { if(m_pAux->m_pPrev) @@ -425,12 +442,13 @@ protected: } public: - /// - /// \brief Inserts the list src inside this list - /// It respects the sort order. - /// The src list elements are removed. - /// \param src The list to insert - /// + /** + * \brief Inserts the list src inside this list + * It respects the sort order. + * The src list elements are removed. + * \param src The list to insert + * \return void + */ void merge(KviPointerList<T> * src) { m_pAux = m_pHead; @@ -475,10 +493,11 @@ public: src->m_uCount = 0; } - /// - /// \brief Swap the lists - /// \param src The list to swap with - /// + /** + * \brief Swap the lists + * \param src The list to swap with + * \return void + */ void swap(KviPointerList<T> * src) { KviPointerListNode * n = m_pHead; @@ -493,13 +512,14 @@ public: } - /// - /// \brief Sorts this list in ascending order. - /// There must be an int kvi_compare(const T *p1, const T *p2) - /// function which returns a value less than, equal to or greater - /// than zero when the item p1 is considered lower than, equal to or - /// greater than p2. - /// + /** + * \brief Sorts this list in ascending order. + * There must be an int kvi_compare(const T *p1, const T *p2) + * function which returns a value less than, equal to or greater + * than zero when the item p1 is considered lower than, equal to or + * greater than p2. + * \return void + */ void sort() { if(m_uCount < 2)return; @@ -527,15 +547,16 @@ public: swap(fill-1); } - /// - /// \brief Inserts the item respecting the sorting order inside the list. - /// The list itself must be already sorted for this to work - /// correctly. - /// There must be a int kvi_compare(const T *p1, const T * p2) that - /// returns a value less than, equal to or greater than zero when the - /// item p1 is considered lower than, equal to or greater than p2. - /// \param t The item to insert - /// + /** + * \brief Inserts the item respecting the sorting order inside the list. + * The list itself must be already sorted for this to work + * correctly. + * There must be a int kvi_compare(const T *p1, const T * p2) that + * returns a value less than, equal to or greater than zero when the + * item p1 is considered lower than, equal to or greater than p2. + * \param t The item to insert + * \return void + */ void inSort(T * t) { KviPointerListNode * x = m_pHead; @@ -544,27 +565,30 @@ public: else insertBeforeSafe(x,t); } - /// - /// \brief Returns true if the list is empty - /// + /** + * \brief Returns true if the list is empty + * \return bool + */ bool isEmpty() const { return (m_pHead == NULL); } - /// - /// \brief Returns the count of the items in the list - /// + /** + * \brief Returns the count of the items in the list + * \return unsigned int + */ unsigned int count() const { return m_uCount; } - /// - /// \brief Returns the first item in the list - /// Sets the iteration pointer to the first item in the list and - /// returns that item (or 0 if the list is empty) - /// + /** + * \brief Returns the first item in the list + * Sets the iteration pointer to the first item in the list and + * returns that item (or 0 if the list is empty) + * \return T * + */ T * first() { if(!m_pHead) @@ -576,11 +600,12 @@ public: return (T *)(m_pAux->m_pData); } - /// - /// \brief Removes the first element from the list - /// It returns the item to the caller. This function obviously never - /// deletes the item (regadless of autoDeletion()). - /// + /** + * \brief Removes the first element from the list + * It returns the item to the caller. This function obviously never + * deletes the item (regadless of autoDeletion()). + * \return T * + */ T * takeFirst() { if(!m_pHead)return NULL; @@ -599,19 +624,21 @@ public: return pData; } - /// - /// \brief Returns an iterator pointing to the first item of the list. - /// + /** + * \brief Returns an iterator pointing to the first item of the list. + * \return KviPointerListIterator<T> + */ KviPointerListIterator<T> iteratorAtFirst() { return KviPointerListIterator<T>(*this,m_pHead); } - /// - /// \brief Returns the last item in the list - /// Sets the iteration pointer to the last item in the list - /// and returns that item (or 0 if the list is empty) - /// + /** + * \brief Returns the last item in the list + * Sets the iteration pointer to the last item in the list + * and returns that item (or 0 if the list is empty) + * \return T * + */ T * last() { if(!m_pTail) @@ -623,54 +650,58 @@ public: return (T *)(m_pAux->m_pData); } - /// - /// \brief Returns an iterator pointing to the first item of the list. - /// + /** + * \brief Returns an iterator pointing to the first item of the list. + * \return KviPointerListIterator<T> + */ KviPointerListIterator<T> iteratorAtLast() { return KviPointerListIterator<T>(*this,m_pTail); } - /// - /// \brief Returns the current iteration item - /// A call to this function MUST be preceded by a call to - /// first(),last(),at() or findRef() - /// + /** + * \brief Returns the current iteration item + * A call to this function MUST be preceded by a call to + * first(),last(),at() or findRef() + * \return T * + */ T * current() { return (T *)(m_pAux->m_pData); } - /// - /// \brief Returns the current iteration item - /// A call to this function should be preceded by a call to - /// first(),last(),at() or findRef(). - /// This function will return a NULL pointer if the current item has - /// been invalidated due to a remove operation. - /// + /** + * \brief Returns the current iteration item + * A call to this function should be preceded by a call to + * first(),last(),at() or findRef(). + * This function will return a NULL pointer if the current item has + * been invalidated due to a remove operation. + * \return T * + */ T * safeCurrent() { return m_pAux ? (T *)(m_pAux->m_pData) : NULL; } - - /// - /// \brief Returns an iterator pointing to the current item in the list. - /// A call to this function MUST be preceded by a call to - /// first(),last(),at() or findRef() - /// + /** + * \brief Returns an iterator pointing to the current item in the list. + * A call to this function MUST be preceded by a call to + * first(),last(),at() or findRef() + * \return KviPointerListIterator<T> + */ KviPointerListIterator<T> iteratorAtCurrent() { return KviPointerListIterator<T>(*this,m_pAux); } - /// - /// \brief Returns the next item in the list - /// Sets the iteration pointer to the next item in the list and - /// returns that item (or 0 if the end of the list has been reached) - /// A call to this function MUST be preceded by a _succesfull_ call - /// to first(),last(),at() or findRef(). - /// + /** + * \brief Returns the next item in the list + * Sets the iteration pointer to the next item in the list and + * returns that item (or 0 if the end of the list has been reached) + * A call to this function MUST be preceded by a _succesfull_ call + * to first(),last(),at() or findRef(). + * \return T * + */ T * next() { if(!m_pAux)return NULL; @@ -679,14 +710,15 @@ public: return NULL; } - /// - /// \brief Returns the previous item in the list - /// Sets the iteration pointer to the previous item in the list and - /// returns that item (or 0 if the beginning of the list has been - /// reached). - /// A call to this function MUST be preceded by a _succesfull_ call - /// to first(),last(),at() or findRef() - /// + /** + * \brief Returns the previous item in the list + * Sets the iteration pointer to the previous item in the list and + * returns that item (or 0 if the beginning of the list has been + * reached). + * A call to this function MUST be preceded by a _succesfull_ call + * to first(),last(),at() or findRef() + * \return T * + */ T * prev() { if(!m_pAux)return NULL; @@ -695,12 +727,13 @@ public: return NULL; } - /// - /// \brief Returns the item at index position - /// Sets the iteration pointer to the nTh item in the list - /// and returns that item (or 0 if the index is out of range) - /// \param idx The index of the element to return - /// + /** + * \brief Returns the item at index position + * Sets the iteration pointer to the nTh item in the list + * and returns that item (or 0 if the index is out of range) + * \param idx The index of the element to return + * \return T * + */ T * at(int idx) { T * t = first(); @@ -714,10 +747,11 @@ public: return 0; } - /// - /// \brief Returns an iterator pointing to the item at the specified index. - /// \param idx The index of the element to return - /// + /** + * \brief Returns an iterator pointing to the item at the specified index. + * \param idx The index of the element to return + * \return KviPointerListIterator<T> + */ KviPointerListIterator<T> iteratorAt(int idx) { KviPointerListNode * n = m_pHead; @@ -732,13 +766,14 @@ public: return KviPointerListIterator<T>(*this,NULL); } - /// - /// \brief Returns the position of an item - /// Sets the iteration pointer to the item with pointer d - /// and returns its position (zero based index) in the list or -1 if - /// the item cannot be found - /// \param d The element to find - /// + /** + * \brief Returns the position of an item + * Sets the iteration pointer to the item with pointer d + * and returns its position (zero based index) in the list or -1 if + * the item cannot be found + * \param d The element to find + * \return int + */ int findRef(const T * d) { int ret = 0; @@ -750,10 +785,11 @@ public: return -1; } - /// - /// \brief Returns an iterator pointing to the item with pointer d. - /// \param d The element to find - /// + /** + * \brief Returns an iterator pointing to the item with pointer d. + * \param d The element to find + * \return KviPointerListIterator<T> + */ KviPointerListIterator<T> iteratorAtRef(const T * d) { KviPointerListNode * n = m_pHead; @@ -766,10 +802,11 @@ public: return KviPointerListIterator<T>(*this,NULL); } - /// - /// \brief Appends an item at the end of the list - /// \param d The item to append - /// + /** + * \brief Appends an item at the end of the list + * \param d The item to append + * \return void + */ void append(const T * d) { if(!m_pHead) @@ -789,28 +826,31 @@ public: m_uCount++; } - /// - /// \brief Appends all the items from the list l to this list - /// \param l The source list where to get items - /// + /** + * \brief Appends all the items from the list l to this list + * \param l The source list where to get items + * \return void + */ void append(KviPointerList<T> * l) { for(T * t = l->first();t;t = l->next())append(t); } - /// - /// \brief Prepends all the items from the list l to this list - /// \param l The source list where to get items - /// + /** + * \brief Prepends all the items from the list l to this list + * \param l The source list where to get items + * \return void + */ void prepend(KviPointerList<T> * l) { for(T * t = l->last();t;t = l->prev())prepend(t); } - /// - /// \brief Inserts the item d in the head position - /// \param d The element to insert - /// + /** + * \brief Inserts the item d in the head position + * \param d The element to insert + * \return void + */ void prepend(const T * d) { if(!m_pHead) @@ -830,16 +870,17 @@ public: } } - /// - /// \brief Inserts the item d at the position specified by iIndex. - /// The position is zero-based. If the specified position is out of - /// the list then the item is appended. - /// Note that this function costs O(n). - /// It's really better to use insertAfter() or insertBefore(), if - /// possible. - /// \param iIndex The index where to insert the item - /// \param d The item to insert - /// + /** + * \brief Inserts the item d at the position specified by iIndex. + * The position is zero-based. If the specified position is out of + * the list then the item is appended. + * Note that this function costs O(n). + * It's really better to use insertAfter() or insertBefore(), if + * possible. + * \param iIndex The index where to insert the item + * \param d The item to insert + * \return void + */ void insert(int iIndex, const T * d) { m_pAux = m_pHead; @@ -854,10 +895,11 @@ public: append(d); } - /// - /// \brief Removes the first item (if any) - /// The item is deleted if autoDelete() is set to true - /// + /** + * \brief Removes the first item (if any) + * The item is deleted if autoDelete() is set to true + * \return bool + */ bool removeFirst() { if(!m_pHead)return false; @@ -881,10 +923,11 @@ public: return true; } - /// - /// \brief Removes the firstitem (if any) - /// The item is deleted if autoDelete() is set to true - /// + /** + * \brief Removes the firstitem (if any) + * The item is deleted if autoDelete() is set to true + * \return bool + */ bool removeLast() { if(!m_pTail)return false; @@ -908,12 +951,13 @@ public: return true; } - /// - /// \brief Removes the item at zero-based position iIndex. - /// Does nothing and returns false if iIndex is out of the list. - /// Please note that this function costs O(n). - /// \param iIndex The index where to remove the item - /// + /** + * \brief Removes the item at zero-based position iIndex. + * Does nothing and returns false if iIndex is out of the list. + * Please note that this function costs O(n). + * \param iIndex The index where to remove the item + * \return bool + */ bool remove(int iIndex) { m_pAux = m_pHead; @@ -928,40 +972,44 @@ public: return true; } - /// - /// \brief Sets the autodelete flag - /// When this flag is on (default), all the items are deleted when - /// removed from the list (or when the list is destroyed or cleared - /// explicitly) - /// \param bAutoDelete The state of the autoDelete() - /// + /** + * \brief Sets the autodelete flag + * When this flag is on (default), all the items are deleted when + * removed from the list (or when the list is destroyed or cleared + * explicitly) + * \param bAutoDelete The state of the autoDelete() + * \return void + */ void setAutoDelete(bool bAutoDelete) { m_bAutoDelete = bAutoDelete; } - /// - /// \brief Returns the autodelete flag. - /// + /** + * \brief Returns the autodelete flag. + * \return bool + */ bool autoDelete() { return m_bAutoDelete; }; - /// - /// \brief Removes all the items from the list - /// (the items are deleted if the autoDelete() flag is set to true) - /// + /** + * \brief Removes all the items from the list + * (the items are deleted if the autoDelete() flag is set to true) + * \return void + */ void clear() { while(m_pHead)removeFirst(); } - /// - /// \brief Removes the current iteration item. - /// Returns true if the current iteration item was valid (and was - /// removed) and false otherwise. - /// + /** + * \brief Removes the current iteration item. + * Returns true if the current iteration item was valid (and was + * removed) and false otherwise. + * \return bool + */ bool removeCurrent() { if(!m_pAux) @@ -970,12 +1018,13 @@ public: return true; } - /// - /// \brief Removes the item pointed by d (if found in the list) - /// The item is deleted if the autoDelete() flag is set to true) - /// Returns true if the item was in the list and false otherwise. - /// \param d The pointer to the item to delete - /// + /** + * \brief Removes the item pointed by d (if found in the list) + * The item is deleted if the autoDelete() flag is set to true) + * Returns true if the item was in the list and false otherwise. + * \param d The pointer to the item to delete + * \return bool + */ bool removeRef(const T * d) { if(findRef(d) == -1)return false; @@ -983,14 +1032,15 @@ public: return true; } - /// - /// \brief Inserts the item d after the item ref - /// If ref is not found in the list, the item is inserted at the end - /// Also sets the current iteration pointer to the newly inserted - /// item - /// \param ref The index item - /// \param d The item to insert after ref - /// + /** + * \brief Inserts the item d after the item ref + * If ref is not found in the list, the item is inserted at the end + * Also sets the current iteration pointer to the newly inserted + * item + * \param ref The index item + * \param d The item to insert after ref + * \return void + */ void insertAfter(const T * ref, const T * d) { if(findRef(ref) == -1) @@ -1010,15 +1060,16 @@ public: m_uCount++; } - /// - /// \brief Inserts the item d before the item ref - /// If ref is not found in the list, the item is inserted at the - /// beginning. - /// Also sets the current iteration pointer to the newly inserted - /// item - /// \param ref The index item - /// \param d The item to insert before ref - /// + /** + * \brief Inserts the item d before the item ref + * If ref is not found in the list, the item is inserted at the + * beginning. + * Also sets the current iteration pointer to the newly inserted + * item + * \param ref The index item + * \param d The item to insert before ref + * \return void + */ void insertBefore(const T * ref, const T * d) { if(findRef(ref) == -1) @@ -1038,9 +1089,10 @@ public: m_uCount++; } - /// - /// \brief Inverts the elements in the list. - /// + /** + * \brief Inverts the elements in the list. + * \return void + */ void invert() { if(!m_pHead)return; @@ -1058,31 +1110,34 @@ public: m_pHead = oldTail; } - /// - /// \brief Clears the list and inserts all the items from the list l - /// \param l The source list to copy from - /// + /** + * \brief Clears the list and inserts all the items from the list l + * \param l The source list to copy from + * \return void + */ void copyFrom(KviPointerList<T> * l) { clear(); for(T * t = l->first();t;t = l->next())append(t); } - /// - /// \brief Clears the list and inserts all the items from the list l - /// This is just an alias to copyFrom(l) - /// \param l The source list to copy from - /// + /** + * \brief Clears the list and inserts all the items from the list l + * This is just an alias to copyFrom(l) + * \param l The source list to copy from + * \return KviPointerList<T> & + */ KviPointerList<T> & operator = (KviPointerList<T> & l) { copyFrom(&l); return *this; } - /// - /// \brief Creates a template list - /// \param bAutoDelete The state of autoDelete() - /// + /** + * \brief Creates a template list + * \param bAutoDelete The state of autoDelete() + * \return KviPointerList<T> + */ KviPointerList<T>(bool bAutoDelete = true) { m_bAutoDelete = bAutoDelete; @@ -1092,10 +1147,10 @@ public: m_pAux = NULL; }; - /// - /// \brief Destroys the list - /// If autoDelete() is set to true, all the items are deleted - /// + /** + * \brief Destroys the list + * If autoDelete() is set to true, all the items are deleted + */ virtual ~KviPointerList<T>() { clear(); diff --git a/src/kvilib/core/kvi_qcstring.h b/src/kvilib/core/kvi_qcstring.h index 4e9f82f79..b91583b39 100644 --- a/src/kvilib/core/kvi_qcstring.h +++ b/src/kvilib/core/kvi_qcstring.h @@ -1,6 +1,5 @@ #ifndef _KVI_QCSTRING_H_ #define _KVI_QCSTRING_H_ - //============================================================================= // // File : kvi_qcstring.h diff --git a/src/kvilib/core/kvi_qstring.h b/src/kvilib/core/kvi_qstring.h index cbcd1f7d4..850611875 100644 --- a/src/kvilib/core/kvi_qstring.h +++ b/src/kvilib/core/kvi_qstring.h @@ -93,6 +93,7 @@ namespace KviQString * \brief Returns true if the string ends with character c * \param szString The source string * \param c The char to check + * \return bool */ inline bool lastCharIs(QString & szString, const QChar & c) { return szString.endsWith(c); }; @@ -141,6 +142,7 @@ namespace KviQString * \brief A portability wrapper which with Qt3 and Qt4. * Returns a lowcase version of the parameter string. * \param s The source string + * \return QString */ inline QString toLower(const QString & s) { @@ -154,6 +156,7 @@ namespace KviQString * \param c The character to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int find(const QString & s, QChar c, int index = 0, bool cs = true) { @@ -167,6 +170,7 @@ namespace KviQString * \param c The character to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int find(const QString & s, char c, int index = 0, bool cs = true) { @@ -180,6 +184,7 @@ namespace KviQString * \param str The string to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int find(const QString & s, const QString & str, int index = 0, bool cs = true) { @@ -193,6 +198,7 @@ namespace KviQString * \param str The string to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int find(const QString & s, const char * str, int index = 0, bool cs = true) { @@ -205,6 +211,7 @@ namespace KviQString * \param s The source string * \param rx The regexp to match * \param index The index to start from + * \return int */ inline int find(const QString & s, const QRegExp & rx, int index = 0) { @@ -219,6 +226,7 @@ namespace KviQString * \param c The character to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int findRev(const QString & s ,QChar c, int index = -1, bool cs = true) { @@ -233,6 +241,7 @@ namespace KviQString * \param c The character to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int findRev(const QString & s, char c, int index = -1, bool cs = true) { @@ -247,6 +256,7 @@ namespace KviQString * \param str The string to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int findRev(const QString & s, const QString & str, int index = -1, bool cs = true) { @@ -261,6 +271,7 @@ namespace KviQString * \param str The string to find * \param index The index to start from * \param cs Case sensitive search + * \return int */ inline int findRev(const QString & s, const char * str, int index = -1, bool cs = true) { @@ -274,6 +285,7 @@ namespace KviQString * \param s The source string * \param rx The regexp to match * \param index The index to start from + * \return int */ inline int findRev(const QString & s, const QRegExp & rx, int index = -1) { @@ -284,6 +296,7 @@ namespace KviQString * \brief Return a whitespace-trimmed string * Spaces are trimmed at start and end of the string * \param s The source string + * \return QString */ inline QString trimmed(const QString & s) { @@ -293,6 +306,7 @@ namespace KviQString /** * \brief Return a UTF-8 formatted string * \param s The source string + * \return KviQCString * \warning: DO NOT USE CONSTRUCTS LIKE char * c = KviQString::toUtf8(something).data(); * They are dangerous since with many compilers the returned string * gets destroyed at the end of the instruction and the c pointer gets @@ -311,6 +325,7 @@ namespace KviQString /** * \brief Return the local 8-bit representation of the string * \param s The source string + * \return KviQCString */ inline KviQCString toLocal8Bit(const QString & s) { @@ -321,6 +336,7 @@ namespace KviQString * \brief Return the string converted to a long * \param s The source string * \param bOk The conversion error handling + * \return kvi_i64_t */ inline kvi_i64_t toI64(QString & szNumber, bool * bOk) { @@ -335,6 +351,7 @@ namespace KviQString * \brief Return the string converted to an unsigned long * \param s The source string * \param bOk The conversion error handling + * \return kvi_u64_t */ inline kvi_u64_t toU64(QString & szNumber, bool * bOk) { diff --git a/src/kvilib/file/kvi_fileutils.h b/src/kvilib/file/kvi_fileutils.h index 0f9d0b809..2e9b5fbd8 100644 --- a/src/kvilib/file/kvi_fileutils.h +++ b/src/kvilib/file/kvi_fileutils.h @@ -63,54 +63,63 @@ namespace KviFileUtils * \param szPath The path to the file to load * \param szBuffer The buffer where to load the file * \param bUtf8 Where to convert from UTF-8 + * \return bool */ extern KVILIB_API bool loadFile(const QString & szPath, QString & szBuffer, bool bUtf8 = true); /** * \brief Adjusts the file path to the current platform * \param szPath The path to the file + * \return void */ extern KVILIB_API void adjustFilePath(QString & szPath); /** * \brief Returns true if szPath points to an existing directory * \param szPath The path to the directory + * \return bool */ extern KVILIB_API bool directoryExists(const QString & szPath); /** * \brief Returns true if szPath points to an existing file * \param szPath The path to the file + * \return bool */ inline bool fileExists(const QString & szPath){ return QFile::exists(szPath); }; /** - /* \brief Removes a file + * \brief Removes a file * \param szPath The file to remove + * \return bool */ extern KVILIB_API bool removeFile(const QString & szPath); /** - /* \brief Removes a file + * \brief Removes a file * \param path The file to remove + * \return bool */ extern KVILIB_API bool removeFile(const char * path); /** * \brief Removes a dir (must be empty) * \param szPath The directory to remove + * \return bool */ extern KVILIB_API bool removeDir(const QString & szPath); /** * \brief Removes a dir (must be empty) * \param path The directory to remove + * \return bool */ extern KVILIB_API bool removeDir(const char * path); /** * \brief Removes a dir recursively * \param szPath The path of the directory to remove + * \return bool */ extern KVILIB_API bool deleteDir(const QString & szPath); @@ -119,6 +128,7 @@ namespace KviFileUtils * \param szPath The path to the file * \param szData The data to write * \param bAppend If we want to append data or overwrite + * \return bool */ extern KVILIB_API bool writeFile(const QString & szPath, const QString & szData, bool bAppend = false); @@ -127,6 +137,7 @@ namespace KviFileUtils * \param path The path to the file * \param szData The data to write * \param bAppend If we want to append data or overwrite + * \return bool */ extern KVILIB_API bool writeFile(const char * path, const QString & szData, bool bAppend = false); @@ -135,6 +146,7 @@ namespace KviFileUtils * \param szPath The path to the file * \param szData The data to write * \param bAppend If we want to append data or overwrite + * \return bool */ extern KVILIB_API bool writeFileLocal8Bit(const QString & szPath, const QString & szData, bool bAppend = false); @@ -143,6 +155,7 @@ namespace KviFileUtils * \param path The path to the file * \param szData The data to write * \param bAppend If we want to append data or overwrite + * \return bool */ extern KVILIB_API bool writeFileLocal8Bit(const char * path, const QString & szData, bool bAppend = false); @@ -152,6 +165,7 @@ namespace KviFileUtils * \param szPath The path to the file to read * \param szBuffer The buffer where to load the file * \param uMaxSize The maximum size of the file to read + * \return bool */ extern KVILIB_API bool readFile(const QString & szPath, QString & szBuffer, unsigned int uMaxSize = 65535); @@ -161,18 +175,21 @@ namespace KviFileUtils * \param path The path to the file to read * \param szBuffer The buffer where to load the file * \param uMaxSize The maximum size of the file to read + * \return bool */ extern KVILIB_API bool readFile(const char * path, QString & szBuffer, unsigned int uMaxSize = 65535); /** * \brief Extracts the filename from a complete path (strips leading path) * \param szFileNameWithPath The complete path to the file + * \return QString */ extern KVILIB_API QString extractFileName(const QString & szFileNameWithPath); /** * \brief Extracts the filename from a complete path (strips leading path) * \param szFileNameWithPath The complete path + * \return QString */ extern KVILIB_API QString extractFilePath(const QString & szFileNameWithPath); @@ -180,6 +197,7 @@ namespace KviFileUtils * \brief Copy the file (cp -f) * \param szSrc The source file * \param szDst The destination file + * \return bool */ extern KVILIB_API bool copyFile(const QString & szSrc, const QString & szDst); @@ -187,6 +205,7 @@ namespace KviFileUtils * \brief Copy the file (cp -f) * \param src The source file * \param dst The destination file + * \return bool */ extern KVILIB_API bool copyFile(const char * src, const char * dst); @@ -194,6 +213,7 @@ namespace KviFileUtils * \brief Rename or move the file (mv) * \param szSrc The source file * \param szDst The destination file + * \return bool */ extern KVILIB_API bool renameFile(const QString & szSrc,const QString & szDst); @@ -201,18 +221,21 @@ namespace KviFileUtils * \brief Rename or move the file (mv) * \param src The source file * \param dst The destination file + * \return bool */ extern KVILIB_API bool renameFile(const char * src, const char * dst); /** * \brief Create a directory (mkdir) * \param szPath The path to the directory + * \return bool */ extern KVILIB_API bool makeDir(const QString & szPath); /** * \brief Create a directory (mkdir) * \param path The path to the directory + * \return bool */ extern KVILIB_API bool makeDir(const char * path); @@ -221,6 +244,7 @@ namespace KviFileUtils * \param f The source file * \param szBuffer The buffer where to store the line read * \param bUtf8 If we want to convert from UTF-8 + * \return bool */ extern KVILIB_API bool readLine(QFile * f, QString & szBuffer, bool bUtf8 = true); @@ -231,18 +255,21 @@ namespace KviFileUtils * \param iStartLine The number of the first line to read * \param iCount The number of lines to read * \param bUtf8 If we want to convert from UTF-8 + * \return bool */ extern KVILIB_API bool readLines(QFile * f, QStringList & buffer, int iStartLine = 0, int iCount = -1, bool bUtf8 = true); /** * \brief Returns true if the file is readable, false otherwise * \param szFname The source file + * \return bool */ extern KVILIB_API bool isReadable(const QString & szFname); /** * \brief Returns true if the path is absolute, false otherwise * \param szPath The path to check + * \return bool */ extern KVILIB_API bool isAbsolutePath(const QString & szPath); @@ -251,6 +278,7 @@ namespace KviFileUtils * There is NO way to come back to the original string the algo is * one-way only * \param path + * \return void */ KVILIB_API extern void encodeFileName(QString & path); }; diff --git a/src/kvilib/file/kvi_packagefile.h b/src/kvilib/file/kvi_packagefile.h index 03475dfdd..aaf3830be 100644 --- a/src/kvilib/file/kvi_packagefile.h +++ b/src/kvilib/file/kvi_packagefile.h @@ -50,7 +50,10 @@ class KviFile; class KVILIB_API KviPackageIOEngine { public: - /// Creates the I/O engine object + /** + * \brief Creates the I/O engine object + * \return KviPackageIOEngine + */ KviPackageIOEngine(); /// Destroys the object virtual ~KviPackageIOEngine(); @@ -63,22 +66,26 @@ protected: public: /** * \brief Returns the last error + * \return const QString & */ const QString & lastError(){ return m_szLastError; }; /** * \brief Sets the last error * \param szLastError The string error + * \return void */ void setLastError(const QString & szLastError){ m_szLastError = szLastError; }; /** * \brief Returns the string info fields + * \return KviPointerHashTable<QString,QString> * */ KviPointerHashTable<QString,QString> * stringInfoFields(){ return m_pStringInfoFields; }; /** * \brief Returns the binary info fields + * \return KviPointerHashTable<QString,QByteArray> * */ KviPointerHashTable<QString,QByteArray> * binaryInfoFields(){ return m_pBinaryInfoFields; }; protected: @@ -86,11 +93,13 @@ protected: * \brief Shows the progress dialog * \param szCaption The caption of the dialog window * \param iTotalSteps The total number of steps + * \return void */ void showProgressDialog(const QString & szCaption, int iTotalSteps); /** * \brief Hides the progress dialog + * \return void */ void hideProgressDialog(); @@ -98,18 +107,21 @@ protected: * \brief Updates the progress dialog * \param iProgress The value in steps of the progress bar * \param szLabel The label of the step + * \return bool */ bool updateProgress(int iProgress, const QString & szLabel); /** * \brief Sets the last error as write error * This is a shortcut to setLastError() + * \return bool */ bool writeError(); /** * \brief Sets the last error as read error * This is a shortcut to setLastError() + * \return bool */ bool readError(); }; @@ -130,7 +142,10 @@ protected: class KVILIB_API KviPackageWriter : public KviPackageIOEngine { public: - /// Creates the package writer object + /** + * \brief Creates the package writer object + * \return KviPackageWriter + */ KviPackageWriter(); /// Destroys the object virtual ~KviPackageWriter(); @@ -174,6 +189,7 @@ public: * \param szLocalFileName The source file * \param szTargetFileName The destination file * \param uAddFileFlags The flags of the file + * \return bool */ bool addFile(const QString & szLocalFileName, const QString & szTargetFileName, kvi_u32_t uAddFileFlags = 0); @@ -182,6 +198,7 @@ public: * \param szLocalDirectoryName The source directory * \param szTargetDirectoryPrefix The destination directory * \param uAddFileFlags The flags of the directory + * \return bool */ bool addDirectory(const QString & szLocalDirectoryName, const QString & szTargetDirectoryPrefix, kvi_u32_t uAddFileFlags = 0); @@ -189,6 +206,7 @@ public: * \brief Adds an info field as a name=value pair * \param szName The name of the info field * \param szValue The value of the info field + * \return void */ void addInfoField(const QString & szName, const QString & szValue); @@ -196,6 +214,7 @@ public: * \brief Adds an info field as a name=value pair * \param szName The name of the info field * \param pArray The value of the info field + * \return void */ void addInfoField(const QString & szName, QByteArray * pArray); @@ -207,6 +226,7 @@ public: * KVI_FILEEXTENSION_ADDONPACKAGE for addons. See kvi_fileextension.h * \param szFileName The file name of the package * \param uPackFlags The flags of the package + * \return bool */ bool pack(const QString & szFileName, kvi_u32_t uPackFlags = 0); private: @@ -215,6 +235,7 @@ private: * This is a shortcut to packFile() performing some checks * \param szFileName The file name of the package * \param uPackFlags The flags of the package + * \return bool */ bool packInternal(const QString & szFileName, kvi_u32_t uPackFlags = 0); @@ -223,19 +244,18 @@ private: * This is the real pack() function * \param pFile The source file package * \param pDataField The data field for the package + * \return bool */ bool packFile(KviFile * pFile, DataField * pDataField); /** * \brief Adds a file to the package. - * The file must be specified as absolute local path and as target path - * relative to the KVIrc local directory. * This is the real addFile() function - * ... more ? * \param fi THe information of the file * \param szLocalFileName The source file * \param szTargetFileName The destination file * \param uAddFileFlags The flags of the file + * \return bool */ bool addFileInternal(const QFileInfo * fi, const QString & szLocalFileName, const QString & szTargetFileName, kvi_u32_t uAddFileFlags = 0); }; @@ -248,7 +268,10 @@ private: class KVILIB_API KviPackageReader : public KviPackageIOEngine { public: - /// Creates the package reader object + /** + * \brief Creates the package reader object + * \return KviPackageReader + */ KviPackageReader(); /// Destroys the object virtual ~KviPackageReader(); @@ -262,6 +285,7 @@ public: * \brief Read the header of the package * This is a shortcut to readHeaderInternal() * \param szLocalFileName The source package + * \return bool */ bool readHeader(const QString & szLocalFileName); @@ -269,6 +293,7 @@ public: * \brief Get the string info field contained in the package * \param szName The name of the info field * \param szBuffer The buffer where to store data + * \return bool */ bool getStringInfoField(const QString & szName, QString & szBuffer); @@ -278,6 +303,7 @@ public: * \param szLocalFileName The source package * \param szUnpackPath The path where to unpack the package * \param uUnpackFlags The flags to unpack + * \return bool */ bool unpack(const QString & szLocalFileName, const QString & szUnpackPath, kvi_u32_t uUnpackFlags = 0); private: @@ -287,6 +313,7 @@ private: * \param szLocalFileName The source package * \param szUnpackPath The path where to unpack the package * \param uUnpackFlags The flags to unpack + * \return bool */ bool unpackInternal(const QString & szLocalFileName, const QString & szUnpackPath, kvi_u32_t uUnpackFlags = 0); @@ -295,6 +322,7 @@ private: * This is the real unpack() function. * \param pFile The source file package * \param szUnpackPath The path where to unpack the package + * \return bool */ bool unpackFile(KviFile * pFile, const QString & szUnpackPath); @@ -303,6 +331,7 @@ private: * This is the real readHeader() function * \param pFile The pointer to the real file * \param szLocalFileName The source package + * \return bool */ bool readHeaderInternal(KviFile * pFile, const QString & szLocalFileName); }; |
