From da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 04:50:36 +0000 Subject: The first batch seem to have made it alright. Unfortunately the Archive class isn't done yet, I'm going to make it rely on streams, so those will be next, then we can make it work all sortsa' well. --- src/archive.h | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/archive.h (limited to 'src/archive.h') diff --git a/src/archive.h b/src/archive.h new file mode 100644 index 0000000..7de9220 --- /dev/null +++ b/src/archive.h @@ -0,0 +1,93 @@ +#ifndef ARCHIVE_H +#define ARCHIVE_H + +#include +#include +#include "archable.h" + +namespace Bu +{ + class Archive + { + private: + bool bLoading; + public: + bool isLoading(); + + enum + { + load = true, + save = false + }; + + Archive( bool bLoading ); + virtual ~Archive(); + virtual void close()=0; + + virtual void write(const void *, int32_t)=0; + virtual void read(void *, int32_t)=0; + + virtual Archive &operator<<(bool); + virtual Archive &operator<<(int8_t); + virtual Archive &operator<<(int16_t); + virtual Archive &operator<<(int32_t); + virtual Archive &operator<<(int64_t); + virtual Archive &operator<<(uint8_t); + virtual Archive &operator<<(uint16_t); + virtual Archive &operator<<(uint32_t); + virtual Archive &operator<<(uint64_t); + virtual Archive &operator<<(long); + virtual Archive &operator<<(float); + virtual Archive &operator<<(double); + virtual Archive &operator<<(long double); + + virtual Archive &operator>>(bool &); + virtual Archive &operator>>(int8_t &); + virtual Archive &operator>>(int16_t &); + virtual Archive &operator>>(int32_t &); + virtual Archive &operator>>(int64_t &); + virtual Archive &operator>>(uint8_t &); + virtual Archive &operator>>(uint16_t &); + virtual Archive &operator>>(uint32_t &); + virtual Archive &operator>>(uint64_t &); + virtual Archive &operator>>(long &); + virtual Archive &operator>>(float &); + virtual Archive &operator>>(double &); + virtual Archive &operator>>(long double &); + + virtual Archive &operator&&(bool &); + virtual Archive &operator&&(int8_t &); + virtual Archive &operator&&(int16_t &); + virtual Archive &operator&&(int32_t &); + virtual Archive &operator&&(int64_t &); + virtual Archive &operator&&(uint8_t &); + virtual Archive &operator&&(uint16_t &); + virtual Archive &operator&&(uint32_t &); + virtual Archive &operator&&(uint64_t &); + virtual Archive &operator&&(float &); + virtual Archive &operator&&(double &); + virtual Archive &operator&&(long double &); + }; + + Archive &operator<<(Archive &, class Bu::Archable &); + Archive &operator>>(Archive &, class Bu::Archable &); + //Archive &operator&&(Archive &s, class Bu::Archable &p); + + Archive &operator<<(Archive &, std::string &); + Archive &operator>>(Archive &, std::string &); + //Archive &operator&&(Archive &, std::string &); + + template Archive &operator&&( Archive &ar, T &dat ) + { + if( ar.isLoading() ) + { + return ar >> dat; + } + else + { + return ar << dat; + } + } +} + +#endif -- cgit v1.2.3 From c884da672645231b5ec47706c886381dab1b391a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 05:09:12 +0000 Subject: The file stream is imported and works, as does our first test, and the new tweaks to archive. The && operator is now a template function, and as such requires no special handling. It could be worth it to check this out for other types, yet dangerous, since it would let you archive anything, even a class, without writing the proper functions for it...we shall see what happens... --- src/archive.cpp | 27 ++++++++++++++-- src/archive.h | 12 ++++--- src/old/sfile.cpp | 74 ------------------------------------------ src/old/sfile.h | 29 ----------------- src/sfile.cpp | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/sfile.h | 36 +++++++++++++++++++++ src/tests/archive.cpp | 11 ++++++- 7 files changed, 169 insertions(+), 110 deletions(-) delete mode 100644 src/old/sfile.cpp delete mode 100644 src/old/sfile.h create mode 100644 src/sfile.cpp create mode 100644 src/sfile.h (limited to 'src/archive.h') diff --git a/src/archive.cpp b/src/archive.cpp index 5f5145c..be06c0e 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -1,13 +1,36 @@ #include "archive.h" -Bu::Archive::Archive(bool bLoading): - bLoading(bLoading) +Bu::Archive::Archive( Stream &rStream, bool bLoading ) : + bLoading( bLoading ), + rStream( rStream ) { } + Bu::Archive::~Archive() { } +void Bu::Archive::write( const void *pData, int32_t nSize ) +{ + if( nSize == 0 || pData == NULL ) + return; + + rStream.write( (const char *)pData, nSize ); +} + +void Bu::Archive::read( void *pData, int32_t nSize ) +{ + if( nSize == 0 || pData == NULL ) + return; + + rStream.read( (char *)pData, nSize ); +} + +void Bu::Archive::close() +{ + rStream.close(); +} + bool Bu::Archive::isLoading() { return bLoading; diff --git a/src/archive.h b/src/archive.h index 7de9220..26e430b 100644 --- a/src/archive.h +++ b/src/archive.h @@ -4,6 +4,7 @@ #include #include #include "archable.h" +#include "stream.h" namespace Bu { @@ -20,12 +21,12 @@ namespace Bu save = false }; - Archive( bool bLoading ); + Archive( Stream &rStream, bool bLoading ); virtual ~Archive(); - virtual void close()=0; + virtual void close(); - virtual void write(const void *, int32_t)=0; - virtual void read(void *, int32_t)=0; + virtual void write(const void *, int32_t); + virtual void read(void *, int32_t); virtual Archive &operator<<(bool); virtual Archive &operator<<(int8_t); @@ -67,6 +68,9 @@ namespace Bu virtual Archive &operator&&(float &); virtual Archive &operator&&(double &); virtual Archive &operator&&(long double &); + + private: + Stream &rStream; }; Archive &operator<<(Archive &, class Bu::Archable &); diff --git a/src/old/sfile.cpp b/src/old/sfile.cpp deleted file mode 100644 index f1de03c..0000000 --- a/src/old/sfile.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "sfile.h" -#include "exceptions.h" - -SFile::SFile( const char *sName, const char *sFlags ) -{ - fh = fopen( sName, sFlags ); -} - -SFile::~SFile() -{ -} - -void SFile::close() -{ - if( fh ) - { - fclose( fh ); - fh = NULL; - } -} - -size_t SFile::read( char *pBuf, size_t nBytes ) -{ - if( !fh ) - throw FileException("File not open."); - - return fread( pBuf, 1, nBytes, fh ); -} - -size_t SFile::write( const char *pBuf, size_t nBytes ) -{ - if( !fh ) - throw FileException("File not open."); - - return fwrite( pBuf, 1, nBytes, fh ); -} - -long SFile::tell() -{ - if( !fh ) - throw FileException("File not open."); - - return ftell( fh ); -} - -void SFile::seek( long offset ) -{ - if( !fh ) - throw FileException("File not open."); - - fseek( fh, offset, SEEK_CUR ); -} - -void SFile::setPos( long pos ) -{ - if( !fh ) - throw FileException("File not open."); - - fseek( fh, pos, SEEK_SET ); -} - -void SFile::setPosEnd( long pos ) -{ - if( !fh ) - throw FileException("File not open."); - - fseek( fh, pos, SEEK_END ); -} - -bool SFile::isEOS() -{ - return feof( fh ); -} - diff --git a/src/old/sfile.h b/src/old/sfile.h deleted file mode 100644 index b51e5bc..0000000 --- a/src/old/sfile.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SFILE_H -#define SFILE_H - -#include - -#include "stream.h" - -class SFile : public Stream -{ -public: - SFile( const char *sName, const char *sFlags ); - virtual ~SFile(); - - virtual void close(); - virtual size_t read( char *pBuf, size_t nBytes ); - virtual size_t write( const char *pBuf, size_t nBytes ); - - virtual long tell(); - virtual void seek( long offset ); - virtual void setPos( long pos ); - virtual void setPosEnd( long pos ); - virtual bool isEOS(); - -private: - FILE *fh; - -}; - -#endif diff --git a/src/sfile.cpp b/src/sfile.cpp new file mode 100644 index 0000000..d7c5c83 --- /dev/null +++ b/src/sfile.cpp @@ -0,0 +1,90 @@ +#include "sfile.h" +#include "exceptions.h" + +Bu::SFile::SFile( const char *sName, const char *sFlags ) +{ + fh = fopen( sName, sFlags ); +} + +Bu::SFile::~SFile() +{ + close(); +} + +void Bu::SFile::close() +{ + if( fh ) + { + fclose( fh ); + fh = NULL; + } +} + +size_t Bu::SFile::read( char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("File not open."); + + return fread( pBuf, 1, nBytes, fh ); +} + +size_t Bu::SFile::write( const char *pBuf, size_t nBytes ) +{ + if( !fh ) + throw FileException("File not open."); + + return fwrite( pBuf, 1, nBytes, fh ); +} + +long Bu::SFile::tell() +{ + if( !fh ) + throw FileException("File not open."); + + return ftell( fh ); +} + +void Bu::SFile::seek( long offset ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, offset, SEEK_CUR ); +} + +void Bu::SFile::setPos( long pos ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, pos, SEEK_SET ); +} + +void Bu::SFile::setPosEnd( long pos ) +{ + if( !fh ) + throw FileException("File not open."); + + fseek( fh, pos, SEEK_END ); +} + +bool Bu::SFile::isEOS() +{ + return feof( fh ); +} + +bool Bu::SFile::canRead() +{ + return true; +} + +bool Bu::SFile::canWrite() +{ + return true; +} + +bool Bu::SFile::canSeek() +{ + return true; +} + diff --git a/src/sfile.h b/src/sfile.h new file mode 100644 index 0000000..304f6b7 --- /dev/null +++ b/src/sfile.h @@ -0,0 +1,36 @@ +#ifndef SFILE_H +#define SFILE_H + +#include + +#include "stream.h" + +namespace Bu +{ + class SFile : public Bu::Stream + { + public: + SFile( const char *sName, const char *sFlags ); + virtual ~SFile(); + + virtual void close(); + virtual size_t read( char *pBuf, size_t nBytes ); + virtual size_t write( const char *pBuf, size_t nBytes ); + + virtual long tell(); + virtual void seek( long offset ); + virtual void setPos( long pos ); + virtual void setPosEnd( long pos ); + virtual bool isEOS(); + + virtual bool canRead(); + virtual bool canWrite(); + virtual bool canSeek(); + + private: + FILE *fh; + + }; +} + +#endif diff --git a/src/tests/archive.cpp b/src/tests/archive.cpp index fb0d97c..5b7e285 100644 --- a/src/tests/archive.cpp +++ b/src/tests/archive.cpp @@ -1,7 +1,16 @@ #include "archive.h" +#include "sfile.h" + +using namespace Bu; int main() { - //Archive + SFile f("test.dat", "wb"); + Archive ar( f, Archive::save ); + + std::string s("Hello there"); + ar << s; + + return 0; } -- cgit v1.2.3 From 5a0d7856dc265580cebaa833e0367d03ef21bbc3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Apr 2007 13:53:18 +0000 Subject: Woo, changed the name of Achable to Archival, I dig that, and added the ground- work for the SSocket, that should be cool. --- src/archable.cpp | 10 ---------- src/archable.h | 35 ----------------------------------- src/archival.cpp | 10 ++++++++++ src/archival.h | 38 ++++++++++++++++++++++++++++++++++++++ src/archive.cpp | 6 +++--- src/archive.h | 8 ++++---- src/fstring.h | 4 ++-- src/hash.h | 2 +- src/ssocket.cpp | 9 +++++++++ src/ssocket.h | 24 ++++++++++++++++++++++++ 10 files changed, 91 insertions(+), 55 deletions(-) delete mode 100644 src/archable.cpp delete mode 100644 src/archable.h create mode 100644 src/archival.cpp create mode 100644 src/archival.h create mode 100644 src/ssocket.cpp create mode 100644 src/ssocket.h (limited to 'src/archive.h') diff --git a/src/archable.cpp b/src/archable.cpp deleted file mode 100644 index 38fc31f..0000000 --- a/src/archable.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "archable.h" - -Bu::Archable::Archable() -{ -} - -Bu::Archable::~Archable() -{ -} - diff --git a/src/archable.h b/src/archable.h deleted file mode 100644 index ed05a78..0000000 --- a/src/archable.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef ARCHABLE_H -#define ARCHABLE_H - -namespace Bu -{ - /** - * The base class for any class you want to archive. Simply include this as - * a base class, implement the purely virtual archive function and you've - * got an easily archiveable class. - */ - class Archable - { - public: - /** - * Does nothing, here for completeness. - */ - Archable(); - - /** - * Here to ensure the deconstructor is virtual. - */ - virtual ~Archable(); - - /** - * This is the main workhorse of the archive system, just override and - * you've got a archiveable class. A reference to the Archive - * used is passed in as your only parameter, query it to discover if - * you are loading or saving. - * @param ar A reference to the Archive object to use. - */ - virtual void archive( class Archive &ar )=0; - }; -} - -#endif diff --git a/src/archival.cpp b/src/archival.cpp new file mode 100644 index 0000000..79c28f1 --- /dev/null +++ b/src/archival.cpp @@ -0,0 +1,10 @@ +#include "archival.h" + +Bu::Archival::Archival() +{ +} + +Bu::Archival::~Archival() +{ +} + diff --git a/src/archival.h b/src/archival.h new file mode 100644 index 0000000..e2c803c --- /dev/null +++ b/src/archival.h @@ -0,0 +1,38 @@ +#ifndef ARCHIVAL_H +#define ARCHIVAL_H + +namespace Bu +{ + /** + * The base class for any class you want to archive. Simply include this as + * a base class, implement the purely virtual archive function and you've + * got an easily archiveable class. + * + * Archival: "of or pertaining to archives or valuable records; contained + * in or comprising such archives or records." + */ + class Archival + { + public: + /** + * Does nothing, here for completeness. + */ + Archival(); + + /** + * Here to ensure the deconstructor is virtual. + */ + virtual ~Archival(); + + /** + * This is the main workhorse of the archive system, just override and + * you've got a archiveable class. A reference to the Archive + * used is passed in as your only parameter, query it to discover if + * you are loading or saving. + * @param ar A reference to the Archive object to use. + */ + virtual void archive( class Archive &ar )=0; + }; +} + +#endif diff --git a/src/archive.cpp b/src/archive.cpp index be06c0e..edc8625 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -312,20 +312,20 @@ Bu::Archive &Bu::Archive::operator&&(long double &p) } -Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archable &p) +Bu::Archive &Bu::operator<<(Bu::Archive &s, Bu::Archival &p) { p.archive( s ); return s; } -Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archable &p) +Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archival &p) { p.archive( s ); return s; } /* -Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archable &p) +Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archival &p) { if (s.isLoading()) { diff --git a/src/archive.h b/src/archive.h index 26e430b..a8ce53e 100644 --- a/src/archive.h +++ b/src/archive.h @@ -3,7 +3,7 @@ #include #include -#include "archable.h" +#include "archival.h" #include "stream.h" namespace Bu @@ -73,9 +73,9 @@ namespace Bu Stream &rStream; }; - Archive &operator<<(Archive &, class Bu::Archable &); - Archive &operator>>(Archive &, class Bu::Archable &); - //Archive &operator&&(Archive &s, class Bu::Archable &p); + Archive &operator<<(Archive &, class Bu::Archival &); + Archive &operator>>(Archive &, class Bu::Archival &); + //Archive &operator&&(Archive &s, class Bu::Archival &p); Archive &operator<<(Archive &, std::string &); Archive &operator>>(Archive &, std::string &); diff --git a/src/fstring.h b/src/fstring.h index 717068f..0184301 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -3,7 +3,7 @@ #include #include -#include "archable.h" +#include "archival.h" #include "archive.h" #include "hash.h" @@ -29,7 +29,7 @@ namespace Bu * FBasicString into a ref-counting container class. */ template< typename chr, typename chralloc=std::allocator, typename chunkalloc=std::allocator > > - class FBasicString : public Archable + class FBasicString : public Archival { #ifndef VALTEST #define cpy( dest, src, size ) memcpy( dest, src, size*sizeof(chr) ) diff --git a/src/hash.h b/src/hash.h index 9e498f1..dc097df 100644 --- a/src/hash.h +++ b/src/hash.h @@ -8,7 +8,7 @@ #include #include #include "exceptionbase.h" -#include "archable.h" +#include "archival.h" #include "archive.h" #define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0)) diff --git a/src/ssocket.cpp b/src/ssocket.cpp new file mode 100644 index 0000000..bdaac24 --- /dev/null +++ b/src/ssocket.cpp @@ -0,0 +1,9 @@ +#include "ssocket.h" + +SSocket::SSocket() +{ +} + +SSocket::~SSocket() +{ +} diff --git a/src/ssocket.h b/src/ssocket.h new file mode 100644 index 0000000..ce02091 --- /dev/null +++ b/src/ssocket.h @@ -0,0 +1,24 @@ +#ifndef S_SOCKET_H +#define S_SOCKET_H + +#include + +#include "stream.h" + +namespace Bu +{ + /** + * + */ + class SSocket : public Stream + { + public: + SSocket(); + virtual ~SSocket(); + + private: + + }; +} + +#endif -- cgit v1.2.3 From e7ab7cb1604c04763bbdcece5885e6ce5aa100b4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Apr 2007 17:37:46 +0000 Subject: Fixed a warning in the SFile test, and added std::list support to the archive. I guess I should write a test for it too... I'm also thinking of removing the S from the front of the stream children. --- src/archive.cpp | 13 ------------- src/archive.h | 29 +++++++++++++++++++++++++++++ src/unit/sfile.cpp | 2 +- 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src/archive.h') diff --git a/src/archive.cpp b/src/archive.cpp index edc8625..c759477 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -324,19 +324,6 @@ Bu::Archive &Bu::operator>>(Bu::Archive &s, Bu::Archival &p) return s; } -/* -Bu::Archive &Bu::operator&&(Bu::Archive &s, Bu::Archival &p) -{ - if (s.isLoading()) - { - return s >> p; - } - else - { - return s << p; - } -}*/ - Bu::Archive &Bu::operator<<( Bu::Archive &ar, std::string &s ) { ar << (uint32_t)s.length(); diff --git a/src/archive.h b/src/archive.h index a8ce53e..9ac3303 100644 --- a/src/archive.h +++ b/src/archive.h @@ -5,6 +5,7 @@ #include #include "archival.h" #include "stream.h" +#include namespace Bu { @@ -92,6 +93,34 @@ namespace Bu return ar << dat; } } + + template Archive &operator<<( Archive &ar, std::list &l ) + { + typename std::list::size_type num = l.size(); + ar << num; + for( typename std::list::const_iterator i = l.begin(); i != l.end(); + i++ ) + { + ar << *i; + } + + return ar; + } + + template Archive &operator>>( Archive &ar, std::list &l ) + { + typename std::list::size_type num; + ar >> num; + + l.resize( num ); + for( typename std::list::const_iterator i = l.begin(); + i != l.end(); i++ ) + { + ar >> *i; + } + + return ar; + } } #endif diff --git a/src/unit/sfile.cpp b/src/unit/sfile.cpp index 3f52272..2aff312 100644 --- a/src/unit/sfile.cpp +++ b/src/unit/sfile.cpp @@ -87,7 +87,7 @@ public: unitTest( sf.isEOS() == false ); try { - int r = sf.read( buf, 5 ); + sf.read( buf, 5 ); unitFailed("No exception thrown"); } catch( Bu::FileException &e ) -- cgit v1.2.3 From 1fa3ca5f24c018126333ca2d6609730e1ae17386 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 10 Apr 2007 21:48:23 +0000 Subject: Added more comments, help, and socket actually reads and writes some, but it's not done. I need to decide how I want to do the buffering... --- src/archive.h | 47 +++++++++++ src/exceptions.cpp | 1 + src/exceptions.h | 2 + src/socket.cpp | 232 ++++++++++++++++++++++++++++++++++++++++++++++++++++- src/socket.h | 23 +++++- src/stream.h | 10 +++ 6 files changed, 312 insertions(+), 3 deletions(-) (limited to 'src/archive.h') diff --git a/src/archive.h b/src/archive.h index 9ac3303..2f782d3 100644 --- a/src/archive.h +++ b/src/archive.h @@ -9,6 +9,53 @@ namespace Bu { + /** + * Provides a framework for serialization of objects and primitives. The + * archive will handle any basic primitive, a few special types, like char * + * strings, as well as STL classes and anything that inherits from the + * Archival class. Each Archive operates on a Stream, so you can send the + * data using an Archive almost anywhere. + * + * In order to use an Archive to store something to a file, try something + * like: + *@code + * File sOut("output", "wb"); // This is a stream subclass + * Archive ar( sOut, Archive::save ); + * ar << myClass; + @endcode + * In this example myClass is any class that inherits from Archival. When + * the storage operator is called, the Archival::archive() function in the + * myClass object is called with a reference to the Archive. This can be + * handled in one of two ways: + *@code + * void MyClass::archive( Archive &ar ) + * { + * ar && sName && nAge && sJob; + * } + @endcode + * Here we don't worry about weather we're loading or saving by using the + * smart && operator. This allows us to write very consistent, very simple + * archive functions that really do a lot of work. If we wanted to do + * something different in the case of loading or saving we would do: + *@code + * void MyClass::archive( Archive &ar ) + * { + * if( ar.isLoading() ) + * { + * ar >> sName >> nAge >> sJob; + * } else + * { + * ar << sName << nAge << sJob; + * } + * } + @endcode + * Archive currently does not provide facility to make fully portable + * archives. For example, it will not convert between endianness for you, + * nor will it take into account differences between primitive sizes on + * different platforms. This, at the moment, is up to the user to ensure. + * One way of dealing with the latter problem is to make sure and use + * explicit primitive types from the stdint.h header, i.e. int32_t. + */ class Archive { private: diff --git a/src/exceptions.cpp b/src/exceptions.cpp index 37f09a4..a512105 100644 --- a/src/exceptions.cpp +++ b/src/exceptions.cpp @@ -7,4 +7,5 @@ namespace Bu subExceptionDef( FileException ) subExceptionDef( ConnectionException ) subExceptionDef( PluginException ) + subExceptionDef( UnsupportedException ) } diff --git a/src/exceptions.h b/src/exceptions.h index b28d292..3efa19f 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -10,6 +10,7 @@ namespace Bu subExceptionDecl( FileException ) subExceptionDecl( ConnectionException ) subExceptionDecl( PluginException ) + subExceptionDecl( UnsupportedException ) enum eFileException { @@ -19,6 +20,7 @@ namespace Bu enum eConnectionException { excodeReadError, + excodeWriteError, excodeBadReadError, excodeConnectionClosed, excodeSocketTimeout diff --git a/src/socket.cpp b/src/socket.cpp index c5c592b..e206bb5 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -1,10 +1,240 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "socket.h" +#include "exceptions.h" -Bu::Socket::Socket() +#define RBS (1024*2) + +Bu::Socket::Socket( int nSocket ) : + nSocket( nSocket ), + bActive( true ) { } +Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) +{ + struct sockaddr_in xServerName; + bActive = false; + + /* Create the socket. */ + nSocket = socket( PF_INET, SOCK_STREAM, 0 ); + + if( nSocket < 0 ) + { + throw ExceptionBase("Couldn't create socket.\n"); + } + + // These lines set the socket to non-blocking, a good thing? + int flags; + flags = fcntl(nSocket, F_GETFL, 0); + flags |= O_NONBLOCK; + if (fcntl(nSocket, F_SETFL, flags) < 0) + { + throw ExceptionBase("Couldn't set socket options.\n"); + } + + /* Connect to the server. */ + //printf("Resolving hostname (%s)...\n", sAddr ); + { + struct hostent *hostinfo; + + xServerName.sin_family = AF_INET; + xServerName.sin_port = htons( nPort ); + hostinfo = gethostbyname( sAddr.getStr() ); + if (hostinfo == NULL) + { + throw ExceptionBase("Couldn't resolve hostname.\n"); + } + xServerName.sin_addr = *(struct in_addr *) hostinfo->h_addr; + } + + //printf("Making actual connection..."); + //fflush( stdout ); + connect( + nSocket, + (struct sockaddr *)&xServerName, + sizeof(xServerName) + ); + //printf("Connected.\n"); + + bActive = true; + + if( nTimeout > 0 ) + { + fd_set rfds, wfds, efds; + int retval; + + FD_ZERO(&rfds); + FD_SET(nSocket, &rfds); + FD_ZERO(&wfds); + FD_SET(nSocket, &wfds); + FD_ZERO(&efds); + FD_SET(nSocket, &efds); + + struct timeval tv; + tv.tv_sec = nTimeout; + tv.tv_usec = 0; + + retval = select( nSocket+1, &rfds, &wfds, &efds, &tv ); + + if( retval == 0 ) + { + close(); + throw ExceptionBase("Connection timeout.\n"); + } + + } +} + Bu::Socket::~Socket() { } +void Bu::Socket::close() +{ + if( bActive ) + { + fsync( nSocket ); + ::close( nSocket ); + } + bActive = false; + //xInputBuf.clearData(); + //xOutputBuf.clearData(); + //if( pProtocol != NULL ) + //{ + // delete pProtocol; + // pProtocol = NULL; + //} +} + +void Bu::Socket::read() +{ + char buffer[RBS]; + int nbytes; + int nTotalRead=0; + + for(;;) + { + //memset( buffer, 0, RBS ); + + nbytes = ::read( nSocket, buffer, RBS ); + if( nbytes < 0 && errno != 0 && errno != EAGAIN ) + { + //printf("errno: %d, %s\n", errno, strerror( errno ) ); + /* Read error. */ + //perror("readInput"); + throw ConnectionException( + excodeReadError, + "Read error: %s", + strerror( errno ) + ); + } + else + { + if( nbytes <= 0 ) + break; + nTotalRead += nbytes; + sReadBuf.append( buffer, nbytes ); + /* Data read. */ + if( nbytes < RBS ) + { + break; + } + + /* New test, if data is divisible by RBS bytes on some libs the + * read could block, this keeps it from happening. + */ + { + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(nSocket, &rfds); + struct timeval tv = { 0, 0 }; + int retval = select( nSocket+1, &rfds, NULL, NULL, &tv ); + if( retval == -1 ) + throw ConnectionException( + excodeBadReadError, + "Bad Read error" + ); + if( !FD_ISSET( nSocket, &rfds ) ) + break; + } + } + } + + /* + if( pProtocol != NULL && nTotalRead > 0 ) + { + pProtocol->onNewData(); + }*/ +} + +size_t Bu::Socket::read( void *pBuf, size_t nBytes ) +{ + read(); + + + + return sReadBuf.getSize(); +} + +size_t Bu::Socket::write( const void *pBuf, size_t nBytes ) +{ + int nWrote = TEMP_FAILURE_RETRY( ::write( nSocket, pBuf, nBytes ) ); + if( nWrote < 0 ) + { + throw ConnectionException( excodeWriteError, strerror(errno) ); + } + return nWrote; +} + +long Bu::Socket::tell() +{ + throw UnsupportedException(); +} + +void Bu::Socket::seek( long offset ) +{ + throw UnsupportedException(); +} + +void Bu::Socket::setPos( long pos ) +{ + throw UnsupportedException(); +} + +void Bu::Socket::setPosEnd( long pos ) +{ + throw UnsupportedException(); +} + +bool Bu::Socket::isEOS() +{ + return !bActive; +} + +bool Bu::Socket::canRead() +{ + return true; +} + +bool Bu::Socket::canWrite() +{ + return true; +} + +bool Bu::Socket::canSeek() +{ + return false; +} + diff --git a/src/socket.h b/src/socket.h index 8ccde71..3d0125d 100644 --- a/src/socket.h +++ b/src/socket.h @@ -4,6 +4,7 @@ #include #include "stream.h" +#include "fstring.h" namespace Bu { @@ -13,11 +14,29 @@ namespace Bu class Socket : public Stream { public: - Socket(); + Socket( int nSocket ); + Socket( const FString &sAddr, int nPort, int nTimeout=30 ); virtual ~Socket(); + + virtual void close(); + virtual void read(); + virtual size_t read( void *pBuf, size_t nBytes ); + virtual size_t write( const void *pBuf, size_t nBytes ); - private: + virtual long tell(); + virtual void seek( long offset ); + virtual void setPos( long pos ); + virtual void setPosEnd( long pos ); + virtual bool isEOS(); + + virtual bool canRead(); + virtual bool canWrite(); + virtual bool canSeek(); + private: + int nSocket; + bool bActive; + FString sReadBuf; }; } diff --git a/src/stream.h b/src/stream.h index ae94234..e640959 100644 --- a/src/stream.h +++ b/src/stream.h @@ -6,6 +6,16 @@ namespace Bu { + /** + * The basis for a completely general data transport mechanism. Anything + * that inherits from this should provide at least the basic read and/or + * write functions, and very probably the close function. Any functions + * that aren't supported should throw an exception if called. + * + * The constructor of a child class should pretty much universally be used + * to open the stream. I can't think of anything that should require an + * exception. + */ class Stream { public: -- cgit v1.2.3 From b7e40536df9bf9bbad3b2b7a59f33ebad25fc981 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 4 Jun 2007 23:49:26 +0000 Subject: Added rudimentary object tracking to Archive, and rearranged the hash and archive dependancies a little. I'll add docs for object tracking later... --- src/archive.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- src/archive.h | 44 ++++++++++++++++++++++++++++++++++++++++++-- src/hash.h | 7 ++++--- 3 files changed, 86 insertions(+), 6 deletions(-) (limited to 'src/archive.h') diff --git a/src/archive.cpp b/src/archive.cpp index c759477..7208bae 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -2,7 +2,8 @@ Bu::Archive::Archive( Stream &rStream, bool bLoading ) : bLoading( bLoading ), - rStream( rStream ) + rStream( rStream ), + nNextID( 1 ) { } @@ -345,3 +346,41 @@ Bu::Archive &Bu::operator>>( Bu::Archive &ar, std::string &s ) return ar; } +uint32_t Bu::Archive::getID( const void *ptr ) +{ + if( hPtrID.has( (int)ptr ) ) + return hPtrID.get( (int)ptr ); + hPtrID.insert( (int)ptr, nNextID ); + return nNextID++; +} + +void Bu::Archive::assocPtrID( void **ptr, uint32_t id ) +{ + if( hPtrID.has( id ) ) + { + *ptr = (void *)hPtrID.get( id ); + return; + } + + if( !hPtrDest.has( id ) ) + hPtrDest.insert( id, List() ); + + hPtrDest[id].value().append( ptr ); +} + +void Bu::Archive::readID( const void *ptr, uint32_t id ) +{ + hPtrID.insert( id, (int)ptr ); + + if( hPtrDest.has( id ) ) + { + Bu::List &l = hPtrDest.get( id ); + for( Bu::List::iterator i = l.begin(); i != l.end(); i++ ) + { + *(*i) = (void *)ptr; + } + + hPtrDest.erase( id ); + } +} + diff --git a/src/archive.h b/src/archive.h index 2f782d3..05c6f57 100644 --- a/src/archive.h +++ b/src/archive.h @@ -3,9 +3,11 @@ #include #include -#include "archival.h" -#include "stream.h" +#include "bu/archival.h" +#include "bu/stream.h" #include +#include "bu/hash.h" +#include "bu/list.h" namespace Bu { @@ -117,8 +119,15 @@ namespace Bu virtual Archive &operator&&(double &); virtual Archive &operator&&(long double &); + uint32_t getID( const void *ptr ); + void assocPtrID( void **ptr, uint32_t id ); + void readID( const void *ptr, uint32_t id ); + private: Stream &rStream; + uint32_t nNextID; + Hash hPtrID; + Hash > hPtrDest; }; Archive &operator<<(Archive &, class Bu::Archival &); @@ -168,6 +177,37 @@ namespace Bu return ar; } + + template + Archive &operator<<( Archive &ar, Hash &h ) + { + ar << h.size(); + for( typename Hash::iterator i = h.begin(); i != h.end(); i++ ) + { + std::pair p = *i; + ar << p.first << p.second; + } + + return ar; + } + + template + Archive &operator>>( Archive &ar, Hash &h ) + { + h.clear(); + uint32_t nSize; + ar >> nSize; + + for( uint32_t j = 0; j < nSize; j++ ) + { + key k; value v; + ar >> k >> v; + h.insert( k, v ); + } + + return ar; + } + } #endif diff --git a/src/hash.h b/src/hash.h index dc097df..f25c258 100644 --- a/src/hash.h +++ b/src/hash.h @@ -8,8 +8,8 @@ #include #include #include "exceptionbase.h" -#include "archival.h" -#include "archive.h" +///#include "archival.h" +///#include "archive.h" #define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0)) @@ -697,6 +697,7 @@ namespace Bu template<> uint32_t __calcHashCode( const std::string &k ); template<> bool __cmpHashKeys( const std::string &a, const std::string &b ); + /* template Archive &operator<<( Archive &ar, Hash &h ) { @@ -725,7 +726,7 @@ namespace Bu } return ar; - } + }*/ /* template -- cgit v1.2.3 From 932677862376e9642a496a15b7f09f1106f495a5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 28 Jun 2007 20:49:39 +0000 Subject: Many minor changes, hopefully the header fixes will keep future header macro conflicts from happening. And, from now on, other projects should do -Ilibbu++ not -Ilibbu++/src so we can get ready for an installed version of libbu++. --- bu | 1 + src/archival.h | 4 ++-- src/archive.h | 4 ++-- src/atom.h | 4 ++-- src/bzip2.h | 4 ++-- src/client.h | 4 ++-- src/exceptionbase.h | 4 ++-- src/exceptions.h | 4 ++-- src/file.h | 4 ++-- src/filter.h | 4 ++-- src/fstring.h | 4 ++-- src/hash.h | 4 ++-- src/ito.h | 4 ++-- src/itoatom.h | 4 ++-- src/itocondition.h | 4 ++-- src/itomutex.h | 4 ++-- src/itoqueue.h | 4 ++-- src/linkmessage.h | 4 ++-- src/list.h | 4 ++-- src/membuf.h | 4 ++-- src/paramproc.h | 4 ++-- src/plugger.h | 4 ++-- src/programchain.h | 4 ++-- src/programlink.h | 4 ++-- src/protocol.h | 4 ++-- src/ringbuffer.h | 4 ++-- src/server.h | 4 ++-- src/serversocket.h | 4 ++-- src/singleton.h | 4 ++-- src/socket.h | 4 ++-- src/sptr.h | 4 ++-- src/stream.h | 4 ++-- src/unitsuite.h | 4 ++-- 33 files changed, 65 insertions(+), 64 deletions(-) create mode 120000 bu (limited to 'src/archive.h') diff --git a/bu b/bu new file mode 120000 index 0000000..02b8847 --- /dev/null +++ b/bu @@ -0,0 +1 @@ +src/bu/ \ No newline at end of file diff --git a/src/archival.h b/src/archival.h index e2c803c..8be3308 100644 --- a/src/archival.h +++ b/src/archival.h @@ -1,5 +1,5 @@ -#ifndef ARCHIVAL_H -#define ARCHIVAL_H +#ifndef BU_ARCHIVAL_H +#define BU_ARCHIVAL_H namespace Bu { diff --git a/src/archive.h b/src/archive.h index 05c6f57..6c0c1df 100644 --- a/src/archive.h +++ b/src/archive.h @@ -1,5 +1,5 @@ -#ifndef ARCHIVE_H -#define ARCHIVE_H +#ifndef BU_ARCHIVE_H +#define BU_ARCHIVE_H #include #include diff --git a/src/atom.h b/src/atom.h index a0469b6..fad47eb 100644 --- a/src/atom.h +++ b/src/atom.h @@ -1,5 +1,5 @@ -#ifndef ATOM_H -#define ATOM_H +#ifndef BU_ATOM_H +#define BU_ATOM_H #include #include diff --git a/src/bzip2.h b/src/bzip2.h index 25f10c5..0a111e8 100644 --- a/src/bzip2.h +++ b/src/bzip2.h @@ -1,5 +1,5 @@ -#ifndef B_ZIP2_H -#define B_ZIP2_H +#ifndef BU_BZIP2_H +#define BU_BZIP2_H #include #include diff --git a/src/client.h b/src/client.h index 02ba077..cee558d 100644 --- a/src/client.h +++ b/src/client.h @@ -1,5 +1,5 @@ -#ifndef CLIENT_H -#define CLIENT_H +#ifndef BU_CLIENT_H +#define BU_CLIENT_H #include diff --git a/src/exceptionbase.h b/src/exceptionbase.h index fd78089..24e4bbf 100644 --- a/src/exceptionbase.h +++ b/src/exceptionbase.h @@ -1,5 +1,5 @@ -#ifndef EXCEPTION_BASE_H -#define EXCEPTION_BASE_H +#ifndef BU_EXCEPTION_BASE_H +#define BU_EXCEPTION_BASE_H #include #include diff --git a/src/exceptions.h b/src/exceptions.h index d5a9d39..b824b91 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -1,5 +1,5 @@ -#ifndef EXCEPTIONS_H -#define EXCEPTIONS_H +#ifndef BU_EXCEPTIONS_H +#define BU_EXCEPTIONS_H #include "exceptionbase.h" #include diff --git a/src/file.h b/src/file.h index 0f638a7..d4e43eb 100644 --- a/src/file.h +++ b/src/file.h @@ -1,5 +1,5 @@ -#ifndef FILE_H -#define FILE_H +#ifndef BU_FILE_H +#define BU_FILE_H #include diff --git a/src/filter.h b/src/filter.h index 7bb04bc..bd557b2 100644 --- a/src/filter.h +++ b/src/filter.h @@ -1,5 +1,5 @@ -#ifndef FILTER_H -#define FILTER_H +#ifndef BU_FILTER_H +#define BU_FILTER_H #include diff --git a/src/fstring.h b/src/fstring.h index 7180f5f..bf6518b 100644 --- a/src/fstring.h +++ b/src/fstring.h @@ -1,5 +1,5 @@ -#ifndef F_STRING_H -#define F_STRING_H +#ifndef BU_F_STRING_H +#define BU_F_STRING_H #include #include diff --git a/src/hash.h b/src/hash.h index 6c4a443..0fa3af7 100644 --- a/src/hash.h +++ b/src/hash.h @@ -1,5 +1,5 @@ -#ifndef HASH_H -#define HASH_H +#ifndef BU_HASH_H +#define BU_HASH_H #include #include diff --git a/src/ito.h b/src/ito.h index 01253f5..c062052 100644 --- a/src/ito.h +++ b/src/ito.h @@ -1,5 +1,5 @@ -#ifndef ITO_H -#define ITO_H +#ifndef BU_ITO_H +#define BU_ITO_H #include diff --git a/src/itoatom.h b/src/itoatom.h index 96090f2..7fc9090 100644 --- a/src/itoatom.h +++ b/src/itoatom.h @@ -1,5 +1,5 @@ -#ifndef ITO_QUEUE_H -#define ITO_QUEUE_H +#ifndef BU_ITO_QUEUE_H +#define BU_ITO_QUEUE_H #include diff --git a/src/itocondition.h b/src/itocondition.h index 4771b22..1793f81 100644 --- a/src/itocondition.h +++ b/src/itocondition.h @@ -1,5 +1,5 @@ -#ifndef ITO_CONDITION_H -#define ITO_CONDITION_H +#ifndef BU_ITO_CONDITION_H +#define BU_ITO_CONDITION_H #include diff --git a/src/itomutex.h b/src/itomutex.h index 80956b8..9c9d205 100644 --- a/src/itomutex.h +++ b/src/itomutex.h @@ -1,5 +1,5 @@ -#ifndef ITO_MUTEX_H -#define ITO_MUTEX_H +#ifndef BU_ITO_MUTEX_H +#define BU_ITO_MUTEX_H #include diff --git a/src/itoqueue.h b/src/itoqueue.h index 322698d..75a2f27 100644 --- a/src/itoqueue.h +++ b/src/itoqueue.h @@ -1,5 +1,5 @@ -#ifndef ITO_QUEUE_H -#define ITO_QUEUE_H +#ifndef BU_ITO_QUEUE_H +#define BU_ITO_QUEUE_H #include diff --git a/src/linkmessage.h b/src/linkmessage.h index 64b8bc2..baa22a6 100644 --- a/src/linkmessage.h +++ b/src/linkmessage.h @@ -1,8 +1,8 @@ /**\file linkmessage.h */ -#ifndef LINKMESSAGE_H -#define LINKMESSAGE_H +#ifndef BU_LINKMESSAGE_H +#define BU_LINKMESSAGE_H namespace Bu { diff --git a/src/list.h b/src/list.h index 314459e..6235619 100644 --- a/src/list.h +++ b/src/list.h @@ -1,5 +1,5 @@ -#ifndef LIST_H -#define LIST_H +#ifndef BU_LIST_H +#define BU_LIST_H #include #include "bu/exceptionbase.h" diff --git a/src/membuf.h b/src/membuf.h index 877b35e..b82f943 100644 --- a/src/membuf.h +++ b/src/membuf.h @@ -1,5 +1,5 @@ -#ifndef MEM_BUF_H -#define MEM_BUF_H +#ifndef BU_MEM_BUF_H +#define BU_MEM_BUF_H #include diff --git a/src/paramproc.h b/src/paramproc.h index beee4a0..2bca588 100644 --- a/src/paramproc.h +++ b/src/paramproc.h @@ -1,5 +1,5 @@ -#ifndef PARAM_PROC_H -#define PARAM_PROC_H +#ifndef BU_PARAM_PROC_H +#define BU_PARAM_PROC_H #include #include diff --git a/src/plugger.h b/src/plugger.h index 4d2e7af..79a3271 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -1,5 +1,5 @@ -#ifndef PLUGGER_H -#define PLUGGER_H +#ifndef BU_PLUGGER_H +#define BU_PLUGGER_H #include "bu/hash.h" diff --git a/src/programchain.h b/src/programchain.h index e73d659..336a9f1 100644 --- a/src/programchain.h +++ b/src/programchain.h @@ -1,5 +1,5 @@ -#ifndef PROGRAMCHAIN_H -#define PROGRAMCHAIN_H +#ifndef BU_PROGRAMCHAIN_H +#define BU_PROGRAMCHAIN_H #include "bu/list.h" #include "bu/linkmessage.h" diff --git a/src/programlink.h b/src/programlink.h index 7c31a18..07d7489 100644 --- a/src/programlink.h +++ b/src/programlink.h @@ -1,5 +1,5 @@ -#ifndef PROGRAMLINK_H -#define PROGRAMLINK_H +#ifndef BU_PROGRAMLINK_H +#define BU_PROGRAMLINK_H #include "bu/linkmessage.h" #include "bu/programchain.h" diff --git a/src/protocol.h b/src/protocol.h index 3accd99..c7a9275 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,5 +1,5 @@ -#ifndef PROTOCOL_H -#define PROTOCOL_H +#ifndef BU_PROTOCOL_H +#define BU_PROTOCOL_H #include diff --git a/src/ringbuffer.h b/src/ringbuffer.h index 625f65b..be80e2f 100644 --- a/src/ringbuffer.h +++ b/src/ringbuffer.h @@ -1,5 +1,5 @@ -#ifndef RING_BUFFER_H -#define RING_BUFFER_H +#ifndef BU_RING_BUFFER_H +#define BU_RING_BUFFER_H #include #include "bu/exceptionbase.h" diff --git a/src/server.h b/src/server.h index 07eef95..302b6e3 100644 --- a/src/server.h +++ b/src/server.h @@ -1,5 +1,5 @@ -#ifndef SERVER_H -#define SERVER_H +#ifndef BU_SERVER_H +#define BU_SERVER_H #include diff --git a/src/serversocket.h b/src/serversocket.h index cb86078..b4ee247 100644 --- a/src/serversocket.h +++ b/src/serversocket.h @@ -1,5 +1,5 @@ -#ifndef SERVER_SOCKET_H -#define SERVER_SOCKET_H +#ifndef BU_SERVER_SOCKET_H +#define BU_SERVER_SOCKET_H #include #include "bu/fstring.h" diff --git a/src/singleton.h b/src/singleton.h index 4976a61..c43d71b 100644 --- a/src/singleton.h +++ b/src/singleton.h @@ -1,5 +1,5 @@ -#ifndef SINGLETON_H -#define SINGLETON_H +#ifndef BU_SINGLETON_H +#define BU_SINGLETON_H #include diff --git a/src/socket.h b/src/socket.h index c9dbd8d..0ccee3b 100644 --- a/src/socket.h +++ b/src/socket.h @@ -1,5 +1,5 @@ -#ifndef SOCKET_H -#define SOCKET_H +#ifndef BU_SOCKET_H +#define BU_SOCKET_H #include diff --git a/src/sptr.h b/src/sptr.h index 4baa697..75851a6 100644 --- a/src/sptr.h +++ b/src/sptr.h @@ -1,5 +1,5 @@ -#ifndef SPTR_H -#define SPTR_H +#ifndef BU_SPTR_H +#define BU_SPTR_H #include #include diff --git a/src/stream.h b/src/stream.h index 056de0c..1e236a6 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,5 +1,5 @@ -#ifndef STREAM_H -#define STREAM_H +#ifndef BU_STREAM_H +#define BU_STREAM_H #include #include diff --git a/src/unitsuite.h b/src/unitsuite.h index 6e9270a..578b4cc 100644 --- a/src/unitsuite.h +++ b/src/unitsuite.h @@ -1,5 +1,5 @@ -#ifndef UNIT_SUITE_H -#define UNIT_SUITE_H +#ifndef BU_UNIT_SUITE_H +#define BU_UNIT_SUITE_H #include #include -- cgit v1.2.3 From 364b888d35f5acdef3721025e02210bce5ae3082 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 1 Jul 2007 06:17:28 +0000 Subject: A minor bugfix in the Bu::Archive was preventing compilation when archiving a Bu::Hash due to the new return value of the unary (*) extraction operator in the iterators. --- src/archive.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/archive.h') diff --git a/src/archive.h b/src/archive.h index 6c0c1df..a2d4c8f 100644 --- a/src/archive.h +++ b/src/archive.h @@ -184,8 +184,8 @@ namespace Bu ar << h.size(); for( typename Hash::iterator i = h.begin(); i != h.end(); i++ ) { - std::pair p = *i; - ar << p.first << p.second; + //std::pair p = *i; + ar << (i.getKey()) << (i.getValue()); } return ar; @@ -207,7 +207,6 @@ namespace Bu return ar; } - } #endif -- cgit v1.2.3