Changeset 433 for trunk/src


Ignore:
Timestamp:
07/21/15 19:40:00 (10 years ago)
Author:
epyon
Message:
  • string.hh split into separate files
  • string.hh - removed std::string conversions (header still stays though)
Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/library.cc

    r403 r433  
    6262string_view library::get_name() const
    6363{
    64     return string_view( m_name );
     64    return string_view( m_name.c_str(), m_name.size() );
    6565}
    6666
     
    7171        return true;
    7272    }
    73     NV_LOG_NOTICE( "library \"", string_view( m_name ), "\" : loading..." );
     73    NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loading..." );
    7474
    7575        std::string name = m_name;
    76         string_view ext( NV_LIB_EXT );
     76        std::string ext( NV_LIB_EXT );
    7777
    7878        if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext )
     
    8585    if ( m_handle == NULL )
    8686    {
    87                 NV_LOG_NOTICE( "library \"", string_view( name ), "\" : failed to open!" );
     87                NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : failed to open!" );
    8888                return false;
    8989    }
    90     NV_LOG_NOTICE( "library \"", string_view( name ), "\" : loaded." );
     90    NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loaded." );
    9191        return true;
    9292}
     
    9797    if ( !result )
    9898    {
    99                 NV_LOG_CRITICAL( "library \"", string_view( m_name ), "\" : can't find symbol \"", symbol, "\"" );
     99                NV_LOG_CRITICAL( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : can't find symbol \"", symbol, "\"" );
    100100                NV_ABORT( "Library symbol load failed!" );
    101101    }
     
    117117    if ( ! NV_LIB_CLOSE( m_handle ) )
    118118    {
    119         NV_LOG_ERROR( "library \"", string_view( m_name ), "\" : can't close library!" );
     119        NV_LOG_ERROR( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : can't close library!" );
    120120    }
    121121    m_handle = nullptr;
  • trunk/src/engine/particle_engine.cc

    r406 r433  
    435435                                        {
    436436                                                data.affector_count--;
    437                                                 NV_LOG_WARNING( "Bad data passed to ", sub_type, " affector in particle system!" );
     437                                                NV_LOG_WARNING( "Bad data passed to ", string_view( sub_type.c_str(), sub_type.size() ), " affector in particle system!" );
    438438                                        }
    439439                                }
     
    441441                                {
    442442                                        data.affector_count--;
    443                                         NV_LOG_WARNING( "Unknown affector type in particle system! (", sub_type, ")" );
     443                                        NV_LOG_WARNING( "Unknown affector type in particle system! (", string_view( sub_type.c_str(), sub_type.size() ), ")" );
    444444                                }
    445445                        }
  • trunk/src/engine/program_manager.cc

    r399 r433  
    3737        }
    3838
    39         nv::program program = m_context->get_device()->create_program( string_view( vsource ), string_view( fsource ) );
     39        nv::program program = m_context->get_device()->create_program( string_view( vsource.c_str(), vsource.size() ), string_view( fsource.c_str(), fsource.size() ) );
    4040        return add( program );
    4141}
  • trunk/src/engine/resource_system.cc

    r431 r433  
    1212{
    1313        m_lua = a_lua_state;
    14         lua::register_storage( m_lua, get_storage_name(), string_view( "register_" + get_resource_name().to_string() ) );
     14        std::string delete_me = "register_" + std::string( get_resource_name().data(), get_resource_name().size() );
     15        lua::register_storage( m_lua, get_storage_name(), string_view( delete_me.c_str(), delete_me.size() ) );
    1516}
    1617
  • trunk/src/formats/md5_loader.cc

    r428 r433  
    155155                                        sstream >> shader;
    156156                                        remove_quotes( shader );
    157                                         maccess.set_name( make_name( shader ) );
     157                                        maccess.set_name( make_name( shader.c_str() ) );
    158158                                        next_line( sstream );
    159159                                }
  • trunk/src/formats/obj_loader.cc

    r427 r433  
    328328                data_channel_set* result = data_channel_set_creator::create_set( 1 );
    329329                data_channel_set_creator raccess( result );
    330                 raccess.set_name( make_name( reader->name ) );
     330                raccess.set_name( make_name( reader->name.c_str() ) );
    331331                uint8* rdata = raccess.add_channel( m_descriptor, reader->size * 3 ).raw_data();
    332332
  • trunk/src/gl/gl_device.cc

    r406 r433  
    1919        m_shader_header  = "#version 120\n";
    2020        for ( auto& i : get_uniform_factory() )
    21                 m_shader_header += "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ i.first.to_string() +";\n";
     21                m_shader_header += "uniform "+datatype_to_glsl_type( i.second->get_datatype() )+" "+ std::string( i.first.data(), i.first.size() ) +";\n";
    2222        for ( auto& i : get_link_uniform_factory() )
    23                 m_shader_header += "uniform sampler2D "+i.first.to_string() +";\n";
     23                m_shader_header += "uniform sampler2D "+std::string( i.first.data(), i.first.size() ) +";\n";
    2424}
    2525
     
    212212                for ( auto& i : *info->m_uniform_map )
    213213                {
    214                         auto j = lmap.find( i.first );
     214                        auto j = lmap.find( i.first.c_str() );
    215215                        if ( j != lmap.end() )
    216216                        {
     
    218218                        }                       
    219219
    220                         auto k = map.find( i.first );
     220                        auto k = map.find( i.first.c_str() );
    221221                        if ( k != map.end() )
    222222                        {
     
    238238                if ( fatal )
    239239                {
    240                         NV_LOG_CRITICAL( "gl_device : uniform '", string_view( name ), "' not found in program!" );
     240                        NV_LOG_CRITICAL( "gl_device : uniform '", string_view( name.c_str(), name.size() ), "' not found in program!" );
    241241                        NV_ABORT( "gl_device : uniform not found!" );
    242242                }
     
    257257                if ( fatal )
    258258                {
    259                         NV_LOG_CRITICAL( "gl_device : attribute '", string_view( name ), "' not found in program!" );
     259                        NV_LOG_CRITICAL( "gl_device : attribute '", string_view( name.c_str(), name.size() ), "' not found in program!" );
    260260                        NV_ABORT( "gl_device : attribute not found!" );
    261261                }
  • trunk/src/gui/gui_environment.cc

    r401 r433  
    3030}
    3131
    32 void nv::gui::environment::load_style( const std::string& filename )
     32void nv::gui::environment::load_style( const string_view& filename )
    3333{
    3434        m_renderer->load_style( filename );
  • trunk/src/gui/gui_gfx_renderer.cc

    r406 r433  
    187187}
    188188
    189 nv::size_t gfx_renderer::load_font( const std::string& filename, nv::size_t size )
    190 {
    191         std::string id_name( filename );
     189nv::size_t gfx_renderer::load_font( const string_view& filename, nv::size_t size )
     190{
     191        std::string id_name( filename.data(), filename.size() );
    192192        char buffer[8]; size_t len = nv::sint32_to_buffer( sint32( size ), buffer );
    193193        id_name.append( std::string( buffer, len ) );
    194         auto i = m_font_names.find( id_name );
     194        string_view id( id_name.c_str(), id_name.size() );
     195        auto i = m_font_names.find( id );
    195196        if ( i != m_font_names.end() )
    196197        {
     
    198199        }
    199200        size_t result = m_fonts.size();
    200         texture_font* f = new texture_font( &m_atlas, filename.c_str(), static_cast<float>( size ) );
     201        texture_font* f = new texture_font( &m_atlas, filename.data(), static_cast<float>( size ) );
    201202        f->load_glyphs( "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " );
    202203        m_fonts.push_back( f );
    203204        m_reupload = true;
    204         m_font_names[id_name] = result;
     205        m_font_names[ id ] = result;
    205206        return result;
    206207}
    207208
    208 nv::size_t gfx_renderer::load_image( const std::string& filename )
     209nv::size_t gfx_renderer::load_image( const string_view& filename )
    209210{
    210211        auto i = m_image_names.find( filename );
     
    253254                if ( m_style.get( e, "skin", selector, path ) )
    254255                {
    255                         size_t image_id = load_image( path );
     256                        size_t image_id = load_image( string_view( path.c_str(), path.size() ) );
    256257                        const image_info* image = get_image( image_id );
    257258                        if ( image )
     
    318319                        if ( m_style.get( e, "text_color", selector, color ) && m_style.get( e, "text_font", selector, path ) && m_style.get( e, "text_size", selector, border ) )
    319320                        {
    320                                 size_t font_id = load_font( path, size_t( border ) );
     321                                size_t font_id = load_font( string_view( path.c_str(), path.size() ), size_t( border ) );
    321322                                texture_font* font = get_font( font_id );
    322323                                position p = abs.ul + position( 0, border );
  • trunk/src/gui/gui_renderer.cc

    r395 r433  
    77#include "nv/gui/gui_renderer.hh"
    88
    9 void nv::gui::renderer::load_style( const std::string& filename )
     9void nv::gui::renderer::load_style( const string_view& filename )
    1010{
    1111        m_style.load_style( filename );
  • trunk/src/gui/gui_style.cc

    r406 r433  
    1616}
    1717
    18 void style::load_style( const std::string& filename )
     18void style::load_style( const string_view& filename )
    1919{
    2020        m_lua.do_file( filename );
  • trunk/src/lua/lua_function.cc

    r406 r433  
    2121        {
    2222                lua_pop( L, 1 );
    23                 NV_LUA_ABORT( "function_base::function_base", "not a valid path - ", a_path.to_string() );
     23                NV_LUA_ABORT( "function_base::function_base", "not a valid path - ", a_path.to_string().c_str() );
    2424        }
    2525
     
    2727        {
    2828                lua_pop( L, 1 );
    29                 NV_LUA_ABORT( "function_base::function_base", "not a valid function - ", a_path.to_string() );
     29                NV_LUA_ABORT( "function_base::function_base", "not a valid function - ", a_path.to_string().c_str() );
    3030        }
    3131        m_ref = luaL_ref( L, LUA_REGISTRYINDEX );
  • trunk/src/lua/lua_map_tile.cc

    r406 r433  
    5555        nv::map_area* map_area = nv::lua::detail::to_map_area( L, 3 );
    5656        lua_settop( L, 2 );
    57         std::string code = nv::trimmed( lua_tostring( L, 1 ) ).to_string();
     57        nv::string_view lts = nv::trimmed( lua_tostring( L, 1 ) );
     58        std::string code( lts.data(), lts.size() );
    5859        std::string chars( " \r\t" );
    5960        code.erase( nv::remove_if( code.begin(), code.end(),
  • trunk/src/lua/lua_state.cc

    r431 r433  
    116116        if ( !p.resolve( m_state, global ) )
    117117        {
    118                 NV_LOG_ERROR( "Lua error : not a valid path - ", p.to_string() );
     118                NV_LOG_ERROR( "Lua error : not a valid path - ", p.to_string().c_str() );
    119119                return false;
    120120        }
     
    123123        {
    124124                lua_pop( m_state, 1 );
    125                 NV_LOG_ERROR( "Lua error : not a valid function - ", p.to_string() );
     125                NV_LOG_ERROR( "Lua error : not a valid function - ", p.to_string().c_str() );
    126126                return false;
    127127        }
     
    442442        for ( int i = 0; i < top; ++i )
    443443        {
    444                 NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1) );
     444                NV_LOG_DEBUG( "#", i+1, " - ", lua_typename(m_state, lua_type(m_state, i+1) ), " = ", nlua_typecontent(m_state, i+1).c_str() );
    445445        }
    446446}
Note: See TracChangeset for help on using the changeset viewer.