Changeset 763 in dev for trunk/ab5.0/jenga
- Timestamp:
- Nov 6, 2008, 10:22:26 PM (16 years ago)
- Location:
- trunk/ab5.0/jenga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/jenga/include/common/String.h
r747 r763 9 9 bool IsExistString( const Jenga::Common::Strings &strings, const std::string &findStr ); 10 10 11 std::string& StringReplace( std::string& str, const std::string sb, const std::stringsa );11 std::string& StringReplace( std::string& str, const std::string &sb, const std::string &sa ); 12 12 13 13 std::string ToString( int n ); -
trunk/ab5.0/jenga/projects/jenga/stdafx.h
r521 r763 19 19 #include <io.h> 20 20 #include <imagehlp.h> 21 #include <assert.h> 21 22 22 23 //boost libraries -
trunk/ab5.0/jenga/src/common/String.cpp
r748 r763 1 1 #include "stdafx.h" 2 #include <algorithm> 2 3 3 4 bool Jenga::Common::IsExistString( const Jenga::Common::Strings &strings, const std::string &findStr ) 4 5 { 5 BOOST_FOREACH( const std::string &str, strings ) 6 { 7 if( str == findStr ) 8 { 9 return true; 10 } 11 } 12 return false; 6 return std::find( strings.begin(), strings.end(), findStr ) != strings.end(); 13 7 } 14 8 15 std::string& Jenga::Common::StringReplace( std::string& str, const std::string sb, const std::stringsa )9 std::string& Jenga::Common::StringReplace( std::string& str, const std::string &sb, const std::string &sa ) 16 10 { 17 11 std::string::size_type n, nb = 0; … … 38 32 CP_THREAD_ACP, 39 33 0, 40 wstr. c_str(), -1,34 wstr.data(), static_cast<int>(wstr.size()), 41 35 NULL, NULL, 42 36 NULL, NULL ); 43 37 44 char *pstr = (char *)calloc( needSize + 1, 1 );38 char *pstr = (char *)calloc( needSize, 1 ); 45 39 WideCharToMultiByte( 46 40 CP_THREAD_ACP, 47 41 0, 48 wstr. c_str(), -1,42 wstr.data(), static_cast<int>(wstr.size()), 49 43 pstr, needSize, 50 44 NULL, NULL ); 51 45 52 std::string result = pstr;46 std::string result(pstr, needSize); 53 47 54 48 free( pstr ); … … 62 56 CP_ACP, 63 57 0, 64 str. c_str(), static_cast<int>(str.size()) + 1,65 NULL, 0 ) * 4;58 str.data(), static_cast<int>(str.size()), 59 NULL, 0 ); 66 60 67 LPWSTR pwstr = (LPWSTR)calloc( size, 1);61 LPWSTR pwstr = (LPWSTR)calloc( size, sizeof (wchar_t) ); 68 62 69 63 MultiByteToWideChar( 70 64 CP_ACP, 71 65 0, 72 str. c_str(), static_cast<int>(str.size()) + 1,73 pwstr, s tatic_cast<int>(str.size()) + 1);66 str.data(), static_cast<int>(str.size()), 67 pwstr, size ); 74 68 75 std::wstring wstr( pwstr, s tr.size());69 std::wstring wstr( pwstr, size ); 76 70 77 71 free( pwstr );
Note:
See TracChangeset
for help on using the changeset viewer.