Ignore:
Timestamp:
Nov 6, 2008, 10:22:26 PM (15 years ago)
Author:
イグトランス (egtra)
Message:

#228試行

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/jenga/src/common/String.cpp

    r748 r763  
    11#include "stdafx.h"
     2#include <algorithm>
    23
    34bool Jenga::Common::IsExistString( const Jenga::Common::Strings &strings, const std::string &findStr )
    45{
    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();
    137}
    148
    15 std::string& Jenga::Common::StringReplace( std::string& str, const std::string sb, const std::string sa )
     9std::string& Jenga::Common::StringReplace( std::string& str, const std::string &sb, const std::string &sa )
    1610{
    1711    std::string::size_type n, nb = 0;
     
    3832        CP_THREAD_ACP,
    3933        0,
    40         wstr.c_str(), -1,
     34        wstr.data(), static_cast<int>(wstr.size()),
    4135        NULL, NULL,
    4236        NULL, NULL );
    4337
    44     char *pstr = (char *)calloc( needSize + 1, 1 );
     38    char *pstr = (char *)calloc( needSize, 1 );
    4539    WideCharToMultiByte(
    4640        CP_THREAD_ACP,
    4741        0,
    48         wstr.c_str(), -1,
     42        wstr.data(), static_cast<int>(wstr.size()),
    4943        pstr, needSize,
    5044        NULL, NULL );
    5145
    52     std::string result = pstr;
     46    std::string result(pstr, needSize);
    5347
    5448    free( pstr );
     
    6256        CP_ACP,
    6357        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 );
    6660
    67     LPWSTR pwstr = (LPWSTR)calloc( size, 1 );
     61    LPWSTR pwstr = (LPWSTR)calloc( size, sizeof (wchar_t) );
    6862
    6963    MultiByteToWideChar(
    7064        CP_ACP,
    7165        0,
    72         str.c_str(), static_cast<int>(str.size()) + 1,
    73         pwstr, static_cast<int>(str.size()) + 1 );
     66        str.data(), static_cast<int>(str.size()),
     67        pwstr, size );
    7468
    75     std::wstring wstr( pwstr, str.size() );
     69    std::wstring wstr( pwstr, size );
    7670
    7771    free( pwstr );
Note: See TracChangeset for help on using the changeset viewer.