Changeset 378 for trunk/src


Ignore:
Timestamp:
05/29/15 12:12:47 (10 years ago)
Author:
epyon
Message:
  • important fix in reverse_iterator operators
  • std::string functions removed or converted to string_ref in string.hh
  • capi.hh - more function forwards and usage of them instead of libc
  • more std removal
  • assert fix
Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/gui_gfx_renderer.cc

    r376 r378  
    190190{
    191191        std::string id_name( filename );
    192         id_name.append( to_string( size ) );
     192        id_name.append( std::to_string( size ) );
    193193        auto i = m_font_names.find( id_name );
    194194        if ( i != m_font_names.end() )
  • trunk/src/lua/lua_area.cc

    r374 r378  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/stl/string.hh"
    1110#include "nv/core/random.hh"
    1211
     
    325324{
    326325        nv::rectangle a = to_area( L, 1 );
    327         std::string s = "(";
    328         s += nv::to_string(a.ul.x);
    329         s += ",";
    330         s += nv::to_string(a.ul.y);
    331         s += "x";
    332         s += nv::to_string(a.lr.x);
    333         s += ",";
    334         s += nv::to_string(a.lr.y);
    335         s += ")";
    336         lua_pushstring( L, s.c_str() );
     326        lua_pushfstring( L, "(%d,%dx%d,%d)", a.ul.x, a.ul.y, a.lr.x, a.lr.y );
    337327        return 1;
    338328}
  • trunk/src/lua/lua_glm.cc

    r369 r378  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/stl/string.hh"
    1110#include "nv/core/random.hh"
     11#include "nv/stl/traits/common.hh"
    1212
    1313static size_t nlua_swizzel_lookup[256];
     
    292292{
    293293        T v = to_vec<T>( L, 1 );
    294         std::string s = "(";
    295         for ( size_t i = 0; i < v.length(); ++i )
    296         {
    297                 if (i > 0) s += ",";
    298                 s += nv::to_string(v[i]);
    299         }
    300         s+=")";
    301         lua_pushstring( L, s.c_str() );
     294        bool fl = nv::is_floating_point<typename T::value_type>::value;
     295        switch ( v.length() )
     296        {
     297        case 1: lua_pushfstring( L, ( fl ? "(%f)"          : "(%d)" ),          v[0] );
     298        case 2: lua_pushfstring( L, ( fl ? "(%f,%f)"       : "(%d,%d)" ),       v[0], v[1] );
     299        case 3: lua_pushfstring( L, ( fl ? "(%f,%f,%f)"    : "(%d,%d,%d)" ),    v[0], v[1], v[2] );
     300        case 4: lua_pushfstring( L, ( fl ? "(%f,%f,%f,%f)" : "(%d,%d,%d,%d)" ), v[0], v[1], v[2], v[3] );
     301        default:
     302                lua_pushliteral( L, "(vector?)" ); break;
     303        }
    302304        return 1;
    303305}
  • trunk/src/lua/lua_map_tile.cc

    r374 r378  
    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 ) );
    58         nv::remove_chars( code, " \r\t" );
     57        std::string code = nv::trimmed( lua_tostring( L, 1 ) ).to_string();
     58        std::string chars( " \r\t" );
     59        code.erase( nv::remove_if( code.begin(), code.end(),
     60                [&chars] ( const char& c )
     61        {
     62                return chars.find( c ) != std::string::npos;
     63        } ), code.end() );
    5964
    6065        map_tile tile;
  • trunk/src/stl/assert.cc

    r376 r378  
    3434}
    3535#       else
    36 #include <assert.h>
     36extern "C" {
     37        extern void __assert_fail(const char *, const char *, unsigned int, const char *)
     38                throw() __attribute__ ((__noreturn__));
     39}
    3740#       endif
    3841void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )
  • trunk/src/stl/string.cc

    r374 r378  
    1111#include <cstdio>
    1212#include <cstdlib>
     13#include <fstream> // for slurp only
    1314
    1415using namespace nv;
     
    1617static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000,
    171810000000, 100000000, 1000000000 };
     19
     20std::string nv::slurp( const std::string& filename )
     21{
     22        std::ifstream input( filename );
     23        //              if ( !input.is_open() ) NV_THROW( std::runtime_error, "File "+filename+" not found!");
     24        std::stringstream sstr;
     25        while ( input >> sstr.rdbuf() );
     26        return sstr.str();
     27}
    1828
    1929static inline void string_reverse( char* begin, char* end )
Note: See TracChangeset for help on using the changeset viewer.