Changeset 437 for trunk/src/core


Ignore:
Timestamp:
07/23/15 08:30:41 (10 years ago)
Author:
epyon
Message:
  • local updates (string removal)
File:
1 edited

Legend:

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

    r433 r437  
    66
    77#include "nv/core/library.hh"
     8#include <string>
    89
    910#if NV_PLATFORM == NV_WINDOWS
     
    4041void library::open( string_view name )
    4142{
    42         m_name.assign( name.data(), name.size() );
     43        m_name = name;
    4344        if ( !open() )
    4445        {
     
    5152bool nv::library::try_open( string_view name )
    5253{
    53         m_name.assign( name.data(), name.size() );
     54        m_name = name;
    5455        if ( !open() )
    5556        {
     
    6263string_view library::get_name() const
    6364{
    64     return string_view( m_name.c_str(), m_name.size() );
     65    return m_name;
    6566}
    6667
     
    7172        return true;
    7273    }
    73     NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loading..." );
     74    NV_LOG_NOTICE( "library \"", m_name, "\" : loading..." );
    7475
    75         std::string name = m_name;
     76        std::string name( m_name.data(), m_name.length() );
    7677        std::string ext( NV_LIB_EXT );
    7778
     
    8586    if ( m_handle == NULL )
    8687    {
    87                 NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : failed to open!" );
     88                NV_LOG_NOTICE( "library \"", m_name, "\" : failed to open!" );
    8889                return false;
    8990    }
    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.c_str(), m_name.size() ), "\" : can't find symbol \"", symbol, "\"" );
     99                NV_LOG_CRITICAL( "library \"", m_name, "\" : 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.c_str(), m_name.size() ), "\" : can't close library!" );
     119        NV_LOG_ERROR( "library \"", m_name, "\" : can't close library!" );
    120120    }
    121121    m_handle = nullptr;
     
    130130}
    131131
    132 std::string library::get_error()
     132nv::string_view library::get_error()
    133133{
    134134#if NV_PLATFORM == NV_WINDOWS
    135135    // We do hate WinAPI for code like this, don't we?
    136     LPTSTR buffer = nullptr;
    137     FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
    138         NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 0, NULL );
    139     std::string msg( reinterpret_cast<char*>( buffer ) );
    140     LocalFree( buffer );
    141     return msg;
     136        static TCHAR buffer[256];
     137    FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
     138        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 256, NULL );
     139    return string_view( reinterpret_cast<char*>( buffer ) );
    142140#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    143     return std::string( dlerror() );
     141    return nv::string_view( dlerror() );
    144142#else
    145     return std::string("");
     143    return nv::string_view();
    146144#endif
    147145}
Note: See TracChangeset for help on using the changeset viewer.