Changeset 433
- Timestamp:
- 07/21/15 19:40:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gui/gui_environment.hh
r395 r433 31 31 environment( renderer* r ); 32 32 // temporary 33 void load_style( const st d::string& filename );33 void load_style( const string_view& filename ); 34 34 handle create_element( const rectangle& r ); 35 35 handle create_element( handle parent, const rectangle& r ); -
trunk/nv/gui/gui_gfx_renderer.hh
r395 r433 56 56 const image_info* get_image( size_t name ) const; 57 57 58 size_t load_font( const st d::string& filename, size_t size );59 size_t load_image( const st d::string& filename );58 size_t load_font( const string_view& filename, size_t size ); 59 size_t load_image( const string_view& filename ); 60 60 61 typedef unordered_map< std::string, size_t > names;61 typedef hash_store< shash64, size_t > names; 62 62 typedef vector< texture_font* > font_vector; 63 63 typedef vector< image_info > image_vector; -
trunk/nv/gui/gui_renderer.hh
r406 r433 28 28 public: 29 29 renderer() {} 30 virtual void load_style( const st d::string& filename );30 virtual void load_style( const string_view& filename ); 31 31 virtual void redraw( element* e, uint32 ) = 0; 32 32 virtual void draw( element* e ) = 0; -
trunk/nv/gui/gui_style.hh
r395 r433 27 27 public: 28 28 style(); 29 void load_style( const st d::string& filename );29 void load_style( const string_view& filename ); 30 30 bool get( element* e, const char* centry, const char* cselector, std::string& s ); 31 31 bool get( element* e, const char* centry, const char* cselector, vec4& vec ); -
trunk/nv/stl/memory.hh
r427 r433 161 161 size_type m_size; 162 162 }; 163 164 163 165 164 template < typename T > -
trunk/nv/stl/string.hh
r431 r433 23 23 #define NV_STL_STRING_HH 24 24 25 #include <nv/common.hh> 25 #include <nv/stl/string/common.hh> 26 #include <nv/stl/string/string_base.hh> 27 #include <nv/stl/string/literal_string.hh> 28 #include <nv/stl/string/const_string.hh> 29 #include <nv/stl/string/short_string.hh> 26 30 #include <string> 27 31 #include <sstream> … … 33 37 namespace nv 34 38 { 35 36 template < typename Storage > class string_base; 37 class string_view; 38 39 // short_string< size_t > 40 // string32 41 // string64 42 // string 43 39 44 40 template< typename H > 45 41 struct hash< std::string, H > : detail::hash_base< std::string, H > … … 70 66 }; 71 67 72 template < typename T, typename Enable = void > 73 struct is_string_base_impl : false_type {}; 74 template < typename T > 75 struct is_string_base_impl < T, 76 typename enable_if< 77 is_base_of< string_base< typename T::storage_type >, T >::value, 78 void >::type > : true_type{}; 68 79 69 } 80 70 81 // Stronger version82 // template < typename T >83 // struct is_string_base : is_template_base_of< T, string_base > {};84 85 template < typename T >86 struct is_string_base : detail::is_string_base_impl< T > {};87 71 88 72 template < typename T > … … 91 75 92 76 }; 93 94 // string base class - will become a base for a string class later95 template < typename Storage >96 class string_base : public Storage97 {98 typedef Storage base_type;99 typedef string_base< base_type > this_type;100 public:101 typedef Storage storage_type;102 typedef typename base_type::value_type value_type;103 typedef typename base_type::pointer pointer;104 typedef typename base_type::const_pointer const_pointer;105 typedef typename base_type::reference reference;106 typedef typename base_type::const_reference const_reference;107 typedef typename base_type::iterator iterator;108 typedef typename base_type::const_iterator const_iterator;109 typedef typename base_type::reverse_iterator reverse_iterator;110 typedef typename base_type::const_reverse_iterator const_reverse_iterator;111 typedef typename base_type::size_type size_type;112 typedef typename base_type::difference_type difference_type;113 114 static constexpr size_type npos = size_type( -1 );115 116 // conversion to std::string117 inline std::string to_string() const118 {119 return std::string( this->data(), this->size() );120 }121 122 inline size_type length() const { return this->size(); }123 124 // string operations125 int compare( const string_view& rhs ) const;126 bool starts_with( value_type c ) const;127 bool starts_with( const string_view& s ) const;128 bool ends_with( value_type c ) const;129 bool ends_with( const string_view& s ) const;130 auto find( value_type c, size_type pos = 0 ) const->size_type;131 auto find( const string_view& s, size_type pos = 0 ) const->size_type;132 auto rfind( value_type c, size_type pos = 0 ) const->size_type;133 auto rfind( const string_view& s, size_type pos = 0 ) const->size_type;134 auto find_first_of( value_type c ) const->size_type;135 auto find_first_of( const string_view& s ) const->size_type;136 auto find_last_of( value_type c ) const->size_type;137 auto find_last_of( const string_view& s ) const->size_type;138 auto find_first_not_of( value_type c ) const->size_type;139 auto find_first_not_of( const string_view& s ) const->size_type;140 auto find_last_not_of( value_type c ) const->size_type;141 auto find_last_not_of( const string_view& s ) const->size_type;142 143 // string operations144 string_view substr( size_type p, size_type n = npos ) const;145 146 template < typename H = size_type >147 inline H get_hash() const148 {149 return hash_string< H >( this->data(), this->size() );150 }151 152 protected:153 using base_type::base_type;154 constexpr string_base() : base_type() {}155 constexpr string_base( pointer str, size_type len ) : base_type( str, len ) {}156 157 template < typename ReverseIterator >158 size_type reverse_distance( ReverseIterator first, ReverseIterator last ) const159 {160 return this->size() - 1 - static_cast<size_t>( nv::distance( first, last ) );161 }162 };163 164 template< typename T, typename H >165 struct hash< T, H, typename enable_if< is_string_base<T>::value, void >::type >166 : detail::hash_base< T, H >167 {168 static H get( const T& value )169 {170 return value.template get_hash< H >();171 }172 inline H operator()( const T& value ) const { return get( value ); }173 };174 175 class string_view : public string_base< array_view< char > >176 {177 public:178 typedef string_base< array_view< char > > this_type;179 180 constexpr string_view() : this_type() {}181 inline string_view( const string_view& rhs ) : this_type( rhs.data(), rhs.size() ) {}182 template < typename S >183 inline string_view( const string_base<S>& rhs ) : this_type( rhs.data(), rhs.size() ) {}184 inline string_view( const std::string& str ) : this_type( str.data(), str.size() ) {}185 constexpr string_view( const char* str, size_type len ) : this_type( str, len ) {}186 187 // Literal constructors188 template< size_t N >189 constexpr string_view( char( &s )[N] ) : this_type( s, N - 1 ) {}190 template< size_t N >191 constexpr string_view( const char( &s )[N] ) : this_type( s, N - 1 ) {}192 193 // Non-literal constructors194 template< typename U >195 inline string_view( U str, typename enable_if<is_same<U, const char*>::value>::type* = nullptr ) : this_type( str, nvstrlen( str ) ) {}196 197 // Non-literal constructors198 template< typename U >199 inline string_view( U str, typename enable_if<is_same<U, char*>::value>::type* = nullptr ) : this_type( str, nvstrlen( str ) ) {}200 201 inline string_view& operator=( const string_view &rhs )202 {203 assign( rhs.data(), rhs.size() );204 return *this;205 }206 207 // modifiers208 inline void clear()209 {210 assign( nullptr, 0 );211 }212 inline void remove_prefix( size_type n )213 {214 size_type s = size();215 if ( n > s ) n = s;216 assign( data() + n, s - n );217 }218 inline void remove_suffix( size_type n )219 {220 size_type s = size();221 if ( n > s ) n = s;222 assign( data(), s - n );223 }224 225 };226 227 template < typename Storage >228 inline int string_base< Storage >::compare( const string_view& rhs ) const229 {230 size_type this_size = this->size();231 int cmp = nvmemcmp( this->data(), rhs.data(), nv::min( this_size, rhs.size() ) );232 return cmp != 0 ? cmp : ( this_size == rhs.size() ? 0 : this_size < rhs.size() ? -1 : 1 );233 }234 235 template < typename Storage >236 inline bool string_base< Storage >::starts_with( value_type c ) const237 {238 return !this->empty() && c == this->front();239 }240 template < typename Storage >241 inline bool string_base< Storage >::starts_with( const string_view& s ) const242 {243 return this->size() >= s.size() && nvmemcmp( this->data(), s.data(), s.size() ) == 0;244 }245 246 template < typename Storage >247 inline bool string_base< Storage >::ends_with( value_type c ) const248 {249 return !this->empty() && c == this->back();250 }251 template < typename Storage >252 inline bool string_base< Storage >::ends_with( const string_view& s ) const253 {254 return this->size() >= s.size() && nvmemcmp( this->data() + this->size() - s.size(), s.data(), s.size() ) == 0;255 }256 257 template < typename Storage >258 inline auto string_base< Storage >::find( value_type c, size_type pos /*= 0*/ ) const -> size_type259 {260 if ( pos >= this->size() ) return npos;261 const_iterator it = nv::find_if( this->cbegin() + static_cast<difference_type>( pos ), this->cend(), [=] ( value_type val ) { return val == c; } );262 return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );263 }264 template < typename Storage >265 inline auto string_base< Storage >::find( const string_view& s, size_type pos /*= 0*/ ) const -> size_type266 {267 if ( pos >= this->size() ) return npos;268 const_iterator it = nv::search( this->cbegin() + static_cast<difference_type>( pos ), this->cend(), s.cbegin(), s.cend() );269 return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );270 }271 272 template < typename Storage >273 inline auto string_base< Storage >::rfind( value_type c, size_type pos /*= 0*/ ) const -> size_type274 {275 if ( pos >= this->size() ) return npos;276 const_reverse_iterator it = nv::find_if( this->crbegin() + static_cast<difference_type>( pos ), this->crend(), [=] ( value_type val ) { return val == c; } );277 return it == this->crend() ? npos : this->reverse_distance( this->crbegin(), it );278 }279 template < typename Storage >280 inline auto string_base< Storage >::rfind( const string_view& s, size_type pos /*= 0*/ ) const -> size_type281 {282 if ( pos >= this->size() ) return npos;283 const_reverse_iterator it = nv::search( this->crbegin() + static_cast<difference_type>( pos ), this->crend(), s.crbegin(), s.crend() );284 return it == this->crend() ? npos : this->reverse_distance( this->crbegin(), it );285 }286 287 template < typename Storage >288 inline auto string_base< Storage >::find_first_of( value_type c ) const -> size_type289 {290 return this->find( c );291 }292 template < typename Storage >293 inline auto string_base< Storage >::find_first_of( const string_view& s ) const -> size_type294 {295 const_iterator it = nv::find_first_of( this->cbegin(), this->cend(), s.cbegin(), s.cend() );296 return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );297 }298 299 template < typename Storage >300 inline auto string_base< Storage >::find_last_of( value_type c ) const -> size_type301 {302 return this->rfind( c );303 }304 template < typename Storage >305 inline auto string_base< Storage >::find_last_of( const string_view& s ) const -> size_type306 {307 const_reverse_iterator it = nv::find_first_of( this->crbegin(), this->crend(), s.cbegin(), s.cend() );308 return it == this->crend() ? npos : this->reverse_distance( this->crbegin(), it );309 }310 311 template < typename Storage >312 inline auto string_base< Storage >::find_first_not_of( value_type c ) const -> size_type313 {314 for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )315 if ( c != *it )316 return static_cast<size_type>( nv::distance( this->cbegin(), it ) );317 return npos;318 }319 template < typename Storage >320 inline auto string_base< Storage >::find_first_not_of( const string_view& s ) const -> size_type321 {322 for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )323 if ( 0 == nvmemchr( s.data(), static_cast<uchar8>( *it ), s.size() ) )324 return static_cast<size_type>( nv::distance( this->cbegin(), it ) );325 return npos;326 }327 328 template < typename Storage >329 inline auto string_base< Storage >::find_last_not_of( value_type c ) const -> size_type330 {331 for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )332 if ( c != *it )333 return this->reverse_distance( this->crbegin(), it );334 return npos;335 }336 template < typename Storage >337 inline auto string_base< Storage >::find_last_not_of( const string_view& s ) const -> size_type338 {339 for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )340 if ( 0 == nvmemchr( s.data(), static_cast<uchar8>( *it ), s.size() ) )341 return this->reverse_distance( this->crbegin(), it );342 return npos;343 }344 345 template < typename Storage >346 inline string_view string_base< Storage >::substr( size_type p, size_type n ) const347 {348 if ( p > this->size() ) return string_view(); // NV_THROW( out_of_range( "substr" ) );349 if ( n == npos || n == p || p + n > this->size() ) n = this->size() - p;350 return string_view( this->data() + p, n );351 }352 353 #define NV_STRING_BASE_CAST_OPERATORS( OPERATOR )\354 template < typename S > inline bool operator OPERATOR ( const string_base< S >& lhs, const std::string& rhs )\355 {\356 return lhs OPERATOR string_view( rhs );\357 }\358 template < typename S > inline bool operator OPERATOR ( const std::string& lhs, const string_base< S >& rhs )\359 {\360 return string_view( lhs ) OPERATOR rhs;\361 }\362 template < typename S > inline bool operator OPERATOR ( const string_base< S >& lhs, const char* rhs )\363 {\364 return lhs OPERATOR string_view( rhs );\365 }\366 template < typename S > inline bool operator OPERATOR ( const char* lhs, const string_base< S >& rhs )\367 {\368 return string_view( lhs ) OPERATOR rhs;\369 }\370 371 // Base operators372 template < typename S1, typename S2 >373 inline bool operator==( const string_base< S1 >& lhs, const string_base< S2 >& rhs )374 {375 return lhs.size() != rhs.size() ? false : ( lhs.compare( rhs ) == 0 );376 }377 template < typename S1, typename S2 >378 inline bool operator!=( const string_base< S1 >& lhs, const string_base< S2 >& rhs )379 {380 return lhs.size() != rhs.size() ? true : ( lhs.compare( rhs ) != 0 );381 }382 template < typename S1, typename S2 >383 inline bool operator<( const string_base< S1 >& lhs, const string_base< S2 >& rhs )384 {385 return lhs.compare( rhs ) < 0;386 }387 template < typename S1, typename S2 >388 inline bool operator>( const string_base< S1 >& lhs, const string_base< S2 >& rhs )389 {390 return lhs.compare( rhs ) > 0;391 }392 template < typename S1, typename S2 >393 inline bool operator<=( const string_base< S1 >& lhs, const string_base< S2 >& rhs )394 {395 return lhs.compare( rhs ) <= 0;396 }397 template < typename S1, typename S2 >398 inline bool operator>=( const string_base< S1 >& lhs, const string_base< S2 >& rhs )399 {400 return lhs.compare( rhs ) >= 0;401 }402 403 NV_STRING_BASE_CAST_OPERATORS( == )404 NV_STRING_BASE_CAST_OPERATORS( != )405 NV_STRING_BASE_CAST_OPERATORS( < )406 NV_STRING_BASE_CAST_OPERATORS( > )407 NV_STRING_BASE_CAST_OPERATORS( <= )408 NV_STRING_BASE_CAST_OPERATORS( >= )409 410 411 #undef NV_STRING_REF_CAST_OPERATORS412 77 413 78 size_t sint32_to_buffer( sint32 n, char* str ); … … 423 88 float buffer_to_f32( const char* s, char** end ); 424 89 double buffer_to_f64( const char* s, char** end ); 425 426 // const string is movable but not copyable427 class const_string : public string_base< array_view< char > >428 {429 public:430 inline const_string() {}431 inline const_string( const char* str, size_type len )432 {433 initialize( str, len );434 }435 inline explicit const_string( const char* str )436 {437 initialize( str, nvstrlen( str ) );438 }439 inline const_string( const string_view& rhs )440 {441 initialize( rhs.data(), rhs.size() );442 }443 template< size_t N >444 inline const_string( char( &s )[N] )445 {446 initialize( s, N-1 );447 }448 template< size_t N >449 inline const_string( const char( &s )[N] )450 {451 initialize( s, N - 1 );452 }453 ~const_string()454 {455 if ( data() )456 {457 delete data();458 }459 }460 461 inline const_string( const_string&& other )462 {463 assign( other.data(), other.size() );464 other.assign( nullptr, 0 );465 }466 467 inline const_string& operator=( const_string&& other )468 {469 pointer old_data = data();470 size_type old_size = size();471 assign( other.data(), other.size() );472 other.assign( old_data, old_size );473 return *this;474 }475 476 // blocked copy constructor477 const_string( const const_string & ) = delete;478 // blocked copy operator479 const_string& operator=( const const_string& ) = delete;480 481 private:482 483 void initialize( const char* p, size_type s )484 {485 char* new_data = new char[s + 1];486 nvmemcpy( new_data, p, s );487 new_data[s] = 0;488 assign( new_data, s );489 }490 };491 492 class literal_string : public string_base< array_view< char > >493 {494 constexpr literal_string( const char* str, size_t len ) : this_type( str, len ) {}495 public:496 typedef string_base< array_view< char > > this_type;497 friend constexpr literal_string operator "" _ls( const char* str, size_t len );498 499 template< size_t N >500 constexpr literal_string( char( &s )[N] ) : this_type( s, N - 1 ) {}501 template< size_t N >502 constexpr literal_string( const char( &s )[N] ) : this_type( s, N - 1 ) {}503 };504 505 constexpr literal_string operator "" _ls( const char* str, size_t len )506 {507 return literal_string( str, len );508 }509 510 template < typename H >511 class hashed_literal_string;512 using hashed_literal_string_32 = hashed_literal_string< uint32 >;513 using hashed_literal_string_64 = hashed_literal_string< uint64 >;514 515 template < typename H >516 class hashed_literal_string : public string_base< array_view< char > >517 {518 constexpr hashed_literal_string( const char* str, size_t len, H hash_code )519 : this_type( str, len ), m_hash( hash_code ) {}520 public:521 typedef string_base< array_view< char > > this_type;522 523 template< size_t N >524 constexpr hashed_literal_string( char( &s )[N] )525 : this_type( s, N - 1 ), m_hash( detail::fnv_hash<H>::hash( s, N - 1 ) ) {}526 template< size_t N >527 constexpr hashed_literal_string( const char( &s )[N] )528 : this_type( s, N - 1 ), m_hash( detail::fnv_hash<H>::hash( s, N - 1 ) ) {}529 530 template < typename H2 >531 constexpr H get_hash() const532 {533 static_assert( is_same< H, H2 >::value, "32/64 bit hash mismatch on hash_literal_string!" );534 return m_hash;535 }536 537 friend constexpr hashed_literal_string_32 operator "" _hls32( const char* str, size_t len );538 friend constexpr hashed_literal_string_64 operator "" _hls64( const char* str, size_t len );539 protected:540 H m_hash;541 };542 543 constexpr hashed_literal_string_32 operator "" _hls32( const char* str, size_t len )544 {545 return hashed_literal_string_32( str, len, detail::fnv_hash< uint32 >::hash( str, len ) );546 }547 548 constexpr hashed_literal_string_64 operator "" _hls64( const char* str, size_t len )549 {550 return hashed_literal_string_64( str, len, detail::fnv_hash< uint64 >::hash( str, len ) );551 }552 553 template< typename H >554 struct hash< hashed_literal_string_32, H >555 {556 static_assert( is_same< uint32, H >::value, "hashed_literal_string_32 used with non-32 bit hash!" );557 static constexpr H get( const hashed_literal_string_32& value )558 {559 return value.get_hash< H >();560 }561 constexpr H operator()( const hashed_literal_string_32& value ) const { return get( value ); }562 };563 564 template< typename H >565 struct hash< hashed_literal_string_64, H >566 {567 static_assert( is_same< uint64, H >::value, "hashed_literal_string_64 used with non-64 bit hash!" );568 static constexpr H get( const hashed_literal_string_64& value )569 {570 return value.get_hash< H >();571 }572 constexpr H operator()( const hashed_literal_string_64& value ) const { return get( value ); }573 };574 90 575 91 inline string_view trimmed( const string_view& str ) … … 648 164 } 649 165 650 using nv::operator "" _ls;651 using nv::operator "" _hls32;652 using nv::operator "" _hls64;653 654 166 #endif // NV_STL_STRING_HH -
trunk/src/core/library.cc
r403 r433 62 62 string_view library::get_name() const 63 63 { 64 return string_view( m_name );64 return string_view( m_name.c_str(), m_name.size() ); 65 65 } 66 66 … … 71 71 return true; 72 72 } 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..." ); 74 74 75 75 std::string name = m_name; 76 st ring_viewext( NV_LIB_EXT );76 std::string ext( NV_LIB_EXT ); 77 77 78 78 if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext ) … … 85 85 if ( m_handle == NULL ) 86 86 { 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!" ); 88 88 return false; 89 89 } 90 NV_LOG_NOTICE( "library \"", string_view( name), "\" : loaded." );90 NV_LOG_NOTICE( "library \"", string_view( m_name.c_str(), m_name.size() ), "\" : loaded." ); 91 91 return true; 92 92 } … … 97 97 if ( !result ) 98 98 { 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, "\"" ); 100 100 NV_ABORT( "Library symbol load failed!" ); 101 101 } … … 117 117 if ( ! NV_LIB_CLOSE( m_handle ) ) 118 118 { 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!" ); 120 120 } 121 121 m_handle = nullptr; -
trunk/src/engine/particle_engine.cc
r406 r433 435 435 { 436 436 data.affector_count--; 437 NV_LOG_WARNING( "Bad data passed to ", s ub_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!" ); 438 438 } 439 439 } … … 441 441 { 442 442 data.affector_count--; 443 NV_LOG_WARNING( "Unknown affector type in particle system! (", s ub_type, ")" );443 NV_LOG_WARNING( "Unknown affector type in particle system! (", string_view( sub_type.c_str(), sub_type.size() ), ")" ); 444 444 } 445 445 } -
trunk/src/engine/program_manager.cc
r399 r433 37 37 } 38 38 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() ) ); 40 40 return add( program ); 41 41 } -
trunk/src/engine/resource_system.cc
r431 r433 12 12 { 13 13 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() ) ); 15 16 } 16 17 -
trunk/src/formats/md5_loader.cc
r428 r433 155 155 sstream >> shader; 156 156 remove_quotes( shader ); 157 maccess.set_name( make_name( shader ) );157 maccess.set_name( make_name( shader.c_str() ) ); 158 158 next_line( sstream ); 159 159 } -
trunk/src/formats/obj_loader.cc
r427 r433 328 328 data_channel_set* result = data_channel_set_creator::create_set( 1 ); 329 329 data_channel_set_creator raccess( result ); 330 raccess.set_name( make_name( reader->name ) );330 raccess.set_name( make_name( reader->name.c_str() ) ); 331 331 uint8* rdata = raccess.add_channel( m_descriptor, reader->size * 3 ).raw_data(); 332 332 -
trunk/src/gl/gl_device.cc
r406 r433 19 19 m_shader_header = "#version 120\n"; 20 20 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"; 22 22 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"; 24 24 } 25 25 … … 212 212 for ( auto& i : *info->m_uniform_map ) 213 213 { 214 auto j = lmap.find( i.first );214 auto j = lmap.find( i.first.c_str() ); 215 215 if ( j != lmap.end() ) 216 216 { … … 218 218 } 219 219 220 auto k = map.find( i.first );220 auto k = map.find( i.first.c_str() ); 221 221 if ( k != map.end() ) 222 222 { … … 238 238 if ( fatal ) 239 239 { 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!" ); 241 241 NV_ABORT( "gl_device : uniform not found!" ); 242 242 } … … 257 257 if ( fatal ) 258 258 { 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!" ); 260 260 NV_ABORT( "gl_device : attribute not found!" ); 261 261 } -
trunk/src/gui/gui_environment.cc
r401 r433 30 30 } 31 31 32 void nv::gui::environment::load_style( const st d::string& filename )32 void nv::gui::environment::load_style( const string_view& filename ) 33 33 { 34 34 m_renderer->load_style( filename ); -
trunk/src/gui/gui_gfx_renderer.cc
r406 r433 187 187 } 188 188 189 nv::size_t gfx_renderer::load_font( const st d::string& filename, nv::size_t size )190 { 191 std::string id_name( filename );189 nv::size_t gfx_renderer::load_font( const string_view& filename, nv::size_t size ) 190 { 191 std::string id_name( filename.data(), filename.size() ); 192 192 char buffer[8]; size_t len = nv::sint32_to_buffer( sint32( size ), buffer ); 193 193 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 ); 195 196 if ( i != m_font_names.end() ) 196 197 { … … 198 199 } 199 200 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 ) ); 201 202 f->load_glyphs( "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ " ); 202 203 m_fonts.push_back( f ); 203 204 m_reupload = true; 204 m_font_names[ id_name] = result;205 m_font_names[ id ] = result; 205 206 return result; 206 207 } 207 208 208 nv::size_t gfx_renderer::load_image( const st d::string& filename )209 nv::size_t gfx_renderer::load_image( const string_view& filename ) 209 210 { 210 211 auto i = m_image_names.find( filename ); … … 253 254 if ( m_style.get( e, "skin", selector, path ) ) 254 255 { 255 size_t image_id = load_image( path);256 size_t image_id = load_image( string_view( path.c_str(), path.size() ) ); 256 257 const image_info* image = get_image( image_id ); 257 258 if ( image ) … … 318 319 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 ) ) 319 320 { 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 ) ); 321 322 texture_font* font = get_font( font_id ); 322 323 position p = abs.ul + position( 0, border ); -
trunk/src/gui/gui_renderer.cc
r395 r433 7 7 #include "nv/gui/gui_renderer.hh" 8 8 9 void nv::gui::renderer::load_style( const st d::string& filename )9 void nv::gui::renderer::load_style( const string_view& filename ) 10 10 { 11 11 m_style.load_style( filename ); -
trunk/src/gui/gui_style.cc
r406 r433 16 16 } 17 17 18 void style::load_style( const st d::string& filename )18 void style::load_style( const string_view& filename ) 19 19 { 20 20 m_lua.do_file( filename ); -
trunk/src/lua/lua_function.cc
r406 r433 21 21 { 22 22 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() ); 24 24 } 25 25 … … 27 27 { 28 28 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() ); 30 30 } 31 31 m_ref = luaL_ref( L, LUA_REGISTRYINDEX ); -
trunk/src/lua/lua_map_tile.cc
r406 r433 55 55 nv::map_area* map_area = nv::lua::detail::to_map_area( L, 3 ); 56 56 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() ); 58 59 std::string chars( " \r\t" ); 59 60 code.erase( nv::remove_if( code.begin(), code.end(), -
trunk/src/lua/lua_state.cc
r431 r433 116 116 if ( !p.resolve( m_state, global ) ) 117 117 { 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() ); 119 119 return false; 120 120 } … … 123 123 { 124 124 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() ); 126 126 return false; 127 127 } … … 442 442 for ( int i = 0; i < top; ++i ) 443 443 { 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() ); 445 445 } 446 446 }
Note: See TracChangeset
for help on using the changeset viewer.