From 6f94639a3f5e20e1c635b2d8676086464d7cba2e Mon Sep 17 00:00:00 2001 From: David Date: Mon, 18 Jun 2007 20:45:45 +0000 Subject: david - did more documenting --- src/file.h | 18 ++++++++++++ src/list.h | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/sptr.h | 45 +++++++++++++++++++++++++++++ src/stream.h | 58 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 213 insertions(+) (limited to 'src') diff --git a/src/file.h b/src/file.h index fe8dbda..1a4421b 100644 --- a/src/file.h +++ b/src/file.h @@ -39,6 +39,14 @@ namespace Bu virtual bool isBlocking(); virtual void setBlocking( bool bBlocking=true ); + /** + * Create a temp file and return its handle + *@param sName (Bu::FString) Give in the form: "/tmp/tmpfileXXXXXXXX" + * It will alter your (sName) setting the 'X's to random + * characters. + *@param sFlags (const char *) Standard file flags 'rb'... etc.. + *@returns (Bu::File) A file object representing your temp file. + */ inline static Bu::File tempFile( Bu::FString &sName, const char *sFlags ) { int afh_d = mkstemp( sName.getStr() ); @@ -46,7 +54,17 @@ namespace Bu return Bu::File( afh_d, sFlags ); } + /** + * Set the size of the file to (nSize). You can either grow or shrink + * the file. + *@param nSize (long) The new size of the file. + */ void truncate( long nSize ); + + /** + * Change the file access permissions. + *@param t (mode_t) The new file access permissions. + */ void chmod( mode_t t ); private: diff --git a/src/list.h b/src/list.h index 9d1f904..314459e 100644 --- a/src/list.h +++ b/src/list.h @@ -115,6 +115,10 @@ namespace Bu } } + /** + * Prepend a value to the list. + *@param v (const value_type &) The value to prepend. + */ void prepend( const value &v ) { Link *pNew = la.allocate( 1 ); @@ -136,6 +140,9 @@ namespace Bu } } + /** + * An iterator to iterate through your list. + */ typedef struct iterator { friend class List; @@ -152,36 +159,67 @@ namespace Bu } public: + /** + * Equals comparison operator. + *@param oth (const iterator &) The iterator to compare to. + *@returns (bool) Are they equal? + */ bool operator==( const iterator &oth ) const { return ( pLink == oth.pLink ); } + /** + * Equals comparison operator. + *@param pOth (const Link *) The link to compare to. + *@returns (bool) Are they equal? + */ bool operator==( const Link *pOth ) const { return ( pLink == pOth ); } + /** + * Not equals comparison operator. + *@param oth (const iterator &) The iterator to compare to. + *@returns (bool) Are they not equal? + */ bool operator!=( const iterator &oth ) const { return ( pLink != oth.pLink ); } + /** + * Not equals comparison operator. + *@param pOth (const Link *) The link to compare to. + *@returns (bool) Are they not equal? + */ bool operator!=( const Link *pOth ) const { return ( pLink != pOth ); } + /** + * Dereference operator. + *@returns (value_type &) The value. + */ value &operator*() { return *(pLink->pValue); } + /** + * Pointer access operator. + *@returns (value_type *) A pointer to the value. + */ value *operator->() { return pLink->pValue; } + /** + * Increment operator. + */ iterator &operator++() { if( pLink != NULL ) @@ -189,6 +227,9 @@ namespace Bu return *this; } + /** + * Decrement operator. + */ iterator &operator--() { if( pLink != NULL ) @@ -196,6 +237,9 @@ namespace Bu return *this; } + /** + * Increment operator. + */ iterator &operator++( int ) { if( pLink != NULL ) @@ -203,6 +247,9 @@ namespace Bu return *this; } + /** + * Decrement operator. + */ iterator &operator--( int ) { if( pLink != NULL ) @@ -210,6 +257,11 @@ namespace Bu return *this; } + /** + * Assignment operator. + *@param oth (const iterator &) The other iterator to set this + * one to. + */ iterator &operator=( const iterator &oth ) { pLink = oth.pLink; @@ -217,6 +269,9 @@ namespace Bu } }; + /** + *@see iterator + */ typedef struct const_iterator { friend class List; @@ -309,21 +364,38 @@ namespace Bu } }; + /** + * Get an iterator pointing to the first item in the list. + *@returns (iterator) + */ iterator begin() { return iterator( pFirst ); } + /** + * Get a const iterator pointing to the first item in the list. + *@returns (const const_iterator) + */ const const_iterator begin() const { return const_iterator( pFirst ); } + /** + * Get an iterator pointing to a place just past the last item in + * the list. + *@returns (const Link *) + */ const Link *end() const { return NULL; } + /** + * Erase an item from the list. + *@param i (iterator) The item to erase. + */ void erase( iterator &i ) { Link *pCur = i.pLink; @@ -355,26 +427,46 @@ namespace Bu } } + /** + * Get the current size of the list. + *@returns (int) The current size of the list. + */ int getSize() const { return nSize; } + /** + * Get the first item in the list. + *@returns (value_type &) The first item in the list. + */ value &first() { return *pFirst->pValue; } + /** + * Get the first item in the list. + *@returns (const value_type &) The first item in the list. + */ const value &first() const { return *pFirst->pValue; } + /** + * Get the last item in the list. + *@returns (value_type &) The last item in the list. + */ value &last() { return *pLast->pValue; } + /** + * Get the last item in the list. + *@returns (const value_type &) The last item in the list. + */ const value &last() const { return *pLast->pValue; diff --git a/src/sptr.h b/src/sptr.h index faa8524..4baa697 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -45,31 +45,55 @@ namespace Bu } } + /** + * Get the number of references to this pointer. + *@returns (int32_t) The number of references to this pointer. + */ int32_t count() const { return *pRefCnt; } + /** + * Pointer access operator. + *@returns (const T *) + */ const T *operator->() const { return pData; } + /** + * Dereference operator. + *@returns (const T &) The value at the end of the pointer. + */ const T &operator*() const { return *pData; } + /** + * Pointer access operator. + *@returns (T *) + */ T *operator->() { return pData; } + /** + * Dereference operator. + *@returns (T &) The value at the end of the pointer. + */ T &operator*() { return *pData; } + /** + * Assignment operator. + *@param src (const SPtr &) + */ SPtr operator=( const SPtr &src ) { decCount(); @@ -81,6 +105,10 @@ namespace Bu return *this; } + /** + * Assignment operator. + *@param src (const SPtr &) + */ const SPtr operator=( const SPtr &src ) const { decCount(); @@ -92,21 +120,38 @@ namespace Bu return *this; } + /** + * Equals comparison operator. + *@param src (const SPtr &) The SPtr to compare to. + *@returns (bool) Are the equal? + */ bool operator==( const SPtr &src ) const { return pData == src.pData; } + /** + * Equals comparison operator. + *@param src (const T *) The pointer to compare to. + *@returns (bool) Are the equal? + */ bool operator==( const T *src ) const { return pData == src; } + /** + * Boolean cast operator. Do we have a pointer? + */ operator bool() const { return pRefCnt != NULL; } + /** + * Do we have a pointer? + *@returns (bool) Do we have a pointer? + */ bool isSet() const { return pRefCnt != NULL; diff --git a/src/stream.h b/src/stream.h index ba070d3..056de0c 100644 --- a/src/stream.h +++ b/src/stream.h @@ -22,17 +22,66 @@ namespace Bu Stream(); virtual ~Stream(); + /** + * Close the stream. + */ virtual void close() = 0; + + /** + * Read data from the stream into a buffer. + *@param pBuf (void *) Buffer which will be filled. + *@param nBytes (size_t) Max data to read. + *@returns (size_t) Amount of data read. + */ virtual size_t read( void *pBuf, size_t nBytes ) = 0; + + /** + * Write data to the stream. + *@param pBuf (const void *) The data to be written. + *@param nBytes (size_t) Amount of data to write from pBuf. + *@returns (size_t) Amount of data actually written. + */ virtual size_t write( const void *pBuf, size_t nBytes ) = 0; + /** + * Get the current position in the stream. + *@returns (long) The current position in the stream. + */ virtual long tell() = 0; + + /** + * Seek to a position in the stream relative to the current position. + *@param offset (long) Offset from current position to seek to. + */ virtual void seek( long offset ) = 0; + + /** + * Set position in the stream relative to the start of the stream. + *@param pos (long) The position. + */ virtual void setPos( long pos ) = 0; + + /** + * Set position in the stream relative to the end of the stream. + *@param pos (long) The position. + */ virtual void setPosEnd( long pos ) = 0; + + /** + * Are we at the end of the stream? + *@returns (bool) Are we at the end of the stream? + */ virtual bool isEOS() = 0; + + /** + * Is the stream open? + *@returns (bool) Is the stream open? + */ virtual bool isOpen() = 0; + /** + * Flush any data still held in buffers. + */ virtual void flush() = 0; /** @@ -71,7 +120,16 @@ namespace Bu */ virtual bool isSeekable() = 0; + /** + * Are we currently set to block mode? + *@returns (bool) + */ virtual bool isBlocking() = 0; + + /** + * Set stream to blocking or non-blocking mode. + *@param bBlocking (bool) Whether we should block or not. + */ virtual void setBlocking( bool bBlocking=true ) = 0; public: // Filters -- cgit v1.2.3