Changeset 399
- Timestamp:
- 06/13/15 11:47:09 (10 years ago)
- Location:
- trunk
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/library.hh
r395 r399 39 39 * Throws library_error on failure 40 40 */ 41 void open( string_ refname );41 void open( string_view name ); 42 42 43 43 /** … … 46 46 * returns true if succeeded, false otherwise 47 47 */ 48 bool try_open( string_ refname );48 bool try_open( string_view name ); 49 49 50 50 /** … … 56 56 * Returns library name 57 57 */ 58 string_ refget_name() const;58 string_view get_name() const; 59 59 60 60 /** … … 63 63 * Throws on symbol not found 64 64 */ 65 void* get( string_ refsymbol );65 void* get( string_view symbol ); 66 66 67 67 /** … … 70 70 * Returns null if symbol not found 71 71 */ 72 void* try_get( string_ refsymbol );72 void* try_get( string_view symbol ); 73 73 74 74 /** -
trunk/nv/core/logger.hh
r395 r399 34 34 * @param message message to be logged. 35 35 */ 36 virtual void log( log_level level, const string_ ref& message ) = 0;36 virtual void log( log_level level, const string_view& message ) = 0; 37 37 /** 38 38 * Enforcement of virtual destructor. … … 47 47 * Log level name (unpadded) 48 48 */ 49 string_ reflevel_name( log_level level ) const;49 string_view level_name( log_level level ) const; 50 50 /** 51 51 * Log level name (padded) 52 52 */ 53 string_ refpadded_level_name( log_level level ) const;53 string_view padded_level_name( log_level level ) const; 54 54 }; 55 55 … … 86 86 * @param message message to be logged. 87 87 */ 88 virtual void log( log_level level, const string_ ref& message );88 virtual void log( log_level level, const string_view& message ); 89 89 90 90 /** … … 144 144 * Logging function. 145 145 */ 146 virtual void log( log_level level, const string_ ref& message );146 virtual void log( log_level level, const string_view& message ); 147 147 148 148 private: … … 176 176 * Logging function. 177 177 */ 178 virtual void log( log_level level, const string_ ref& message );178 virtual void log( log_level level, const string_view& message ); 179 179 180 180 protected: … … 201 201 * @param flush_always if set to false, wont flush after each line. 202 202 */ 203 log_file_sink( const string_ ref& file_name, bool flush_always = true );203 log_file_sink( const string_view& file_name, bool flush_always = true ); 204 204 205 205 /** -
trunk/nv/core/logging.hh
r396 r399 50 50 m_level = level; 51 51 } 52 virtual void log( log_level level, const string_ ref& message ) = 0;53 void log_append( string_ refref )52 virtual void log( log_level level, const string_view& message ) = 0; 53 void log_append( string_view ref ) 54 54 { 55 55 nvmemcpy( m_pos, ref.data(), ref.size() ); … … 84 84 { 85 85 *m_pos = '\0'; 86 log( level, string_ ref( m_message, (size_t)( m_pos - m_message ) ) );86 log( level, string_view( m_message, (size_t)( m_pos - m_message ) ) ); 87 87 m_pos = m_message; 88 88 } -
trunk/nv/core/profiler.hh
r395 r399 44 44 } 45 45 protected: 46 node( const string_ ref& tag, node* parent );47 node* request_child( const string_ ref& tag );46 node( const string_view& tag, node* parent ); 47 node* request_child( const string_view& tag ); 48 48 void start(); 49 49 bool stop(); … … 66 66 ~profiler(); 67 67 68 void start_profile( const string_ ref& tag );68 void start_profile( const string_view& tag ); 69 69 void stop_profile(); 70 70 public: … … 82 82 { 83 83 public: 84 profiler_guard( string_ reftag )84 profiler_guard( string_view tag ) 85 85 { 86 86 profiler::pointer()->start_profile( tag ); … … 96 96 { 97 97 public: 98 profiler_condition_guard( string_ reftag, bool condition )98 profiler_condition_guard( string_view tag, bool condition ) 99 99 : m_active( condition ) 100 100 { -
trunk/nv/engine/program_manager.hh
r395 r399 24 24 public: 25 25 program_manager( context* a_context ); 26 virtual string_ refget_storage_name() const { return "programs"; }27 virtual string_ refget_resource_name() const { return "program"; }26 virtual string_view get_storage_name() const { return "programs"; } 27 virtual string_view get_resource_name() const { return "program"; } 28 28 protected: 29 29 virtual resource_id load_resource( lua::table_guard& table ); -
trunk/nv/engine/resource_system.hh
r395 r399 33 33 resource_manager_base() : m_lua( nullptr ) {} 34 34 void initialize( lua::state* state ); 35 virtual string_ refget_storage_name() const = 0;36 virtual string_ refget_resource_name() const = 0;35 virtual string_view get_storage_name() const = 0; 36 virtual string_view get_resource_name() const = 0; 37 37 virtual void clear() { m_names.clear(); } 38 38 void load_all(); -
trunk/nv/fmod/fmod_audio.hh
r395 r399 35 35 virtual channel play_sound( sound a_sound, float volume = 1.0f, float pan = 0.0f ); 36 36 virtual channel play_sound( sound a_sound, vec3 position ); 37 virtual sound load_sound( const string_ ref& a_path );37 virtual sound load_sound( const string_view& a_path ); 38 38 virtual void release( sound a_sound ); 39 39 virtual void set_orientation( vec3 forward, vec3 up ); -
trunk/nv/formats/md3_loader.hh
r395 r399 41 41 private: 42 42 void release_mesh_frame( mesh_data* data, sint32 frame, sint32 surface ); 43 key_raw_channel* load_tags( const string_ ref& tag );43 key_raw_channel* load_tags( const string_view& tag ); 44 44 bool m_merge_all; 45 45 void* m_md3; -
trunk/nv/formats/md5_loader.hh
r398 r399 83 83 protected: 84 84 void reset(); 85 void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_info, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data );85 void build_frame_skeleton( mesh_node_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_info, const array_view<transform>& base_frames, const array_view<float>& frame_data ); 86 86 bool prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info ); 87 87 protected: -
trunk/nv/gfx/texture_font.hh
r395 r399 45 45 texture_font( texture_atlas* atlas, const char * filename, float size ); 46 46 const texture_glyph* get_glyph( uint16 charcode ) const; 47 bool load_glyphs( string_ refcodes );47 bool load_glyphs( string_view codes ); 48 48 float get_size() const { return m_size; } 49 49 ~texture_font(); -
trunk/nv/gl/gl_device.hh
r395 r399 41 41 42 42 gl_device(); 43 virtual image_data* create_image_data( string_ reffilename ); // temporary43 virtual image_data* create_image_data( string_view filename ); // temporary 44 44 virtual image_data* create_image_data( const uint8* data, uint32 size ); // temporary 45 45 46 virtual program create_program( string_ ref vs_source, string_reffs_source );46 virtual program create_program( string_view vs_source, string_view fs_source ); 47 47 virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ); 48 48 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ); … … 63 63 64 64 private: 65 bool compile( gl_program_info* p, string_ ref vertex_program, string_reffragment_program );66 bool compile( uint32 sh_type, string_ refshader_code, unsigned& glid );65 bool compile( gl_program_info* p, string_view vertex_program, string_view fragment_program ); 66 bool compile( uint32 sh_type, string_view shader_code, unsigned& glid ); 67 67 void update_uniforms( gl_program_info* p ); 68 68 void load_attributes( gl_program_info* p ); -
trunk/nv/interface/audio.hh
r395 r399 33 33 virtual channel play_sound( sound a_sound, vec3 position ) = 0; 34 34 // temporary - use streams later 35 virtual sound load_sound( const string_ ref& a_path ) = 0;35 virtual sound load_sound( const string_view& a_path ) = 0; 36 36 virtual void release( sound a_sound ) = 0; 37 37 virtual void set_orientation( vec3 forward, vec3 up ) = 0; -
trunk/nv/interface/context.hh
r395 r399 300 300 { 301 301 vertex_array va = create_vertex_array(); 302 const_array_ref< mesh_raw_channel* > channels = data->get_raw_channels();302 array_view< mesh_raw_channel* > channels = data->get_raw_channels(); 303 303 for ( uint32 ch = 0; ch < channels.size(); ++ch ) 304 304 { -
trunk/nv/interface/device.hh
r395 r399 157 157 initialize_engine_uniforms(); 158 158 } 159 virtual program create_program( string_ ref vs_source, string_reffs_source ) = 0;159 virtual program create_program( string_view vs_source, string_view fs_source ) = 0; 160 160 virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ) = 0; 161 161 virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) = 0; 162 162 // TODO: remove? 163 163 virtual texture create_texture( ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) { return create_texture( TEXTURE_2D, size, aformat, asampler, data ); } 164 virtual image_data* create_image_data( string_ reffilename ) = 0; // temporary164 virtual image_data* create_image_data( string_view filename ) = 0; // temporary 165 165 virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary 166 166 virtual void release( texture ) = 0; … … 205 205 206 206 template < typename T > 207 void set_opt_uniform_array( program p, const std::string& name, const const_array_ref<T>& value )207 void set_opt_uniform_array( program p, const std::string& name, const array_view<T>& value ) 208 208 { 209 209 set_uniform_array( p, name, (const T*)value.data(), value.size(), false ); -
trunk/nv/interface/mesh_data.hh
r395 r399 106 106 } 107 107 108 const_array_ref< mesh_raw_channel* > get_raw_channels() const { return m_channels; }109 const mesh_raw_channel* 108 array_view< mesh_raw_channel* > get_raw_channels() const { return m_channels; } 109 const mesh_raw_channel* get_index_channel() const { return m_index_channel; } 110 110 size_t get_channel_count() const { return m_channels.size(); } 111 111 const mesh_raw_channel* get_channel( size_t index ) const -
trunk/nv/interface/uniform.hh
r395 r399 152 152 typedef nv::vector< engine_uniform_base* > engine_uniform_list; 153 153 // TODO - change to literal type map 154 typedef nv::unordered_map< string_ ref, engine_uniform_factory_base* > engine_uniform_factory_map;155 typedef nv::unordered_map< string_ ref, engine_link_uniform_base* > engine_link_uniform_factory_map;154 typedef nv::unordered_map< string_view, engine_uniform_factory_base* > engine_uniform_factory_map; 155 typedef nv::unordered_map< string_view, engine_link_uniform_base* > engine_link_uniform_factory_map; 156 156 157 157 class engine_uniform_m_view : public engine_uniform< mat4 > -
trunk/nv/lua/lua_nova.hh
r395 r399 14 14 namespace lua 15 15 { 16 void register_storage( state* a_state, string_ ref name, string_refconstructor_name );16 void register_storage( state* a_state, string_view name, string_view constructor_name ); 17 17 void register_nova( state* a_state ); 18 18 } -
trunk/nv/lua/lua_path.hh
r396 r399 55 55 void parse(); 56 56 void push( uint32 value ); 57 void push( string_ refp );57 void push( string_view p ); 58 58 59 59 private: -
trunk/nv/lua/lua_state.hh
r395 r399 129 129 } 130 130 bool is_defined( const path& p ) { return is_defined( p, m_global ); } 131 void register_native_function( lfunction f, string_ refname );131 void register_native_function( lfunction f, string_view name ); 132 132 133 133 template < typename F, F f > 134 void register_function( string_ refname )134 void register_function( string_view name ) 135 135 { 136 136 register_native_function( detail::function_wrapper< F, f >, name ); … … 138 138 139 139 template < typename C, typename F, F f > 140 void register_function( string_ refname )140 void register_function( string_view name ) 141 141 { 142 142 register_native_function( detail::object_method_wrapper< C, F, f >, name ); … … 192 192 explicit state( bool load_libs = false ); 193 193 explicit state( lua_State* state ); 194 bool do_string( string_ ref code, string_refname, int rvalues = 0 );195 bool do_file( string_ reffilename );194 bool do_string( string_view code, string_view name, int rvalues = 0 ); 195 bool do_file( string_view filename ); 196 196 int get_stack_size(); 197 197 void log_stack(); 198 198 lua_State* get_raw(); 199 ref register_object( void* o, string_ reflua_name );200 ref register_proto( string_ ref id, string_refstorage );201 void store_metadata( ref object_index, string_ refmetaname, void* pointer );199 ref register_object( void* o, string_view lua_name ); 200 ref register_proto( string_view id, string_view storage ); 201 void store_metadata( ref object_index, string_view metaname, void* pointer ); 202 202 void unregister_object( ref object_index ); 203 203 204 void register_enum( string_ refname, int value );205 void register_singleton( string_ refname, void* o );206 207 void register_native_object_method( string_ ref lua_name, string_refname, lfunction f );204 void register_enum( string_view name, int value ); 205 void register_singleton( string_view name, void* o ); 206 207 void register_native_object_method( string_view lua_name, string_view name, lfunction f ); 208 208 template < typename F, F f > 209 void register_object_method( string_ ref lua_name, string_refname )209 void register_object_method( string_view lua_name, string_view name ) 210 210 { 211 211 register_native_object_method( lua_name, name, detail::object_method_wrapper< typename memfn_class_type<F>::type, F, f > ); … … 224 224 } 225 225 template < typename H > 226 ref register_handle_component( const H& handle, string_ refid )226 ref register_handle_component( const H& handle, string_view id ) 227 227 { 228 228 nv::lua::push_handle( m_state, handle ); … … 230 230 } 231 231 template < typename H > 232 ref register_handle_component( const H& handle, string_ refid, const path& proto )232 ref register_handle_component( const H& handle, string_view id, const path& proto ) 233 233 { 234 234 if ( !proto.resolve( m_state, true ) ) … … 240 240 } 241 241 template < typename H > 242 void unregister_handle_component( const H& handle, string_ refid )242 void unregister_handle_component( const H& handle, string_view id ) 243 243 { 244 244 nv::lua::push_handle( m_state, handle ); … … 277 277 278 278 private: 279 ref register_handle_component_impl( string_ refid, bool empty );280 void unregister_handle_component_impl( string_ refid );281 282 int load_string( string_ ref code, string_refname );283 int load_file( string_ reffilename );284 int do_current( string_ refname, int rvalues = 0 );279 ref register_handle_component_impl( string_view id, bool empty ); 280 void unregister_handle_component_impl( string_view id ); 281 282 int load_string( string_view code, string_view name ); 283 int load_file( string_view filename ); 284 int do_current( string_view name, int rvalues = 0 ); 285 285 void deep_pointer_copy( int index, void* obj ); 286 286 }; … … 293 293 virtual ~table_guard(); 294 294 size_t get_size(); 295 bool has_field( string_ refelement );296 std::string get_std_string( string_ ref element, string_ref defval = string_ref() );297 const_string get_string( string_ ref element, string_ref defval = string_ref() );298 char get_char( string_ refelement, char defval = ' ' );299 int get_integer( string_ refelement, int defval = 0 );300 unsigned get_unsigned( string_ refelement, unsigned defval = 0 );301 double get_double( string_ refelement, double defval = 0.0 );302 float get_float( string_ refelement, float defval = 0.0 );303 bool get_boolean( string_ refelement, bool defval = false );304 bool is_table( string_ refelement );305 bool is_number( string_ refelement );306 bool is_boolean( string_ refelement );307 bool is_string( string_ refelement );295 bool has_field( string_view element ); 296 std::string get_std_string( string_view element, string_view defval = string_view() ); 297 const_string get_string( string_view element, string_view defval = string_view() ); 298 char get_char( string_view element, char defval = ' ' ); 299 int get_integer( string_view element, int defval = 0 ); 300 unsigned get_unsigned( string_view element, unsigned defval = 0 ); 301 double get_double( string_view element, double defval = 0.0 ); 302 float get_float( string_view element, float defval = 0.0 ); 303 bool get_boolean( string_view element, bool defval = false ); 304 bool is_table( string_view element ); 305 bool is_number( string_view element ); 306 bool is_boolean( string_view element ); 307 bool is_string( string_view element ); 308 308 private: 309 309 int m_level; -
trunk/nv/lua/lua_values.hh
r395 r399 74 74 void push_bool ( lua_State *L, bool v ); 75 75 void push_string ( lua_State *L, const std::string& s ); 76 void push_string_ ref ( lua_State *L, string_refs );76 void push_string_view( lua_State *L, string_view s ); 77 77 void push_cstring ( lua_State *L, const char* s ); 78 78 void push_pointer ( lua_State *L, void* p ); … … 85 85 std::string to_string ( lua_State *L, int index ); 86 86 const char* to_cstring ( lua_State *L, int index ); 87 string_ ref to_string_ref( lua_State *L, int index );87 string_view to_string_view( lua_State *L, int index ); 88 88 void* to_pointer ( lua_State *L, int index ); 89 89 void* to_ref_object ( lua_State *L, int index ); … … 95 95 std::string to_string ( lua_State *L, int index, const std::string& def ); 96 96 const char* to_cstring ( lua_State *L, int index, const char* def ); 97 string_ ref to_string_ref ( lua_State *L, int index, string_refdef );97 string_view to_string_view( lua_State *L, int index, string_view def ); 98 98 void* to_pointer ( lua_State *L, int index, void* def ); 99 99 void* to_ref_object ( lua_State *L, int index, void* def ); … … 159 159 160 160 template <> 161 struct pass_traits < string_ ref>162 { 163 static void push( lua_State *L, string_ ref s ) { detail::push_string_ref( L, s ); }164 static string_ ref to( lua_State *L, int index ) { return detail::to_string_ref( L, index ); }165 static string_ ref to( lua_State *L, int index, string_ref def ) { return detail::to_string_ref( L, index, def ); }161 struct pass_traits < string_view > 162 { 163 static void push( lua_State *L, string_view s ) { detail::push_string_view( L, s ); } 164 static string_view to( lua_State *L, int index ) { return detail::to_string_view( L, index ); } 165 static string_view to( lua_State *L, int index, string_view def ) { return detail::to_string_view( L, index, def ); } 166 166 }; 167 167 -
trunk/nv/sdl/sdl_audio.hh
r395 r399 33 33 virtual channel play_sound( sound a_sound, float volume = 1.0f, float pan = 0.0f ); 34 34 virtual channel play_sound( sound a_sound, vec3 position ); 35 virtual sound load_sound( const string_ ref& a_path );35 virtual sound load_sound( const string_view& a_path ); 36 36 virtual void release( sound a_sound ); 37 37 virtual void set_orientation( vec3 forward, vec3 up ); -
trunk/nv/stl/container/contiguous_storage_policy.hh
r395 r399 45 45 46 46 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 47 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }47 operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); } 48 48 49 49 // allow move … … 72 72 73 73 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 74 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }74 operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); } 75 75 protected: 76 76 constexpr resizable_storage() : m_size( 0 ) {} … … 141 141 142 142 operator array_ref< value_type >() { return array_ref< value_type >( Storage::data(), size() ); } 143 operator const_array_ref< value_type >() const { return const_array_ref< value_type >( Storage::data(), size() ); }143 operator array_view< value_type >() const { return array_view< value_type >( Storage::data(), size() ); } 144 144 protected: 145 145 constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {} -
trunk/nv/stl/memory.hh
r396 r399 34 34 35 35 template< typename T > 36 class storage_ view36 class storage_ref 37 37 { 38 38 public: … … 43 43 static constexpr bool is_const = false; 44 44 45 constexpr storage_ view()45 constexpr storage_ref() 46 46 : m_data( nullptr ), m_size( 0 ) {} 47 constexpr storage_ view( value_type* a_data, size_type a_size )47 constexpr storage_ref( value_type* a_data, size_type a_size ) 48 48 : m_data( a_data ), m_size( a_size ) {} 49 49 … … 67 67 68 68 template< typename T > 69 class const_storage_view69 class storage_view 70 70 { 71 71 public: … … 76 76 static constexpr bool is_const = true; 77 77 78 constexpr const_storage_view()78 constexpr storage_view() 79 79 : m_data( nullptr ), m_size( 0 ) {} 80 constexpr const_storage_view( const value_type* a_data, size_type a_size )80 constexpr storage_view( const value_type* a_data, size_type a_size ) 81 81 : m_data( a_data ), m_size( a_size ) {} 82 constexpr const_storage_view( const storage_view<T>& view )82 constexpr storage_view( const storage_ref<T>& view ) 83 83 : m_data( view.data() ), m_size( view.size() ) {} 84 84 … … 474 474 475 475 template < typename T > 476 using const_array_ref = detail::add_random_access< detail::add_iterators < const_storage_view< T > > >;477 template < typename T > 478 using array_ref = detail::add_random_access< detail::add_iterators < storage_view< T > > >;479 using const_mem_ref = const_array_ref< char >;476 using array_view = detail::add_random_access< detail::add_iterators < storage_view< T > > >; 477 template < typename T > 478 using array_ref = detail::add_random_access< detail::add_iterators < storage_ref< T > > >; 479 using mem_view = array_view< char >; 480 480 using mem_ref = array_ref< char >; 481 481 -
trunk/nv/stl/string.hh
r395 r399 77 77 }; 78 78 79 class string_ ref;79 class string_view; 80 80 81 81 // string base class - will become a base for a string class later 82 class string_base : public detail::add_iterators< const_storage_view< char > >83 { 84 typedef detail::add_iterators< const_storage_view< char > > inherited;82 class string_base : public detail::add_iterators< storage_view< char > > 83 { 84 typedef detail::add_iterators< storage_view< char > > inherited; 85 85 public: 86 86 typedef char value_type; … … 197 197 198 198 // string operations 199 string_ refsubstr( size_type p, size_type n = npos ) const;199 string_view substr( size_type p, size_type n = npos ) const; 200 200 201 201 inline size_t hash() const … … 245 245 246 246 247 class string_ ref: public string_base247 class string_view : public string_base 248 248 { 249 249 public: 250 inline string_ ref() {}251 inline string_ ref( const string_ref& rhs )250 inline string_view() {} 251 inline string_view( const string_view& rhs ) 252 252 : string_base( rhs.data(), rhs.size() ) 253 253 { 254 254 } 255 inline string_ ref( const string_base& rhs )255 inline string_view( const string_base& rhs ) 256 256 : string_base( rhs.data(), rhs.size() ) 257 257 { 258 258 } 259 259 260 inline string_ ref( const std::string& str )260 inline string_view( const std::string& str ) 261 261 : string_base( str.data(), str.size() ) 262 262 { 263 263 } 264 264 265 inline string_ ref( const char* str, size_type len )265 inline string_view( const char* str, size_type len ) 266 266 : string_base( str, len ) 267 267 { … … 270 270 // Literal constructors 271 271 template< size_t N > 272 inline string_ ref( char( &s )[N] ) : string_base( s, N - 1 ) {}273 template< size_t N > 274 inline string_ ref( const char( &s )[N] ) : string_base( s, N - 1 ) {}272 inline string_view( char( &s )[N] ) : string_base( s, N - 1 ) {} 273 template< size_t N > 274 inline string_view( const char( &s )[N] ) : string_base( s, N - 1 ) {} 275 275 276 276 // Non-literal constructors 277 277 template< typename U > 278 inline string_ ref( U str, typename enable_if<is_same<U, const char*>::value>::type* = nullptr ) : string_base( str, nvstrlen( str ) ) {}278 inline string_view( U str, typename enable_if<is_same<U, const char*>::value>::type* = nullptr ) : string_base( str, nvstrlen( str ) ) {} 279 279 280 280 // Non-literal constructors 281 281 template< typename U > 282 inline string_ ref( U str, typename enable_if<is_same<U, char*>::value>::type* = nullptr ) : string_base( str, nvstrlen( str ) ) {}283 284 inline string_ ref& operator=( const string_ref&rhs )282 inline string_view( U str, typename enable_if<is_same<U, char*>::value>::type* = nullptr ) : string_base( str, nvstrlen( str ) ) {} 283 284 inline string_view& operator=( const string_view &rhs ) 285 285 { 286 286 assign( rhs.data(), rhs.size() ); … … 309 309 310 310 template< typename H > 311 struct hash< string_ ref, H > : hash< string_base, H >{};311 struct hash< string_view, H > : hash< string_base, H >{}; 312 312 313 313 // const string is movable but not copyable … … 364 364 }; 365 365 366 inline string_ refstring_base::substr( size_type p, size_type n ) const367 { 368 if ( p > size() ) return string_ ref(); // NV_THROW( out_of_range( "substr" ) );366 inline string_view string_base::substr( size_type p, size_type n ) const 367 { 368 if ( p > size() ) return string_view(); // NV_THROW( out_of_range( "substr" ) ); 369 369 if ( n == p || p + n > size() ) n = size() - p; 370 return string_ ref( data() + p, n );370 return string_view( data() + p, n ); 371 371 } 372 372 … … 374 374 inline bool operator OPERATOR ( const string_base& lhs, const std::string& rhs )\ 375 375 {\ 376 return lhs OPERATOR string_ ref( rhs );\376 return lhs OPERATOR string_view( rhs );\ 377 377 }\ 378 378 inline bool operator OPERATOR ( const std::string& lhs, const string_base& rhs )\ 379 379 {\ 380 return string_ ref( lhs ) OPERATOR rhs;\380 return string_view( lhs ) OPERATOR rhs;\ 381 381 }\ 382 382 inline bool operator OPERATOR ( const string_base& lhs, const char* rhs )\ 383 383 {\ 384 return lhs OPERATOR string_ ref( rhs );\384 return lhs OPERATOR string_view( rhs );\ 385 385 }\ 386 386 inline bool operator OPERATOR ( const char* lhs, const string_base& rhs )\ 387 387 {\ 388 return string_ ref( lhs ) OPERATOR rhs;\388 return string_view( lhs ) OPERATOR rhs;\ 389 389 }\ 390 390 … … 432 432 size_t f64_to_buffer( f64 n, char* str ); 433 433 434 inline string_ ref trimmed( const string_ref& str )434 inline string_view trimmed( const string_view& str ) 435 435 { 436 436 size_t endpos = str.find_last_not_of( " \r\n\t" ); 437 437 size_t startpos = str.find_first_not_of( " \r\n\t" ); 438 438 439 if ( string_ ref::npos != endpos || string_ref::npos != startpos )440 { 441 if ( string_ ref::npos == startpos ) startpos = 0;442 if ( string_ ref::npos != endpos ) endpos = endpos + 1 - startpos;439 if ( string_view::npos != endpos || string_view::npos != startpos ) 440 { 441 if ( string_view::npos == startpos ) startpos = 0; 442 if ( string_view::npos != endpos ) endpos = endpos + 1 - startpos; 443 443 return str.substr( startpos, endpos ); 444 444 } … … 446 446 } 447 447 448 inline string_ ref rtrimmed( const string_ref& str )448 inline string_view rtrimmed( const string_view& str ) 449 449 { 450 450 size_t endpos = str.find_last_not_of( " \r\n\t" ); 451 if ( string_ ref::npos != endpos )451 if ( string_view::npos != endpos ) 452 452 { 453 453 return str.substr( 0, endpos + 1 ); … … 456 456 } 457 457 458 inline string_ ref ltrimmed( const string_ref& str )458 inline string_view ltrimmed( const string_view& str ) 459 459 { 460 460 size_t startpos = str.find_first_not_of( " \r\n\t" ); 461 if ( string_ ref::npos != startpos )461 if ( string_view::npos != startpos ) 462 462 { 463 463 return str.substr( startpos ); … … 467 467 468 468 469 inline string_ ref extract_extension( string_reffilename )469 inline string_view extract_extension( string_view filename ) 470 470 { 471 471 size_t lastdot = filename.find_last_of( '.' ); 472 if ( string_ ref::npos != lastdot )472 if ( string_view::npos != lastdot ) 473 473 return filename.substr( lastdot + 1 ); 474 474 return filename; -
trunk/src/core/library.cc
r395 r399 41 41 } 42 42 43 void library::open( string_ refname )43 void library::open( string_view name ) 44 44 { 45 45 m_name.assign( name.data(), name.size() ); … … 51 51 } 52 52 53 bool nv::library::try_open( string_ refname )53 bool nv::library::try_open( string_view name ) 54 54 { 55 55 m_name.assign( name.data(), name.size() ); … … 62 62 } 63 63 64 string_ reflibrary::get_name() const64 string_view library::get_name() const 65 65 { 66 return string_ ref( m_name );66 return string_view( m_name ); 67 67 } 68 68 … … 76 76 77 77 std::string name = m_name; 78 string_ refext( NV_LIB_EXT );78 string_view ext( NV_LIB_EXT ); 79 79 80 80 if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext ) … … 94 94 } 95 95 96 void* library::get( string_ refsymbol )96 void* library::get( string_view symbol ) 97 97 { 98 98 void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() ); … … 104 104 } 105 105 106 void* nv::library::try_get( string_ refsymbol )106 void* nv::library::try_get( string_view symbol ) 107 107 { 108 108 return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() ); -
trunk/src/core/logger.cc
r395 r399 85 85 86 86 // log function 87 void logger::log( log_level level, const string_ ref& message )87 void logger::log( log_level level, const string_view& message ) 88 88 { 89 89 for ( auto& sink_info : m_log_sinks ) … … 141 141 142 142 // console logging 143 void log_console_sink::log( log_level level, const string_ ref& message )143 void log_console_sink::log( log_level level, const string_view& message ) 144 144 { 145 145 char stamp[16]; … … 177 177 178 178 // handle logging 179 void log_handle_sink::log( log_level level, const string_ ref& message )179 void log_handle_sink::log( log_level level, const string_view& message ) 180 180 { 181 181 char stamp[16]; … … 204 204 } 205 205 206 nv::log_file_sink::log_file_sink( const string_ ref& file_name, bool flush_always /*= true */ )206 nv::log_file_sink::log_file_sink( const string_view& file_name, bool flush_always /*= true */ ) 207 207 : log_handle_sink( nullptr, flush_always ) 208 208 { … … 257 257 } 258 258 259 string_ refnv::log_sink::level_name( log_level level ) const259 string_view nv::log_sink::level_name( log_level level ) const 260 260 { 261 261 return NV_LOG_LEVEL_NAME( level ); 262 262 } 263 263 264 string_ refnv::log_sink::padded_level_name( log_level level ) const265 { 266 return string_ ref( NV_LOG_LEVEL_NAME_PAD( level ), 8 );267 } 268 264 string_view nv::log_sink::padded_level_name( log_level level ) const 265 { 266 return string_view( NV_LOG_LEVEL_NAME_PAD( level ), 8 ); 267 } 268 -
trunk/src/core/profiler.cc
r395 r399 30 30 } 31 31 32 void profiler::start_profile( const string_ ref& tag )32 void profiler::start_profile( const string_view& tag ) 33 33 { 34 34 if ( tag != m_current->m_tag ) … … 47 47 } 48 48 49 profiler::node::node( const string_ ref& tag, node* parent )49 profiler::node::node( const string_view& tag, node* parent ) 50 50 : m_tag( tag.to_string() ) 51 51 , m_parent( parent ) … … 58 58 } 59 59 60 profiler::node* profiler::node::request_child( const string_ ref& tag )60 profiler::node* profiler::node::request_child( const string_view& tag ) 61 61 { 62 62 std::string stag( tag.to_string() ); … … 110 110 char buffer[128]; 111 111 snprintf( buffer, 128, "%-23s %6s %6s %9s %6s", "TAG", "%PARNT", "CALLS", "TOTAL(ms)", "AVG(ms)" ); 112 NV_LOG_INFO( string_ ref( buffer, nvstrlen( buffer ) ) );112 NV_LOG_INFO( string_view( buffer, nvstrlen( buffer ) ) ); 113 113 log_node_children( 0, m_root ); 114 114 NV_LOG_INFO( "-- PROFILER REPORT END ---------------------------------" ); … … 131 131 snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent, 132 132 c->m_tag.c_str(), pparent, calls, total_ms, avg_ms ); 133 NV_LOG_INFO( string_ ref( buffer, nvstrlen( buffer ) ) );133 NV_LOG_INFO( string_view( buffer, nvstrlen( buffer ) ) ); 134 134 if ( c->m_children.size() > 0 ) 135 135 { -
trunk/src/engine/program_manager.cc
r395 r399 37 37 } 38 38 39 nv::program program = m_context->get_device()->create_program( string_ ref( vsource ), string_ref( fsource ) );39 nv::program program = m_context->get_device()->create_program( string_view( vsource ), string_view( fsource ) ); 40 40 return add( program ); 41 41 } -
trunk/src/engine/resource_system.cc
r395 r399 12 12 { 13 13 m_lua = a_lua_state; 14 lua::register_storage( m_lua, get_storage_name(), string_ ref( "register_" + get_resource_name().to_string() ) );14 lua::register_storage( m_lua, get_storage_name(), string_view( "register_" + get_resource_name().to_string() ) ); 15 15 } 16 16 -
trunk/src/fmod/fmod_audio.cc
r395 r399 88 88 89 89 90 nv::sound fmod::audio::load_sound( const string_ ref& a_path )90 nv::sound fmod::audio::load_sound( const string_view& a_path ) 91 91 { 92 92 FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system; -
trunk/src/formats/assimp_loader.cc
r395 r399 237 237 aiMesh* mesh = scene->mMeshes[mc]; 238 238 239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_ ref( (char*)mesh->mName.data ) );239 NV_LOG_NOTICE( "Mesh #", mc, " - ", string_view( (char*)mesh->mName.data ) ); 240 240 NV_LOG_NOTICE( " bones - ", mesh->mNumBones ); 241 241 NV_LOG_NOTICE( " uvs - ", mesh->mNumUVComponents[0] ); -
trunk/src/formats/md3_loader.cc
r395 r399 284 284 } 285 285 286 nv::key_raw_channel* nv::md3_loader::load_tags( const string_ ref& tag )286 nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag ) 287 287 { 288 288 md3_t* md3 = (md3_t*)m_md3; … … 294 294 { 295 295 const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f]; 296 string_ refrname((char*)(rtag.name));296 string_view rname((char*)(rtag.name)); 297 297 if (rname == tag) 298 298 { … … 425 425 { 426 426 const md3_tag_t& rtag = md3->tags[i]; 427 string_ refname( (char*)(rtag.name) );427 string_view name( (char*)(rtag.name) ); 428 428 429 429 nodes[i].transform = mat4(); -
trunk/src/formats/md5_loader.cc
r398 r399 457 457 } 458 458 459 void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const const_array_ref<md5_joint_info>& joint_infos, const const_array_ref<transform>& base_frames, const const_array_ref<float>& frame_data )459 void md5_loader::build_frame_skeleton( mesh_node_data* nodes, uint32 index, const array_view<md5_joint_info>& joint_infos, const array_view<transform>& base_frames, const array_view<float>& frame_data ) 460 460 { 461 461 assert( m_type == ANIMATION ); -
trunk/src/formats/nmd_loader.cc
r395 r399 162 162 static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out ) 163 163 { 164 const_array_ref< mesh_raw_channel* > data = mesh->get_raw_channels();164 array_view< mesh_raw_channel* > data = mesh->get_raw_channels(); 165 165 166 166 uint32 size = sizeof( nmd_element_header ); -
trunk/src/gfx/texture_font.cc
r398 r399 92 92 } 93 93 94 bool texture_font::load_glyphs( string_ refcodes )94 bool texture_font::load_glyphs( string_view codes ) 95 95 { 96 96 FT_Face face = (FT_Face)(m_rface); -
trunk/src/gl/gl_device.cc
r398 r399 24 24 } 25 25 26 program gl_device::create_program( string_ ref vs_source, string_reffs_source )26 program gl_device::create_program( string_view vs_source, string_view fs_source ) 27 27 { 28 28 program result = m_programs.create(); … … 41 41 // this is a temporary function that will be removed once we find a way to 42 42 // pass binary file data around 43 image_data* gl_device::create_image_data( string_ reffilename )43 image_data* gl_device::create_image_data( string_view filename ) 44 44 { 45 45 load_sdl_image_library(); … … 264 264 } 265 265 266 bool nv::gl_device::compile( gl_program_info* p, string_ ref vertex_program, string_reffragment_program )266 bool nv::gl_device::compile( gl_program_info* p, string_view vertex_program, string_view fragment_program ) 267 267 { 268 268 if (!compile( GL_VERTEX_SHADER, vertex_program, p->glidv )) { return false; } … … 407 407 } 408 408 409 bool nv::gl_device::compile( uint32 sh_type, string_ refshader_code, unsigned& glid )409 bool nv::gl_device::compile( uint32 sh_type, string_view shader_code, unsigned& glid ) 410 410 { 411 411 glid = glCreateShader( sh_type ); -
trunk/src/lua/lua_nova.cc
r395 r399 810 810 } 811 811 812 void nv::lua::register_storage( state* a_state, string_ ref name, string_refconstructor_name )812 void nv::lua::register_storage( state* a_state, string_view name, string_view constructor_name ) 813 813 { 814 814 // TODO: error checking -
trunk/src/lua/lua_path.cc
r395 r399 14 14 { 15 15 if ( m_elements[0].length == 0 || m_elements[0].str == nullptr ) return; 16 string_ refspath( m_elements[0].str, m_elements[0].length );16 string_view spath( m_elements[0].str, m_elements[0].length ); 17 17 m_count = 0; 18 18 size_t point = spath.find( '.' ); 19 19 20 while ( point != string_ ref::npos )20 while ( point != string_view::npos ) 21 21 { 22 22 m_elements[m_count].str = spath.data(); … … 39 39 } 40 40 41 void nv::lua::path::push( string_ refp )41 void nv::lua::path::push( string_view p ) 42 42 { 43 43 m_elements[ m_count ].str = p.data(); -
trunk/src/lua/lua_state.cc
r395 r399 80 80 } 81 81 82 void lua::state_wrapper::register_native_function( lfunction f, string_ refname )82 void lua::state_wrapper::register_native_function( lfunction f, string_view name ) 83 83 { 84 84 if ( m_global ) push_global_table(); … … 171 171 } 172 172 173 bool lua::table_guard::has_field( string_ refelement )173 bool lua::table_guard::has_field( string_view element ) 174 174 { 175 175 lua_getfield( m_state, -1, element.data() ); … … 179 179 } 180 180 181 std::string lua::table_guard::get_std_string( string_ ref element, string_ref defval /*= string_ref() */ )181 std::string lua::table_guard::get_std_string( string_view element, string_view defval /*= string_view() */ ) 182 182 { 183 183 lua_getfield( m_state, -1, element.data() ); … … 198 198 } 199 199 200 const_string lua::table_guard::get_string( string_ ref element, string_ref defval /*= string_ref() */ )200 const_string lua::table_guard::get_string( string_view element, string_view defval /*= string_view() */ ) 201 201 { 202 202 lua_getfield( m_state, -1, element.data() ); … … 217 217 } 218 218 219 char lua::table_guard::get_char( string_ refelement, char defval /*= "" */ )219 char lua::table_guard::get_char( string_view element, char defval /*= "" */ ) 220 220 { 221 221 lua_getfield( m_state, -1, element.data() ); … … 225 225 } 226 226 227 int lua::table_guard::get_integer( string_ refelement, int defval /*= "" */ )227 int lua::table_guard::get_integer( string_view element, int defval /*= "" */ ) 228 228 { 229 229 lua_getfield( m_state, -1, element.data() ); … … 233 233 } 234 234 235 unsigned lua::table_guard::get_unsigned( string_ refelement, unsigned defval /*= "" */ )235 unsigned lua::table_guard::get_unsigned( string_view element, unsigned defval /*= "" */ ) 236 236 { 237 237 lua_getfield( m_state, -1, element.data() ); … … 241 241 } 242 242 243 double lua::table_guard::get_double( string_ refelement, double defval /*= "" */ )243 double lua::table_guard::get_double( string_view element, double defval /*= "" */ ) 244 244 { 245 245 lua_getfield( m_state, -1, element.data() ); … … 250 250 251 251 252 float nv::lua::table_guard::get_float( string_ refelement, float defval /*= 0.0 */ )252 float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ ) 253 253 { 254 254 lua_getfield( m_state, -1, element.data() ); … … 258 258 } 259 259 260 bool lua::table_guard::get_boolean( string_ refelement, bool defval /*= "" */ )260 bool lua::table_guard::get_boolean( string_view element, bool defval /*= "" */ ) 261 261 { 262 262 lua_getfield( m_state, -1, element.data() ); … … 266 266 } 267 267 268 bool nv::lua::table_guard::is_table( string_ refelement )268 bool nv::lua::table_guard::is_table( string_view element ) 269 269 { 270 270 lua_getfield( m_state, -1, element.data() ); … … 274 274 } 275 275 276 bool nv::lua::table_guard::is_number( string_ refelement )276 bool nv::lua::table_guard::is_number( string_view element ) 277 277 { 278 278 lua_getfield( m_state, -1, element.data() ); … … 282 282 } 283 283 284 bool nv::lua::table_guard::is_boolean( string_ refelement )284 bool nv::lua::table_guard::is_boolean( string_view element ) 285 285 { 286 286 lua_getfield( m_state, -1, element.data() ); … … 290 290 } 291 291 292 bool nv::lua::table_guard::is_string( string_ refelement )292 bool nv::lua::table_guard::is_string( string_view element ) 293 293 { 294 294 lua_getfield( m_state, -1, element.data() ); … … 350 350 } 351 351 352 int lua::state::load_string( string_ ref code, string_refname )352 int lua::state::load_string( string_view code, string_view name ) 353 353 { 354 354 NV_LOG_TRACE( "Loading Lua string '", name, "'"); … … 356 356 } 357 357 358 int lua::state::load_file( string_ reffilename )358 int lua::state::load_file( string_view filename ) 359 359 { 360 360 NV_LOG_NOTICE( "Loading Lua file '", filename, "'"); … … 362 362 } 363 363 364 bool lua::state::do_string( string_ ref code, string_refname, int rvalues )364 bool lua::state::do_string( string_view code, string_view name, int rvalues ) 365 365 { 366 366 lua::stack_guard( this ); … … 374 374 } 375 375 376 bool lua::state::do_file( string_ reffilename )376 bool lua::state::do_file( string_view filename ) 377 377 { 378 378 lua::stack_guard( this ); … … 386 386 } 387 387 388 int lua::state::do_current( string_ refname, int rvalues )388 int lua::state::do_current( string_view name, int rvalues ) 389 389 { 390 390 int result = lua_pcall(m_state, 0, rvalues, 0); … … 417 417 } 418 418 419 lua::ref lua::state::register_object( void* o, string_ reflua_name )419 lua::ref lua::state::register_object( void* o, string_view lua_name ) 420 420 { 421 421 if ( o == nullptr ) return lua::ref( lua::ref::none ); … … 430 430 } 431 431 432 lua::ref lua::state::register_proto( string_ ref id, string_refstorage )432 lua::ref lua::state::register_proto( string_view id, string_view storage ) 433 433 { 434 434 stack_guard guard( this ); … … 446 446 } 447 447 448 void lua::state::register_native_object_method( string_ ref lua_name, string_refname, lfunction f )448 void lua::state::register_native_object_method( string_view lua_name, string_view name, lfunction f ) 449 449 { 450 450 stack_guard guard( this ); … … 508 508 } 509 509 510 void nv::lua::state::store_metadata( ref object_index, string_ refmetaname, void* pointer )510 void nv::lua::state::store_metadata( ref object_index, string_view metaname, void* pointer ) 511 511 { 512 512 if ( !object_index.is_valid() ) return; … … 518 518 } 519 519 520 void nv::lua::state::register_enum( string_ refname, int value )520 void nv::lua::state::register_enum( string_view name, int value ) 521 521 { 522 522 lua_pushinteger( m_state, value ); … … 524 524 } 525 525 526 nv::lua::ref nv::lua::state::register_handle_component_impl( string_ refid, bool empty )526 nv::lua::ref nv::lua::state::register_handle_component_impl( string_view id, bool empty ) 527 527 { 528 528 int args = empty ? 1 : 2; … … 547 547 } 548 548 549 void nv::lua::state::unregister_handle_component_impl( string_ refid )549 void nv::lua::state::unregister_handle_component_impl( string_view id ) 550 550 { 551 551 NV_LUA_STACK_ASSERT( m_state, -1 ); … … 562 562 } 563 563 564 void nv::lua::state::register_singleton( string_ refname, void* o )564 void nv::lua::state::register_singleton( string_view name, void* o ) 565 565 { 566 566 if ( o == nullptr ) return; -
trunk/src/lua/lua_values.cc
r395 r399 75 75 } 76 76 77 void nv::lua::detail::push_string_ ref( lua_State *L, string_refs )77 void nv::lua::detail::push_string_view( lua_State *L, string_view s ) 78 78 { 79 79 lua_pushlstring( L, s.data(), s.size() ); … … 123 123 } 124 124 125 nv::string_ ref nv::lua::detail::to_string_ref( lua_State *L, int index )125 nv::string_view nv::lua::detail::to_string_view( lua_State *L, int index ) 126 126 { 127 127 size_t length = 0; 128 128 const char* result = lua_tolstring( L, index, &length ); 129 return string_ ref( result, length );129 return string_view( result, length ); 130 130 } 131 131 -
trunk/src/sdl/sdl_audio.cc
r397 r399 85 85 } 86 86 87 nv::sound nv::sdl::audio::load_sound( const string_ ref& a_path )87 nv::sound nv::sdl::audio::load_sound( const string_view& a_path ) 88 88 { 89 89 // TODO: this is a really weird error - if we remove this check, all hell gets loose
Note: See TracChangeset
for help on using the changeset viewer.