- Timestamp:
- 06/13/15 21:51:27 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/library.cc
r399 r402 11 11 # include <windows.h> 12 12 # define NV_LIB_EXT ".dll" 13 # define NV_LIB_HANDLE HMODULE 14 # define NV_LIB_OPEN( name ) LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) 15 # define NV_LIB_GET( handle, name ) GetProcAddress( handle, name ) 16 # define NV_LIB_CLOSE( name ) !FreeLibrary( name ) 13 # define NV_LIB_OPEN( name ) static_cast<void*>( LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) ) 14 # define NV_LIB_GET( handle, name ) reinterpret_cast<void*>( GetProcAddress( static_cast<HMODULE>( handle ), name ) ) 15 # define NV_LIB_CLOSE( handle ) ( FreeLibrary( static_cast<HMODULE>( handle ) ) != 0 ) 17 16 #elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE 18 17 # include <dlfcn.h> 19 18 # define NV_LIB_EXT ".so" 20 # define NV_LIB_HANDLE void*21 19 # define NV_LIB_OPEN( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL) 22 # define NV_LIB_GET( handle, name ) dlsym( handle, name )23 # define NV_LIB_CLOSE( name ) dlclose( name)20 # define NV_LIB_GET( handle, name ) dlsym( static_cast<void*>( handle ), name ) 21 # define NV_LIB_CLOSE( handle ) ( dlclose( static_cast<void*>( handle ) ) == 0 ) 24 22 #elif NV_PLATFORM == NV_APPLE 25 23 # include "macUtils.h" 26 24 # include <dlfcn.h> 27 25 # define NV_LIB_EXT ".dylib" 28 # define NV_LIB_HANDLE CFBundleRef29 26 # define NV_LIB_OPEN( name ) mac_loadExeBundle( name ) 30 27 # define NV_LIB_GET( handle, name ) mac_getBundleSym( handle, name ) 31 # define NV_LIB_CLOSE( name ) mac_unloadExeBundle( name)28 # define NV_LIB_CLOSE( handle ) ( mac_unloadExeBundle( handle ) == 0 ) 32 29 #endif 33 30 … … 83 80 } 84 81 85 m_handle = (void*)NV_LIB_OPEN( name.c_str() );82 m_handle = NV_LIB_OPEN( name.c_str() ); 86 83 87 84 if ( m_handle == NULL ) … … 96 93 void* library::get( string_view symbol ) 97 94 { 98 void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE)m_handle, symbol.data() );95 void* result = NV_LIB_GET( m_handle, symbol.data() ); 99 96 if ( !result ) 100 97 { … … 106 103 void* nv::library::try_get( string_view symbol ) 107 104 { 108 return (void*) NV_LIB_GET( (NV_LIB_HANDLE)m_handle, symbol.data() );105 return NV_LIB_GET( m_handle, symbol.data() ); 109 106 } 110 107 … … 116 113 void library::close() 117 114 { 118 if ( NV_LIB_CLOSE( (NV_LIB_HANDLE)m_handle ) )115 if ( ! NV_LIB_CLOSE( m_handle ) ) 119 116 { 120 117 NV_LOG_ERROR( "library : can't close library '", m_name, "'!" ); 121 118 } 122 m_handle = NULL;119 m_handle = nullptr; 123 120 } 124 121 125 122 library::~library() 126 123 { 127 if ( m_handle != NULL)124 if ( m_handle != nullptr ) 128 125 { 129 126 close(); … … 135 132 #if NV_PLATFORM == NV_WINDOWS 136 133 // We do hate WinAPI for code like this, don't we? 137 LPTSTR buffer = NULL;134 LPTSTR buffer = nullptr; 138 135 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 139 NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL );140 std::string msg( (char*)buffer);136 NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 0, NULL ); 137 std::string msg( reinterpret_cast<char*>( buffer ) ); 141 138 LocalFree( buffer ); 142 139 return msg; 143 140 #elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE 144 return st ring(dlerror());141 return std::string( dlerror() ); 145 142 #else 146 return st ring("");143 return std::string(""); 147 144 #endif 148 145 } -
trunk/src/core/logger.cc
r399 r402 89 89 for ( auto& sink_info : m_log_sinks ) 90 90 { 91 if ( sink_info.sink && (sink_info.level >= (uint32)level) )91 if ( sink_info.sink && (sink_info.level >= static_cast<uint32>( level ) ) ) 92 92 { 93 93 // log and iterate … … 106 106 { 107 107 sink_info.sink = sink; 108 sink_info.level = (uint32)level;108 sink_info.level = static_cast<uint32>( level ); 109 109 return; 110 110 } … … 194 194 //if ( m_flush ) FlushFileBuffers( m_handle ); 195 195 #else 196 fwrite( stamp, ssize, 1, (FILE*)m_handle ); 197 fwrite( " [", 2, 1, (FILE*)m_handle ); 198 fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, (FILE*)m_handle ); 199 fwrite( "] ", 2, 1, (FILE*)m_handle ); 200 fwrite( message.data(), message.size(), 1, (FILE*)m_handle ); 201 fwrite( "\n", 1, 1, (FILE*)m_handle ); 202 if ( m_flush ) fflush( (FILE*)m_handle ); 196 FILE* file = static_cast<FILE*>( m_handle ); 197 fwrite( stamp, ssize, 1, file ); 198 fwrite( " [", 2, 1, file ); 199 fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, file ); 200 fwrite( "] ", 2, 1, file ); 201 fwrite( message.data(), message.size(), 1, file ); 202 fwrite( "\n", 1, 1, file ); 203 if ( m_flush ) fflush( file ); 203 204 #endif 204 205 } … … 226 227 CloseHandle( m_handle ); 227 228 #else 228 fclose( (FILE*) m_handle);229 fclose( static_cast<FILE*>( m_handle ) ); 229 230 #endif 230 231 } … … 244 245 { 245 246 uint32 ms = get_system_ms(); 246 unsigned int secs = (unsigned int)(ms / 1000);247 unsigned int mm = (unsigned int)( ms * 100 / 1000 ) % 100;248 unsigned int h = (unsigned int)(secs / (60*60));249 unsigned int m = (unsigned int)(secs / 60) % 60;247 unsigned int secs = static_cast<unsigned int>( ms / 1000 ); 248 unsigned int mm = static_cast<unsigned int>( ms * 100 / 1000 ) % 100; 249 unsigned int h = static_cast<unsigned int>( secs / (60*60) ); 250 unsigned int m = static_cast<unsigned int>( secs / 60 ) % 60; 250 251 unsigned int s = secs % 60; 251 252 #if NV_COMPILER == NV_MSVC -
trunk/src/core/profiler.cc
r399 r402 124 124 if ( c->m_calls > 0 ) 125 125 { 126 f64 pparent = ( (f64)c->m_total_time_us / (f64)c->m_parent->m_total_time_us ) * 100.f; 126 f64 ftotal_time_us = static_cast<f64>( c->m_total_time_us ); 127 f64 pparent = ( ftotal_time_us / static_cast<f64>( c->m_parent->m_total_time_us ) ) * 100.f; 127 128 uint32 calls = c->m_calls; 128 f64 total_ms = c->m_total_time_us / 1000.f;129 f64 avg_ms = ( (f64)c->m_total_time_us / (f64)c->m_calls) / 1000.f;129 f64 total_ms = ftotal_time_us / 1000.f; 130 f64 avg_ms = ( ftotal_time_us / static_cast<f64>( c->m_calls ) ) / 1000.f; 130 131 if ( indent > 0 ) nvmemset( buffer, '-', indent ); 131 132 snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent, -
trunk/src/core/random.cc
r395 r402 19 19 random::seed_type random::randomize() 20 20 { 21 std::mt19937& rng = *( ( std::mt19937* )m_data);21 std::mt19937& rng = *( reinterpret_cast< std::mt19937* >( m_data ) ); 22 22 seed_type seed = randomized_seed(); 23 23 rng.seed( seed ); … … 27 27 void random::set_seed( random::seed_type seed /*= 0 */ ) 28 28 { 29 std::mt19937& rng = *( ( std::mt19937* )m_data);29 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 30 30 rng.seed( seed == 0 ? randomized_seed() : seed ); 31 31 } … … 39 39 random::result_type random::rand() 40 40 { 41 std::mt19937& rng = *( ( std::mt19937* )m_data);41 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 42 42 return rng(); 43 43 } … … 45 45 sint32 random::srand( sint32 val ) 46 46 { 47 std::mt19937& rng = *( ( std::mt19937* )m_data);47 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 48 48 std::uniform_int_distribution<sint32> dist( 0, val - 1 ); 49 49 return dist( rng ); … … 52 52 uint32 random::urand( uint32 val ) 53 53 { 54 std::mt19937& rng = *( ( std::mt19937* )m_data);54 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 55 55 std::uniform_int_distribution<uint32> dist( 0, val - 1 ); 56 56 return dist( rng ); … … 59 59 f32 random::frand( f32 val ) 60 60 { 61 std::mt19937& rng = *( ( std::mt19937* )m_data);61 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 62 62 std::uniform_real_distribution<f32> dist( 0, val ); 63 63 return dist( rng ); … … 66 66 sint32 random::srange( sint32 min, sint32 max ) 67 67 { 68 std::mt19937& rng = *( ( std::mt19937* )m_data);68 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 69 69 std::uniform_int_distribution<sint32> dist( min, max ); 70 70 return dist( rng ); … … 73 73 uint32 random::urange( uint32 min, uint32 max ) 74 74 { 75 std::mt19937& rng = *( ( std::mt19937* )m_data);75 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 76 76 std::uniform_int_distribution<uint32> dist( min, max ); 77 77 return dist( rng ); … … 80 80 f32 random::frange( f32 min, f32 max ) 81 81 { 82 std::mt19937& rng = *( ( std::mt19937* )m_data);82 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 83 83 std::uniform_real_distribution<f32> dist( min, max ); 84 84 return dist( rng ); … … 87 87 uint32 random::dice( uint32 count, uint32 sides ) 88 88 { 89 std::mt19937& rng = *( ( std::mt19937* )m_data);89 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 90 90 std::uniform_int_distribution<uint32> dist( 1, sides ); 91 91 uint32 result = 0; … … 106 106 nv::vec2 nv::random::precise_unit_vec2() 107 107 { 108 std::mt19937& rng = *( ( std::mt19937* )m_data);108 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 109 109 std::uniform_real_distribution<f32> dist( 0, glm::pi<float>() * 2.f ); 110 110 float angle = dist( rng ); … … 114 114 nv::vec3 nv::random::precise_unit_vec3() 115 115 { 116 std::mt19937& rng = *( ( std::mt19937* )m_data);116 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 117 117 std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f ); 118 118 std::uniform_real_distribution<f32> dist02pi( 0.0f, 2*glm::pi<float>() ); … … 129 129 nv::vec2 nv::random::fast_disk_point() 130 130 { 131 std::mt19937& rng = *( ( std::mt19937* )m_data);131 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 132 132 std::uniform_real_distribution<f32> dist( 0.0f, 1.0f ); 133 133 float r1 = dist( rng ); … … 140 140 nv::vec2 nv::random::precise_disk_point() 141 141 { 142 std::mt19937& rng = *( ( std::mt19937* )m_data);142 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 143 143 std::uniform_real_distribution<f32> unit( 0.0f, 1.0f ); 144 144 std::uniform_real_distribution<f32> angle( 0.0f, glm::pi<float>() ); … … 150 150 nv::vec3 nv::random::fast_sphere_point() 151 151 { 152 std::mt19937& rng = *( ( std::mt19937* )m_data);152 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 153 153 std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f ); 154 154 std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f ); … … 168 168 nv::vec3 nv::random::precise_sphere_point() 169 169 { 170 std::mt19937& rng = *( ( std::mt19937* )m_data);170 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 171 171 std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f ); 172 172 std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f ); … … 185 185 nv::vec2 nv::random::precise_ellipse_point( const vec2& radii ) 186 186 { 187 std::mt19937& rng = *( ( std::mt19937* )m_data);187 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 188 188 std::uniform_real_distribution<f32> distx( -radii.x, radii.x ); 189 189 std::uniform_real_distribution<f32> disty( -radii.y, radii.y ); … … 204 204 nv::vec3 nv::random::precise_ellipsoid_point( const vec3& radii ) 205 205 { 206 std::mt19937& rng = *( ( std::mt19937* )m_data);206 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 207 207 std::uniform_real_distribution<f32> distx( -radii.x, radii.x ); 208 208 std::uniform_real_distribution<f32> disty( -radii.y, radii.y ); … … 225 225 nv::vec2 nv::random::fast_hollow_disk_point( float iradius, float oradius ) 226 226 { 227 std::mt19937& rng = *( ( std::mt19937* )m_data);227 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 228 228 float idist2 = iradius * iradius; 229 229 float odist2 = oradius * oradius; … … 239 239 nv::vec3 nv::random::fast_hollow_sphere_point( float iradius, float oradius ) 240 240 { 241 std::mt19937& rng = *( ( std::mt19937* )m_data);241 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 242 242 float idist3 = iradius * iradius * iradius; 243 243 float odist3 = oradius * oradius * oradius; … … 254 254 nv::vec2 nv::random::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii ) 255 255 { 256 std::mt19937& rng = *( ( std::mt19937* )m_data);256 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 257 257 vec2 iradii2 = iradii * iradii; 258 258 vec2 opoint = ellipse_edge( oradii ); … … 275 275 nv::vec3 nv::random::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii ) 276 276 { 277 std::mt19937& rng = *( ( std::mt19937* )m_data);277 std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) ); 278 278 vec3 iradii2 = iradii * iradii; 279 279 vec3 opoint = ellipsoid_edge( oradii ); -
trunk/src/core/time.cc
r401 r402 85 85 nv::uint32 nv::get_cpu_ms() 86 86 { 87 return (uint32)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000.0) ) ;87 return static_cast<uint32>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000.0f ) ) ; 88 88 } 89 89 90 90 nv::uint64 nv::get_cpu_us() 91 91 { 92 return (uint64)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000000.0) ) ;92 return static_cast<uint64>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000000.0f ) ) ; 93 93 } 94 94 … … 99 99 QueryPerformanceCounter(&now); 100 100 LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart; 101 return (uint32) (1000.0 * result / (double) zero_timer.frequency.QuadPart);101 return static_cast<uint32>(1000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) ); 102 102 #else 103 103 struct timeval now; 104 104 gettimeofday(&now, NULL); 105 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );105 return static_cast<uint32>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 ); 106 106 #endif 107 107 } … … 113 113 QueryPerformanceCounter(&now); 114 114 LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart; 115 return (uint64) (1000000.0 * result / (double) zero_timer.frequency.QuadPart);115 return static_cast<uint64>(1000000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) ); 116 116 #else 117 117 struct timeval now; 118 118 gettimeofday(&now, NULL); 119 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );119 return static_cast<uint64>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) ); 120 120 #endif 121 121 } -
trunk/src/stl/assert.cc
r396 r402 31 31 extern "C" { 32 32 extern void __assert(const char *, const char *, unsigned int, const char *) 33 throw()__attribute__ ((__noreturn__));33 __attribute__ ((__noreturn__)); 34 34 } 35 35 # else 36 36 extern "C" { 37 37 extern void __assert_fail(const char *, const char *, unsigned int, const char *) 38 throw()__attribute__ ((__noreturn__));38 __attribute__ ((__noreturn__)); 39 39 } 40 40 # endif 41 void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )41 __attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function ) 42 42 { 43 43 # if NV_COMPILER == NV_CLANG -
trunk/src/stl/hash_table.cc
r395 r402 47 47 }; 48 48 49 static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );49 //static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) ); 50 50 51 51 namespace nv 52 52 { 53 void* g_hash_table_empty[2] = { nullptr, (void*)uintptr_t( ~0) };53 void* g_hash_table_empty[2] = { nullptr, reinterpret_cast<void*>( uintptr_t( ~0 ) ) }; 54 54 } 55 55 -
trunk/src/stl/string.cc
r395 r402 15 15 using namespace nv; 16 16 17 static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 18 10000000, 100000000, 1000000000 }; 17 //static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; 19 18 20 19 std::string nv::slurp( const std::string& filename ) … … 41 40 { 42 41 char* s = str; 43 uint32 abs = ( n < 0 ) ? (uint32)( -n ) : (uint32)(n );42 uint32 abs = static_cast< uint32 >( n < 0 ? -n : n ); 44 43 do 45 44 { 46 *s++ = (char)( '0' + ( abs % 10 ) );45 *s++ = static_cast<char>( '0' + ( abs % 10 ) ); 47 46 abs /= 10; 48 47 } while ( abs > 0 ); … … 50 49 *s = '\0'; 51 50 string_reverse( str, s - 1 ); 52 return (nv::size_t)( s - str );51 return static_cast<nv::size_t>( s - str ); 53 52 } 54 53 … … 56 55 { 57 56 char* s = str; 58 uint64 abs = ( n < 0 ) ? (uint64)( -n ) : (uint64)(n );57 uint64 abs = static_cast< uint64 >( n < 0 ? -n : n ); 59 58 do 60 59 { 61 *s++ = (char)( '0' + ( abs % 10 ) );60 *s++ = static_cast<char>( '0' + ( abs % 10 ) ); 62 61 abs /= 10; 63 62 } while ( abs > 0 ); … … 65 64 *s = '\0'; 66 65 string_reverse( str, s - 1 ); 67 return (nv::size_t)( s - str );66 return static_cast<nv::size_t>( s - str ); 68 67 } 69 68 … … 73 72 do 74 73 { 75 *s++ = (char)( '0' + ( n % 10 ) );74 *s++ = static_cast<char>( '0' + ( n % 10 ) ); 76 75 n /= 10; 77 76 } while ( n > 0 ); 78 77 *s = '\0'; 79 78 string_reverse( str, s - 1 ); 80 return (nv::size_t)( s - str );79 return static_cast<nv::size_t>( s - str ); 81 80 } 82 81 … … 86 85 do 87 86 { 88 *s++ = (char)( '0' + ( n % 10 ) );87 *s++ = static_cast<char>( '0' + ( n % 10 ) ); 89 88 n /= 10; 90 89 } while ( n > 0 ); 91 90 *s = '\0'; 92 91 string_reverse( str, s - 1 ); 93 return (size_t)( s - str );92 return static_cast<nv::size_t>( s - str ); 94 93 } 95 94 … … 101 100 int result = snprintf( str, 64, "%.*g", 6, n ); 102 101 #endif 103 return result > 0 ? ( nv::size_t )result : 0;102 return static_cast<nv::size_t>( result > 0 ? result : 0 ); 104 103 } 105 104 … … 111 110 int result = snprintf( str, 64, "%.*g", 6, n ); 112 111 #endif 113 return result > 0 ? ( nv::size_t )result : 0;112 return static_cast<nv::size_t>( result > 0 ? result : 0 ); 114 113 } 115 114 116 sint32 buffer_to_sint32( const char* str, char** end )115 sint32 nv::buffer_to_sint32( const char* str, char** end ) 117 116 { 118 117 const char* s = str; … … 131 130 ++s; 132 131 } 133 if ( end != nullptr ) *end = (char*)s;132 if ( end != nullptr ) *end = const_cast<char*>( s ); 134 133 return positive ? result : -result; 135 134 } 136 135 137 sint64 buffer_to_sint64( const char* s, char** end )136 sint64 nv::buffer_to_sint64( const char* s, char** end ) 138 137 { 139 138 while ( *s == ' ' ) ++s; … … 151 150 ++s; 152 151 } 153 if ( end != nullptr ) *end = (char*)s;152 if ( end != nullptr ) *end = const_cast<char*>( s ); 154 153 return positive ? result : -result; 155 154 } 156 155 157 uint32 buffer_to_uint32( const char* s, char** end )156 uint32 nv::buffer_to_uint32( const char* s, char** end ) 158 157 { 159 158 while ( *s == ' ' ) ++s; … … 161 160 while ( *s >= '0' && *s <= '9' ) 162 161 { 163 result = ( result * 10 ) + (uint32)( *s - '0' );162 result = ( result * 10 ) + static_cast<uint32>( *s - '0' ); 164 163 ++s; 165 164 } 166 if ( end != nullptr ) *end = (char*)s;165 if ( end != nullptr ) *end = const_cast<char*>( s ); 167 166 return result; 168 167 } 169 168 170 uint64 buffer_to_uint64( const char* s, char** end )169 uint64 nv::buffer_to_uint64( const char* s, char** end ) 171 170 { 172 171 while ( *s == ' ' ) ++s; … … 174 173 while ( *s >= '0' && *s <= '9' ) 175 174 { 176 result = ( result * 10 ) + (uint32)( *s - '0' );175 result = ( result * 10 ) + static_cast<uint32>( *s - '0' ); 177 176 ++s; 178 177 } 179 if ( end != nullptr ) *end = (char*)s;178 if ( end != nullptr ) *end = const_cast<char*>( s ); 180 179 return result; 181 180 } 182 181 183 float buffer_to_f32( const char* s, char** end )182 float nv::buffer_to_f32( const char* s, char** end ) 184 183 { 185 184 return strtof( s, end ); 186 185 } 187 186 188 double buffer_to_f64( const char* s, char** end )187 double nv::buffer_to_f64( const char* s, char** end ) 189 188 { 190 189 return strtod( s, end );
Note: See TracChangeset
for help on using the changeset viewer.