From ddd6ebd637aa7da2daae7e2d70a968b3aa04eb91 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Wed, 15 Feb 2012 07:45:56 +0000 Subject: [PATCH] some workarond for MS Visual git-svn-id: svn://ttmath.org/publicrep/tito/trunk@385 e52654a7-88a9-db11-a3e9-0013d4bc506e --- src/crypto.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/crypto.h | 9 +++++++++ 2 files changed, 46 insertions(+) diff --git a/src/crypto.cpp b/src/crypto.cpp index cf33e27..7f0cc49 100755 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -48,6 +48,43 @@ namespace Tito { +void Crypto::AssignString(const char * src, size_t len, std::wstring & dst, bool clear) +{ + if( clear ) + dst.clear(); + + if( dst.capacity() < dst.size() + len ) + dst.reserve(dst.size() + len + 128); + + for(size_t i=0 ; i(src[i]); +} + +void Crypto::AssignString(const wchar_t * src, size_t len, std::string & dst, bool clear) +{ + if( clear ) + dst.clear(); + + if( dst.capacity() < dst.size() + len ) + dst.reserve(dst.size() + len + 128); + + for(size_t i=0 ; i(src[i]); +} + + +void Crypto::AssignString(const std::string & src, std::wstring & dst, bool clear) +{ + AssignString(src.c_str(), src.size(), dst, clear); +} + +void Crypto::AssignString(const std::wstring & src, std::string & dst, bool clear) +{ + AssignString(src.c_str(), src.size(), dst, clear); +} + + + bool Crypto::SetAESKey(unsigned char aes_key[32]) { diff --git a/src/crypto.h b/src/crypto.h index cc0cde6..08a0562 100755 --- a/src/crypto.h +++ b/src/crypto.h @@ -106,6 +106,15 @@ private: void Clear(); + + // temporarily fix for Visual Studio + // crypto.obj : error LNK2001: unresolved external symbol "void __cdecl Tito::AssignString(char const *,unsigned int,class std::basic_string,class std::allocator > &,bool)" (?AssignString@Tito@@YAXPBDIAAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@_N@Z) + void AssignString(const char * src, size_t len, std::wstring & dst, bool clear = true); + void AssignString(const wchar_t * src, size_t len, std::string & dst, bool clear = true); + void AssignString(const std::string & src, std::wstring & dst, bool clear = true); + void AssignString(const std::wstring & src, std::string & dst, bool clear = true); + + };