diff --git a/include/ebcl/Files.hh b/include/ebcl/Files.hh index fb6633c..63bd4ef 100644 --- a/include/ebcl/Files.hh +++ b/include/ebcl/Files.hh @@ -2,11 +2,11 @@ /* FILES **********************************************************************/ /******************************************************************************/ -#ifndef _H_LW_LIB_FILES -#define _H_LW_LIB_FILES -#include -#include -namespace lw { +#ifndef _H_EBCL_FILES +#define _H_EBCL_FILES +#include +#include +namespace ebcl { /*= FILE ACCESS ==============================================================*/ @@ -183,5 +183,5 @@ M_CLASS_POINTERS( FileOutputStream ); } -#endif // _H_LW_LIB_FILES -#include +#endif // _H_EBCL_FILES +#include diff --git a/include/ebcl/MemoryStreams.hh b/include/ebcl/MemoryStreams.hh index 024905e..1a3ab71 100644 --- a/include/ebcl/MemoryStreams.hh +++ b/include/ebcl/MemoryStreams.hh @@ -2,9 +2,10 @@ /* MEMORY STREAMS *************************************************************/ /******************************************************************************/ -#pragma once -#include -namespace lw { +#ifndef _H_EBCL_MEMORYSTREAMS +#define _H_EBCL_MEMORYSTREAMS +#include +namespace ebcl { class T_MemoryInputStream final : public A_InputStream @@ -59,4 +60,5 @@ M_CLASS_POINTERS( MemoryOutputStream ); } // namespace -#include +#include +#endif // _H_EBCL_MEMORYSTREAMS diff --git a/include/ebcl/Utilities.hh b/include/ebcl/Utilities.hh index 337282b..54c497a 100644 --- a/include/ebcl/Utilities.hh +++ b/include/ebcl/Utilities.hh @@ -232,7 +232,7 @@ template< typename T > // M_DEFINE_SWAP( Type ) - Define the swap function for a given type #define M_DEFINE_SWAP( Type ) \ - void lw::swap( Type& lhs , Type& rhs ) noexcept + void swap( Type& lhs , Type& rhs ) noexcept /*= ENDIAN DETECTION =========================================================*/ diff --git a/include/ebcl/inline/Files.hh b/include/ebcl/inline/Files.hh index e4fdf83..8c62375 100644 --- a/include/ebcl/inline/Files.hh +++ b/include/ebcl/inline/Files.hh @@ -2,10 +2,10 @@ /* FILES - INLINE CODE ********************************************************/ /******************************************************************************/ -#ifndef _H_LW_LIB_INLINE_FILES -#define _H_LW_LIB_INLINE_FILES -#include -namespace lw { +#ifndef _H_EBCL_INLINE_FILES +#define _H_EBCL_INLINE_FILES +#include +namespace ebcl { /*= T_File ===================================================================*/ @@ -96,4 +96,4 @@ inline size_t T_FileOutputStream::offset( ) const noexcept } // namespace -#endif // _H_LW_LIB_INLINE_FILES +#endif // _H_EBCL_INLINE_FILES diff --git a/include/ebcl/inline/MemoryStreams.hh b/include/ebcl/inline/MemoryStreams.hh index f6b1adc..3435017 100644 --- a/include/ebcl/inline/MemoryStreams.hh +++ b/include/ebcl/inline/MemoryStreams.hh @@ -2,9 +2,10 @@ /* MEMORY STREAMS - INLINE CODE ***********************************************/ /******************************************************************************/ -#pragma once -#include -namespace lw { +#ifndef _H_EBCL_INLINE_MEMORYSTREAMS +#define _H_EBCL_INLINE_MEMORYSTREAMS +#include +namespace ebcl { /*= T_MemoryInputStream ======================================================*/ @@ -41,3 +42,4 @@ inline T_MemoryOutputStream::T_MemoryOutputStream( T_Buffer< T >& buffer ) } // namespace +#endif // _H_EBCL_INLINE_MEMORYSTREAMS diff --git a/src/Files.cc b/src/Files.cc index 933204c..0c36449 100644 --- a/src/Files.cc +++ b/src/Files.cc @@ -3,8 +3,8 @@ /******************************************************************************/ -#include -using namespace lw; +#include +using namespace ebcl; /*= T_File ==================================================================*/ @@ -41,20 +41,17 @@ void T_File::open( ) const T_Buffer< char > path( path_.toOSString( ) ); // Select the right mode - char const* mode; - switch ( mode_ ) { - case E_FileMode::READ_ONLY: - mode = "rb"; - break; - - case E_FileMode::READ_WRITE: - mode = "rb+"; - break; - - case E_FileMode::OVERWRITE: - mode = "wb+"; - break; - } + char const* const mode( ([this]() { + switch ( mode_ ) { + case E_FileMode::READ_ONLY: + return "rb"; + case E_FileMode::READ_WRITE: + return "rb+"; + case E_FileMode::OVERWRITE: + return "wb+"; + } + std::abort( ); + })( ) ); // Open the file #ifdef WIN32_ diff --git a/src/MemoryStreams.cc b/src/MemoryStreams.cc index 52646fb..00bc0a4 100644 --- a/src/MemoryStreams.cc +++ b/src/MemoryStreams.cc @@ -2,8 +2,8 @@ /* MEMORY STREAMS *************************************************************/ /******************************************************************************/ -#include -using namespace lw; +#include +using namespace ebcl; /*= T_MemoryInputStream ======================================================*/ diff --git a/src/files.mk b/src/files.mk index 1dd1515..78bab9e 100644 --- a/src/files.mk +++ b/src/files.mk @@ -1,5 +1,7 @@ LIB_SOURCES = \ + src/Files.cc \ src/HashIndex.cc \ + src/MemoryStreams.cc \ src/Pointers.cc \ src/Streams.cc \ src/Strings.cc \ @@ -8,8 +10,6 @@ LIB_SOURCES = \ # END # -# src/Files.cc \ -# src/MemoryStreams.cc \ # src/SRDBinary.cc \ # src/SRDData.cc \ # src/SRDDefinitions.cc \ diff --git a/tests/binary-reader.cc b/tests/binary-reader.cc index 74c37ce..c4c2604 100644 --- a/tests/binary-reader.cc +++ b/tests/binary-reader.cc @@ -1,10 +1,11 @@ -#include -#include +#include +#include #include -using namespace lw; +using namespace ebcl; -/* - StreamReaderTest ---------------------------------------------------{{{-*/ +/* - StreamReaderTest -------------------------------------------------------*/ + class StreamReaderTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( StreamReaderTest ); @@ -40,7 +41,7 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION( StreamReaderTest ); -void StreamReaderTest::testNumericBigEndian8( ) // {{{ +void StreamReaderTest::testNumericBigEndian8( ) { const uint8_t data[] = { 0x12 }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -49,8 +50,7 @@ void StreamReaderTest::testNumericBigEndian8( ) // {{{ rd.readNumericBigEndian< uint8_t >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian8( ) // {{{ +void StreamReaderTest::testNumericLittleEndian8( ) { const uint8_t data[] = { 0x12 }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -59,8 +59,7 @@ void StreamReaderTest::testNumericLittleEndian8( ) // {{{ rd.readNumericLittleEndian< uint8_t >( ) ); } -// }}} -void StreamReaderTest::testNumericBigEndian16( ) // {{{ +void StreamReaderTest::testNumericBigEndian16( ) { const uint8_t data[] = { 0xbe , 0xef }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -69,8 +68,7 @@ void StreamReaderTest::testNumericBigEndian16( ) // {{{ rd.readNumericBigEndian< uint16_t >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian16( ) // {{{ +void StreamReaderTest::testNumericLittleEndian16( ) { const uint8_t data[] = { 0xbe , 0xef }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -79,8 +77,7 @@ void StreamReaderTest::testNumericLittleEndian16( ) // {{{ rd.readNumericLittleEndian< uint16_t >( ) ); } -// }}} -void StreamReaderTest::testNumericBigEndian32( ) // {{{ +void StreamReaderTest::testNumericBigEndian32( ) { const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -89,8 +86,7 @@ void StreamReaderTest::testNumericBigEndian32( ) // {{{ rd.readNumericBigEndian< uint32_t >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian32( ) // {{{ +void StreamReaderTest::testNumericLittleEndian32( ) { const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -99,8 +95,7 @@ void StreamReaderTest::testNumericLittleEndian32( ) // {{{ rd.readNumericLittleEndian< uint32_t >( ) ); } -// }}} -void StreamReaderTest::testNumericBigEndian32f( ) // {{{ +void StreamReaderTest::testNumericBigEndian32f( ) { const uint8_t data[] = { 0x3f , 0x80 , 0x00 , 0x00 }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -108,8 +103,7 @@ void StreamReaderTest::testNumericBigEndian32f( ) // {{{ CPPUNIT_ASSERT_EQUAL( 1.0f , rd.readNumericBigEndian< float >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian32f( ) // {{{ +void StreamReaderTest::testNumericLittleEndian32f( ) { const uint8_t data[] = { 0x00 , 0x00 , 0x80 , 0x3f }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -117,8 +111,7 @@ void StreamReaderTest::testNumericLittleEndian32f( ) // {{{ CPPUNIT_ASSERT_EQUAL( 1.0f , rd.readNumericLittleEndian< float >( ) ); } -// }}} -void StreamReaderTest::testNumericBigEndian64( ) // {{{ +void StreamReaderTest::testNumericBigEndian64( ) { const uint8_t data[] = { 0xba , 0xdb , 0xa7 , 0x5e , 0xa7 , 0xba , 0xb1 , 0x35 @@ -129,8 +122,7 @@ void StreamReaderTest::testNumericBigEndian64( ) // {{{ rd.readNumericBigEndian< uint64_t >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian64( ) // {{{ +void StreamReaderTest::testNumericLittleEndian64( ) { const uint8_t data[] = { 0x35 , 0xb1 , 0xba , 0xa7 , 0x5e , 0xa7 , 0xdb , 0xba , @@ -141,8 +133,7 @@ void StreamReaderTest::testNumericLittleEndian64( ) // {{{ rd.readNumericLittleEndian< uint64_t >( ) ); } -// }}} -void StreamReaderTest::testNumericBigEndian64f( ) // {{{ +void StreamReaderTest::testNumericBigEndian64f( ) { const uint8_t data[] = { 0x3f , 0xf0 , 0 , 0 , 0 , 0 , 0 , 0 }; T_MemoryInputStream ms( data , sizeof( data ) ); @@ -150,15 +141,10 @@ void StreamReaderTest::testNumericBigEndian64f( ) // {{{ CPPUNIT_ASSERT_EQUAL( 1.0 , rd.readNumericBigEndian< double >( ) ); } -// }}} -void StreamReaderTest::testNumericLittleEndian64f( ) // {{{ +void StreamReaderTest::testNumericLittleEndian64f( ) { const uint8_t data[] = { 0 , 0 , 0 , 0 , 0 , 0 , 0xf0 , 0x3f }; T_MemoryInputStream ms( data , sizeof( data ) ); T_BinaryReader rd( ms ); CPPUNIT_ASSERT_EQUAL( 1.0 , rd.readNumericLittleEndian< double >( ) ); } - -// }}} - -/*------------------------------------------------------------------------}}}-*/ diff --git a/tests/binary-writer.cc b/tests/binary-writer.cc index e575bb9..aa5705b 100644 --- a/tests/binary-writer.cc +++ b/tests/binary-writer.cc @@ -1,10 +1,11 @@ -#include -#include +#include +#include #include -using namespace lw; +using namespace ebcl; -/* - BinaryWriterTest ---------------------------------------------------{{{-*/ +/* - BinaryWriterTest -------------------------------------------------------*/ + class BinaryWriterTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( BinaryWriterTest ); @@ -40,7 +41,7 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION( BinaryWriterTest ); -void BinaryWriterTest::testNumericBigEndian8( ) // {{{ +void BinaryWriterTest::testNumericBigEndian8( ) { const uint8_t data[] = { 0x12 }; T_Buffer< uint8_t > buffer; @@ -54,8 +55,7 @@ void BinaryWriterTest::testNumericBigEndian8( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian8( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian8( ) { const uint8_t data[] = { 0x12 }; T_Buffer< uint8_t > buffer; @@ -69,8 +69,7 @@ void BinaryWriterTest::testNumericLittleEndian8( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericBigEndian16( ) // {{{ +void BinaryWriterTest::testNumericBigEndian16( ) { const uint8_t data[] = { 0xbe , 0xef }; T_Buffer< uint8_t > buffer; @@ -84,8 +83,7 @@ void BinaryWriterTest::testNumericBigEndian16( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian16( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian16( ) { const uint8_t data[] = { 0xbe , 0xef }; T_Buffer< uint8_t > buffer; @@ -99,8 +97,7 @@ void BinaryWriterTest::testNumericLittleEndian16( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericBigEndian32( ) // {{{ +void BinaryWriterTest::testNumericBigEndian32( ) { const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef }; T_Buffer< uint8_t > buffer; @@ -114,8 +111,7 @@ void BinaryWriterTest::testNumericBigEndian32( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian32( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian32( ) { const uint8_t data[] = { 0xde , 0xad , 0xbe , 0xef }; T_Buffer< uint8_t > buffer; @@ -129,8 +125,7 @@ void BinaryWriterTest::testNumericLittleEndian32( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericBigEndian32f( ) // {{{ +void BinaryWriterTest::testNumericBigEndian32f( ) { const uint8_t data[] = { 0x3f , 0x80 , 0x00 , 0x00 }; T_Buffer< uint8_t > buffer; @@ -144,8 +139,7 @@ void BinaryWriterTest::testNumericBigEndian32f( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian32f( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian32f( ) { const uint8_t data[] = { 0x00 , 0x00 , 0x80 , 0x3f }; T_Buffer< uint8_t > buffer; @@ -159,8 +153,7 @@ void BinaryWriterTest::testNumericLittleEndian32f( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericBigEndian64( ) // {{{ +void BinaryWriterTest::testNumericBigEndian64( ) { const uint8_t data[] = { 0xba , 0xdb , 0xa7 , 0x5e , 0xa7 , 0xba , 0xb1 , 0x35 @@ -176,8 +169,7 @@ void BinaryWriterTest::testNumericBigEndian64( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian64( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian64( ) { const uint8_t data[] = { 0x35 , 0xb1 , 0xba , 0xa7 , 0x5e , 0xa7 , 0xdb , 0xba , @@ -193,8 +185,7 @@ void BinaryWriterTest::testNumericLittleEndian64( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericBigEndian64f( ) // {{{ +void BinaryWriterTest::testNumericBigEndian64f( ) { const uint8_t data[] = { 0x3f , 0xf0 , 0 , 0 , 0 , 0 , 0 , 0 }; T_Buffer< uint8_t > buffer; @@ -208,8 +199,7 @@ void BinaryWriterTest::testNumericBigEndian64f( ) // {{{ } } -// }}} -void BinaryWriterTest::testNumericLittleEndian64f( ) // {{{ +void BinaryWriterTest::testNumericLittleEndian64f( ) { const uint8_t data[] = { 0 , 0 , 0 , 0 , 0 , 0 , 0xf0 , 0x3f }; T_Buffer< uint8_t > buffer; @@ -222,7 +212,3 @@ void BinaryWriterTest::testNumericLittleEndian64f( ) // {{{ CPPUNIT_ASSERT_EQUAL( data[ i ] , buffer[ i ] ); } } - -// }}} - -/*------------------------------------------------------------------------}}}-*/ diff --git a/tests/buffers.cc b/tests/buffers.cc index 1c25a66..a9c9c6c 100644 --- a/tests/buffers.cc +++ b/tests/buffers.cc @@ -1,6 +1,6 @@ -#include +#include #include -using namespace lw; +using namespace ebcl; class FixedBufferTest : public CppUnit::TestFixture diff --git a/tests/list.mk b/tests/list.mk index bd6d908..f033b11 100644 --- a/tests/list.mk +++ b/tests/list.mk @@ -1,4 +1,5 @@ TESTS = \ + buffers \ ptr-owned \ ptr-shared \ ptr-weak \ @@ -8,6 +9,12 @@ TESTS = \ arrays-static-objects \ arrays-auto \ arrays-multi \ + strings \ + strings-iterator \ + strings-storage \ + strings-builder \ + binary-reader \ + binary-writer \ optional \ union \ variant \ @@ -18,14 +25,7 @@ TESTS = \ #TESTS = \ # alloc-pool \ -# buffers \ # ring-buffer \ -# strings \ -# strings-iterator \ -# strings-storage \ -# strings-builder \ -# binary-reader \ -# binary-writer \ # stream-file-input \ # srd-bin-reader \ # srd-bin-writer \ diff --git a/tests/strings-builder.cc b/tests/strings-builder.cc index 2637e4f..586b322 100644 --- a/tests/strings-builder.cc +++ b/tests/strings-builder.cc @@ -1,7 +1,7 @@ -#include +#include #include #include -using namespace lw; +using namespace ebcl; class StringsBuilderTest : public CppUnit::TestFixture diff --git a/tests/strings-iterator.cc b/tests/strings-iterator.cc index 35ac1a5..06c89a4 100644 --- a/tests/strings-iterator.cc +++ b/tests/strings-iterator.cc @@ -1,6 +1,6 @@ -#include +#include #include -using namespace lw; +using namespace ebcl; class StringsIteratorTest : public CppUnit::TestFixture diff --git a/tests/strings-storage.cc b/tests/strings-storage.cc index 583b1b2..25de92d 100644 --- a/tests/strings-storage.cc +++ b/tests/strings-storage.cc @@ -1,6 +1,6 @@ -#include +#include #include -using namespace lw; +using namespace ebcl; /*= StringsDynamicTest ========================================================*/ diff --git a/tests/strings.cc b/tests/strings.cc index 81b354b..ee8086c 100644 --- a/tests/strings.cc +++ b/tests/strings.cc @@ -1,6 +1,6 @@ -#include +#include #include -using namespace lw; +using namespace ebcl; class StringsTest : public CppUnit::TestFixture