From b323460dbb380fa10fbfb5fc7aed66afe9bf86be Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 10 Jun 2019 22:44:29 +0200 Subject: [PATCH] Adapt to changes in c++utilities --- io/entry.cpp | 3 +-- io/field.cpp | 3 +-- io/passwordfile.cpp | 9 ++++----- io/passwordfile.h | 10 +++++----- tests/entrytests.cpp | 4 ++-- tests/fieldtests.cpp | 4 ++-- tests/opensslrandomdevice.cpp | 2 +- tests/opensslutils.cpp | 4 ++-- tests/passwordfiletests.cpp | 15 +++++++-------- tests/utils.h | 6 +++--- util/opensslrandomdevice.cpp | 3 ++- 11 files changed, 30 insertions(+), 33 deletions(-) diff --git a/io/entry.cpp b/io/entry.cpp index 29cec65..efc7bb6 100644 --- a/io/entry.cpp +++ b/io/entry.cpp @@ -9,8 +9,7 @@ #include using namespace std; -using namespace IoUtilities; -using namespace ConversionUtilities; +using namespace CppUtilities; namespace Io { diff --git a/io/field.cpp b/io/field.cpp index 6168933..95944db 100644 --- a/io/field.cpp +++ b/io/field.cpp @@ -5,8 +5,7 @@ #include using namespace std; -using namespace IoUtilities; -using namespace ConversionUtilities; +using namespace CppUtilities; namespace Io { diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index b928f8b..97aae51 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -24,8 +24,7 @@ #include using namespace std; -using namespace ConversionUtilities; -using namespace IoUtilities; +using namespace CppUtilities; namespace Io { @@ -321,7 +320,7 @@ void PasswordFile::load() if (remainingSize > numeric_limits::max()) { throw CryptoException("Size exceeds limit."); } - const auto rawDecompressedSize = ConversionUtilities::LE::toUInt64(decryptedData.data()); + const auto rawDecompressedSize = LE::toUInt64(decryptedData.data()); if (rawDecompressedSize > numeric_limits::max()) { throw ParsingException("Decompressed size exceeds limit."); } @@ -477,7 +476,7 @@ void PasswordFile::write(PasswordFileSaveFlags options) if (options & PasswordFileSaveFlags::Compression) { uLongf compressedSize = compressBound(size); encryptedData.resize(8 + compressedSize); - ConversionUtilities::LE::getBytes(static_cast(size), encryptedData.data()); + LE::getBytes(static_cast(size), encryptedData.data()); switch ( compress(reinterpret_cast(encryptedData.data() + 8), &compressedSize, reinterpret_cast(decryptedData.data()), size)) { case Z_MEM_ERROR: @@ -685,7 +684,7 @@ void PasswordFile::setPath(const string &value) m_path = value; // support "file://" protocol - if (ConversionUtilities::startsWith(m_path, "file:")) { + if (startsWith(m_path, "file:")) { m_path = m_path.substr(5); } } diff --git a/io/passwordfile.h b/io/passwordfile.h index 1d24f89..179be56 100644 --- a/io/passwordfile.h +++ b/io/passwordfile.h @@ -78,7 +78,7 @@ public: PasswordFile(const PasswordFile &other); PasswordFile(PasswordFile &&other); ~PasswordFile(); - IoUtilities::NativeFileStream &fileStream(); + CppUtilities::NativeFileStream &fileStream(); void open(PasswordFileOpenFlags options = PasswordFileOpenFlags::Default); void opened(); void generateRootEntry(); @@ -120,9 +120,9 @@ private: std::unique_ptr m_rootEntry; std::string m_extendedHeader; std::string m_encryptedExtendedHeader; - IoUtilities::NativeFileStream m_file; - IoUtilities::BinaryReader m_freader; - IoUtilities::BinaryWriter m_fwriter; + CppUtilities::NativeFileStream m_file; + CppUtilities::BinaryReader m_freader; + CppUtilities::BinaryWriter m_fwriter; std::uint32_t m_version; PasswordFileOpenFlags m_openOptions; PasswordFileSaveFlags m_saveOptions; @@ -131,7 +131,7 @@ private: /*! * \brief Returns the underlying file stream. */ -inline IoUtilities::NativeFileStream &PasswordFile::fileStream() +inline CppUtilities::NativeFileStream &PasswordFile::fileStream() { return m_file; } diff --git a/tests/entrytests.cpp b/tests/entrytests.cpp index e0d78dc..91bd3e1 100644 --- a/tests/entrytests.cpp +++ b/tests/entrytests.cpp @@ -3,14 +3,14 @@ #include "./utils.h" #include -using namespace TestUtilities; +using namespace CppUtilities; #include #include using namespace std; using namespace Io; -using namespace TestUtilities::Literals; +using namespace CppUtilities::Literals; using namespace CPPUNIT_NS; diff --git a/tests/fieldtests.cpp b/tests/fieldtests.cpp index 95266fa..f66861e 100644 --- a/tests/fieldtests.cpp +++ b/tests/fieldtests.cpp @@ -4,14 +4,14 @@ #include "./utils.h" #include -using namespace TestUtilities; +using namespace CppUtilities; #include #include using namespace std; using namespace Io; -using namespace TestUtilities::Literals; +using namespace CppUtilities::Literals; using namespace CPPUNIT_NS; diff --git a/tests/opensslrandomdevice.cpp b/tests/opensslrandomdevice.cpp index f83676b..5cdcdfd 100644 --- a/tests/opensslrandomdevice.cpp +++ b/tests/opensslrandomdevice.cpp @@ -9,7 +9,7 @@ using namespace std; using namespace Util; -using namespace TestUtilities::Literals; +using namespace CppUtilities::Literals; using namespace CPPUNIT_NS; diff --git a/tests/opensslutils.cpp b/tests/opensslutils.cpp index d8d3701..a5cc880 100644 --- a/tests/opensslutils.cpp +++ b/tests/opensslutils.cpp @@ -10,8 +10,8 @@ using namespace std; using namespace Util::OpenSsl; -using namespace ConversionUtilities; -using namespace TestUtilities::Literals; +using namespace CppUtilities; +using namespace CppUtilities::Literals; using namespace CPPUNIT_NS; diff --git a/tests/passwordfiletests.cpp b/tests/passwordfiletests.cpp index 9aa96a9..fc11a23 100644 --- a/tests/passwordfiletests.cpp +++ b/tests/passwordfiletests.cpp @@ -9,8 +9,8 @@ using namespace std; using namespace Io; -using namespace TestUtilities::Literals; - +using namespace CppUtilities; +using namespace CppUtilities::Literals; using namespace CPPUNIT_NS; /*! @@ -49,8 +49,7 @@ void PasswordFileTests::tearDown() */ void PasswordFileTests::testReading() { - testReading( - "read", TestUtilities::testFilePath("testfile1.pwmgr"), "123456", TestUtilities::testFilePath("testfile2.pwmgr"), string(), false, false); + testReading("read", testFilePath("testfile1.pwmgr"), "123456", testFilePath("testfile2.pwmgr"), string(), false, false); } void PasswordFileTests::testReading(const string &context, const string &testfile1path, const string &testfile1password, const string &testfile2, @@ -153,8 +152,8 @@ void PasswordFileTests::testReading(const string &context, const string &testfil */ void PasswordFileTests::testBasicWriting() { - const string testfile1 = TestUtilities::workingCopyPath("testfile1.pwmgr"); - const string testfile2 = TestUtilities::workingCopyPath("testfile2.pwmgr"); + const string testfile1 = workingCopyPath("testfile1.pwmgr"); + const string testfile2 = workingCopyPath("testfile2.pwmgr"); PasswordFile file; // resave testfile 1 @@ -187,8 +186,8 @@ void PasswordFileTests::testBasicWriting() */ void PasswordFileTests::testExtendedWriting() { - const string testfile1 = TestUtilities::workingCopyPath("testfile1.pwmgr"); - const string testfile2 = TestUtilities::workingCopyPath("testfile2.pwmgr"); + const string testfile1 = workingCopyPath("testfile1.pwmgr"); + const string testfile2 = workingCopyPath("testfile2.pwmgr"); PasswordFile file; // resave testfile 1 diff --git a/tests/utils.h b/tests/utils.h index 67675a7..d8d5b34 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -9,11 +9,11 @@ #include -namespace TestUtilities { +namespace CppUtilities { inline std::ostream &operator<<(std::ostream &out, const Io::Entry *entry) { - return out << ConversionUtilities::joinStrings(entry->path(), "/"); + return out << joinStrings(entry->path(), "/"); } inline std::ostream &operator<<(std::ostream &out, const Io::Field *field) @@ -21,6 +21,6 @@ inline std::ostream &operator<<(std::ostream &out, const Io::Field *field) return out << field->name() << '=' << field->value(); } -} // namespace TestUtilities +} // namespace CppUtilities #endif // PASSWORDFILE_TESTS_UTILS_H diff --git a/util/opensslrandomdevice.cpp b/util/opensslrandomdevice.cpp index 9512dc2..30f3450 100644 --- a/util/opensslrandomdevice.cpp +++ b/util/opensslrandomdevice.cpp @@ -10,6 +10,7 @@ #include using namespace std; +using namespace CppUtilities; namespace Util { @@ -32,7 +33,7 @@ OpenSslRandomDevice::result_type OpenSslRandomDevice::operator()() const { unsigned char buf[4]; if (RAND_bytes(buf, sizeof(buf))) { - return ConversionUtilities::LE::toUInt32(reinterpret_cast(buf)); + return LE::toUInt32(reinterpret_cast(buf)); } // handle error case