void ConsoleApplicationImpl::BuildArguments( Int argc, Char* argv[] ) { CARAMEL_ASSERT( 1 <= argc ); // The first argument is program path, we don't need it for ( Int i = 1; i < argc; ++ i ) { m_arguments.push_back( std::string( argv[i] )); } }
std::string WideString::ToNarrow( TextEncoding encoding ) const { CARAMEL_ASSERT( TEXT_ENCODING_UTF16_LE != encoding ); if ( m_s.empty() ) { return std::string(); } if ( TEXT_ENCODING_WINDOWS_ACP == encoding ) { encoding = static_cast< TextEncoding >( ::GetACP() ); } // // 1. Computer the required buffer size. // 2. Try to encode the string. // 3. If the buffer is insufficient, double the buffer and try again. // const Int requiredSize = ::WideCharToMultiByte( encoding, // code page 0, m_s.c_str(), m_s.length() + 1, // including the terminating '\0' NULL, 0, NULL, NULL ); if ( 0 == requiredSize ) { CARAMEL_THROW( "Compute required size failed" ); } std::string result; DWORD errorCode = WideString_Encode( result, m_s, encoding, requiredSize ); if ( ERROR_INSUFFICIENT_BUFFER == errorCode ) { // Double the buffer and try again. errorCode = WideString_Encode( result, m_s, encoding, requiredSize * 2 ); } if ( S_OK != errorCode ) { // TODO: Trace some error CARAMEL_THROW( "Encode string failed" ); } return result; }
void SimpleApp::InitPlatform() { /// Redirect Caramel Trace to Win32 Debugger /// auto debugger = new Windows::DebuggerTraceAdapter; debugger->BindBuiltinChannels( Trace::LEVEL_DEBUG ); Trace::Listeners::AddManaged( debugger ); /// Create GLView with Size and Title /// const DesktopSettings& ds = m_settings.desktop; auto glview = GLViewImpl::createWithRect( ds.frameTitle, Rect( 0, 0, ds.frameWidth, ds.frameHeight )); auto director = Director::getInstance(); CARAMEL_ASSERT( nullptr == director->getOpenGLView() ); director->setOpenGLView( glview ); // // Specify Assets path in Win32 // - 1. Relateive path from working directory to assets. // 2. Add an additional assets.win32 . // if ( ds.assetsPath.empty() ) { CARAMEL_THROW( "Assets path not set" ); } auto fileUtils = FileUtils::getInstance(); fileUtils->addSearchPath( ds.assetsPath ); fileUtils->addSearchPath( ds.assetsPath + ".win32" ); }
AnyString::AnyString( const Char* sz ) { CARAMEL_ASSERT( sz ); m_value = sz; }