Changeset 399 for trunk


Ignore:
Timestamp:
06/13/15 11:47:09 (10 years ago)
Author:
epyon
Message:
  • naming cleanup
  • string_ref -> string_view (compatible with C++17 standard!)
  • *_ref and const_*_ref, renamed to _ref and _view for consistency
Location:
trunk
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/library.hh

    r395 r399  
    3939                 * Throws library_error on failure
    4040                 */
    41                 void open( string_ref name );
     41                void open( string_view name );
    4242
    4343                /**
     
    4646                 * returns true if succeeded, false otherwise
    4747                 */
    48                 bool try_open( string_ref name );
     48                bool try_open( string_view name );
    4949
    5050                /**
     
    5656                 * Returns library name
    5757                 */
    58                 string_ref get_name() const;
     58                string_view get_name() const;
    5959
    6060                /**
     
    6363                 * Throws on symbol not found
    6464                 */
    65                 void* get( string_ref symbol );
     65                void* get( string_view symbol );
    6666
    6767                /**
     
    7070                 * Returns null if symbol not found
    7171                 */
    72                 void* try_get( string_ref symbol );
     72                void* try_get( string_view symbol );
    7373
    7474                /**
  • trunk/nv/core/logger.hh

    r395 r399  
    3434                 * @param message message to be logged.
    3535                 */
    36                 virtual void log( log_level level, const string_ref& message ) = 0;
     36                virtual void log( log_level level, const string_view& message ) = 0;
    3737                /**
    3838                 * Enforcement of virtual destructor.
     
    4747                * Log level name (unpadded)
    4848                */
    49                 string_ref level_name( log_level level ) const;
     49                string_view level_name( log_level level ) const;
    5050                /**
    5151                * Log level name (padded)
    5252                */
    53                 string_ref padded_level_name( log_level level ) const;
     53                string_view padded_level_name( log_level level ) const;
    5454        };
    5555
     
    8686                 * @param message message to be logged.
    8787                 */
    88                 virtual void log( log_level level, const string_ref& message );
     88                virtual void log( log_level level, const string_view& message );
    8989
    9090                /**
     
    144144                 * Logging function.
    145145                 */
    146                 virtual void log( log_level level, const string_ref& message );
     146                virtual void log( log_level level, const string_view& message );
    147147
    148148        private:
     
    176176                 * Logging function.
    177177                 */
    178                 virtual void log( log_level level, const string_ref& message );
     178                virtual void log( log_level level, const string_view& message );
    179179
    180180        protected:
     
    201201                * @param flush_always if set to false, wont flush after each line.
    202202                */
    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 );
    204204
    205205                /**
  • trunk/nv/core/logging.hh

    r396 r399  
    5050                        m_level = level;
    5151                }
    52                 virtual void log( log_level level, const string_ref& message ) = 0;
    53                 void log_append( string_ref ref )
     52                virtual void log( log_level level, const string_view& message ) = 0;
     53                void log_append( string_view ref )
    5454                {
    5555                        nvmemcpy( m_pos, ref.data(), ref.size() );
     
    8484                {
    8585                        *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 ) ) );
    8787                        m_pos = m_message;
    8888                }
  • trunk/nv/core/profiler.hh

    r395 r399  
    4444                        }
    4545                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 );
    4848                        void start();
    4949                        bool stop();
     
    6666                ~profiler();
    6767
    68                 void start_profile( const string_ref& tag );
     68                void start_profile( const string_view& tag );
    6969                void stop_profile();
    7070        public:
     
    8282        {
    8383        public:
    84                 profiler_guard( string_ref tag )
     84                profiler_guard( string_view tag )
    8585                {
    8686                        profiler::pointer()->start_profile( tag );
     
    9696        {
    9797        public:
    98                 profiler_condition_guard( string_ref tag, bool condition )
     98                profiler_condition_guard( string_view tag, bool condition )
    9999                        : m_active( condition )
    100100                {
  • trunk/nv/engine/program_manager.hh

    r395 r399  
    2424        public:
    2525                program_manager( context* a_context );
    26                 virtual string_ref get_storage_name() const { return "programs"; }
    27                 virtual string_ref get_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"; }
    2828        protected:
    2929                virtual resource_id load_resource( lua::table_guard& table );
  • trunk/nv/engine/resource_system.hh

    r395 r399  
    3333                resource_manager_base() : m_lua( nullptr ) {}
    3434                void initialize( lua::state* state );
    35                 virtual string_ref get_storage_name() const = 0;
    36                 virtual string_ref get_resource_name() const = 0;
     35                virtual string_view get_storage_name() const = 0;
     36                virtual string_view get_resource_name() const = 0;
    3737                virtual void clear() { m_names.clear(); }
    3838                void load_all();
  • trunk/nv/fmod/fmod_audio.hh

    r395 r399  
    3535                        virtual channel play_sound( sound a_sound, float volume = 1.0f, float pan = 0.0f );
    3636                        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 );
    3838                        virtual void release( sound a_sound );
    3939                        virtual void set_orientation( vec3 forward, vec3 up );
  • trunk/nv/formats/md3_loader.hh

    r395 r399  
    4141        private:
    4242                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 );
    4444                bool m_merge_all;
    4545                void* m_md3;
  • trunk/nv/formats/md5_loader.hh

    r398 r399  
    8383        protected:
    8484                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 );
    8686                bool prepare_mesh( mesh_node_data* nodes, uint32 vtx_count, mesh_data* mdata, md5_weight* weights, md5_weight_info* weight_info );
    8787        protected:
  • trunk/nv/gfx/texture_font.hh

    r395 r399  
    4545                        texture_font( texture_atlas* atlas, const char * filename, float size );
    4646                        const texture_glyph* get_glyph( uint16 charcode ) const;
    47                         bool load_glyphs( string_ref codes );
     47                        bool load_glyphs( string_view codes );
    4848                        float get_size() const { return m_size; }
    4949                        ~texture_font();
  • trunk/nv/gl/gl_device.hh

    r395 r399  
    4141
    4242                gl_device();
    43                 virtual image_data* create_image_data( string_ref filename ); // temporary
     43                virtual image_data* create_image_data( string_view filename ); // temporary
    4444                virtual image_data* create_image_data( const uint8* data, uint32 size ); // temporary
    4545
    46                 virtual program create_program( string_ref vs_source, string_ref fs_source );
     46                virtual program create_program( string_view vs_source, string_view fs_source );
    4747                virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr );
    4848                virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr );
     
    6363       
    6464        private:
    65                 bool compile( gl_program_info* p, string_ref vertex_program, string_ref fragment_program );
    66                 bool compile( uint32 sh_type, string_ref shader_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 );
    6767                void update_uniforms( gl_program_info* p );
    6868                void load_attributes( gl_program_info* p );
  • trunk/nv/interface/audio.hh

    r395 r399  
    3333                virtual channel play_sound( sound a_sound, vec3 position ) = 0;
    3434                // 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;
    3636                virtual void release( sound a_sound ) = 0;
    3737                virtual void set_orientation( vec3 forward, vec3 up ) = 0;
  • trunk/nv/interface/context.hh

    r395 r399  
    300300                {
    301301                        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();
    303303                        for ( uint32 ch = 0; ch < channels.size(); ++ch )
    304304                        {
  • trunk/nv/interface/device.hh

    r395 r399  
    157157                        initialize_engine_uniforms();
    158158                }
    159                 virtual program create_program( string_ref vs_source, string_ref fs_source ) = 0;
     159                virtual program create_program( string_view vs_source, string_view fs_source ) = 0;
    160160                virtual buffer create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source = nullptr ) = 0;
    161161                virtual texture create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data = nullptr ) = 0;
    162162                // TODO: remove?
    163163                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_ref filename ) = 0; // temporary
     164                virtual image_data* create_image_data( string_view filename ) = 0; // temporary
    165165                virtual image_data* create_image_data( const uint8* data, uint32 size ) = 0; // temporary
    166166                virtual void release( texture ) = 0;
     
    205205
    206206                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 )
    208208                {
    209209                        set_uniform_array( p, name, (const T*)value.data(), value.size(), false );
  • trunk/nv/interface/mesh_data.hh

    r395 r399  
    106106                }
    107107
    108                 const_array_ref< mesh_raw_channel* > get_raw_channels()  const { return m_channels; }
    109                 const mesh_raw_channel*              get_index_channel() const { return m_index_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; }
    110110                size_t get_channel_count() const { return m_channels.size(); }
    111111                const mesh_raw_channel* get_channel( size_t index ) const
  • trunk/nv/interface/uniform.hh

    r395 r399  
    152152        typedef nv::vector< engine_uniform_base* >                        engine_uniform_list;
    153153        // 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;
    156156
    157157        class engine_uniform_m_view : public engine_uniform< mat4 >
  • trunk/nv/lua/lua_nova.hh

    r395 r399  
    1414        namespace lua
    1515        {
    16                 void register_storage( state* a_state, string_ref name, string_ref constructor_name );
     16                void register_storage( state* a_state, string_view name, string_view constructor_name );
    1717                void register_nova( state* a_state );
    1818        }
  • trunk/nv/lua/lua_path.hh

    r396 r399  
    5555                        void parse();
    5656                        void push( uint32 value );
    57                         void push( string_ref p );
     57                        void push( string_view p );
    5858
    5959                private:
  • trunk/nv/lua/lua_state.hh

    r395 r399  
    129129                        }
    130130                        bool is_defined( const path& p ) { return is_defined( p, m_global ); }
    131                         void register_native_function( lfunction f, string_ref name );
     131                        void register_native_function( lfunction f, string_view name );
    132132
    133133                        template < typename F, F f >
    134                         void register_function( string_ref name )
     134                        void register_function( string_view name )
    135135                        {
    136136                                register_native_function( detail::function_wrapper< F, f >, name );
     
    138138
    139139                        template < typename C, typename F, F f >
    140                         void register_function( string_ref name )
     140                        void register_function( string_view name )
    141141                        {
    142142                                register_native_function( detail::object_method_wrapper< C, F, f >, name );
     
    192192                        explicit state( bool load_libs = false );
    193193                        explicit state( lua_State* state );
    194                         bool do_string( string_ref code, string_ref name, int rvalues = 0 );
    195                         bool do_file( string_ref filename );
     194                        bool do_string( string_view code, string_view name, int rvalues = 0 );
     195                        bool do_file( string_view filename );
    196196                        int get_stack_size();
    197197                        void log_stack();
    198198                        lua_State* get_raw();
    199                         ref register_object( void* o, string_ref lua_name );
    200                         ref register_proto( string_ref id, string_ref storage );
    201                         void store_metadata( ref object_index, string_ref metaname, 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 );
    202202                        void unregister_object( ref object_index );
    203203
    204                         void register_enum( string_ref name, int value );
    205                         void register_singleton( string_ref name, void* o );
    206 
    207                         void register_native_object_method( string_ref lua_name, string_ref name, 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 );
    208208                        template < typename F, F f >
    209                         void register_object_method( string_ref lua_name, string_ref name )
     209                        void register_object_method( string_view lua_name, string_view name )
    210210                        {
    211211                                register_native_object_method( lua_name, name, detail::object_method_wrapper< typename memfn_class_type<F>::type, F, f > );
     
    224224                        }
    225225                        template < typename H >
    226                         ref register_handle_component( const H& handle, string_ref id )
     226                        ref register_handle_component( const H& handle, string_view id )
    227227                        {
    228228                                nv::lua::push_handle( m_state, handle );
     
    230230                        }
    231231                        template < typename H >
    232                         ref register_handle_component( const H& handle, string_ref id, const path& proto )
     232                        ref register_handle_component( const H& handle, string_view id, const path& proto )
    233233                        {
    234234                                if ( !proto.resolve( m_state, true ) )
     
    240240                        }
    241241                        template < typename H >
    242                         void unregister_handle_component( const H& handle, string_ref id )
     242                        void unregister_handle_component( const H& handle, string_view id )
    243243                        {
    244244                                nv::lua::push_handle( m_state, handle );
     
    277277
    278278                private:
    279                         ref register_handle_component_impl( string_ref id, bool empty );
    280                         void unregister_handle_component_impl( string_ref id );
    281 
    282                         int load_string( string_ref code, string_ref name );
    283                         int load_file( string_ref filename );
    284                         int do_current( string_ref name, 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 );
    285285                        void deep_pointer_copy( int index, void* obj );
    286286                };
     
    293293                        virtual ~table_guard();
    294294                        size_t get_size();
    295                         bool has_field( string_ref element );
    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_ref element, char defval = ' ' );
    299                         int get_integer( string_ref element, int defval = 0 );
    300                         unsigned get_unsigned( string_ref element, unsigned defval = 0 );
    301                         double get_double( string_ref element, double defval = 0.0 );
    302                         float get_float( string_ref element, float defval = 0.0 );
    303                         bool get_boolean( string_ref element, bool defval = false );
    304                         bool is_table( string_ref element );
    305                         bool is_number( string_ref element );
    306                         bool is_boolean( string_ref element );
    307                         bool is_string( string_ref element );
     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 );
    308308                private:
    309309                        int m_level;
  • trunk/nv/lua/lua_values.hh

    r395 r399  
    7474                        void push_bool       ( lua_State *L, bool v );
    7575                        void push_string     ( lua_State *L, const std::string& s );
    76                         void push_string_ref ( lua_State *L, string_ref s );
     76                        void push_string_view( lua_State *L, string_view s );
    7777                        void push_cstring    ( lua_State *L, const char* s );
    7878                        void push_pointer    ( lua_State *L, void* p );
     
    8585                        std::string to_string     ( lua_State *L, int index );
    8686                        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 );
    8888                        void*       to_pointer    ( lua_State *L, int index );
    8989                        void*       to_ref_object ( lua_State *L, int index );
     
    9595                        std::string to_string     ( lua_State *L, int index, const std::string& def );
    9696                        const char* to_cstring    ( lua_State *L, int index, const char* def );
    97                         string_ref  to_string_ref ( lua_State *L, int index, string_ref def );
     97                        string_view to_string_view( lua_State *L, int index, string_view def );
    9898                        void*       to_pointer    ( lua_State *L, int index, void* def );
    9999                        void*       to_ref_object ( lua_State *L, int index, void* def );
     
    159159
    160160                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 ); }
    166166                };
    167167
  • trunk/nv/sdl/sdl_audio.hh

    r395 r399  
    3333                        virtual channel play_sound( sound a_sound, float volume = 1.0f, float pan = 0.0f );
    3434                        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 );
    3636                        virtual void release( sound a_sound );
    3737                        virtual void set_orientation( vec3 forward, vec3 up );
  • trunk/nv/stl/container/contiguous_storage_policy.hh

    r395 r399  
    4545
    4646                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() ); }
    4848
    4949                // allow move
     
    7272
    7373                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() ); }
    7575        protected:
    7676                constexpr resizable_storage() : m_size( 0 ) {}
     
    141141
    142142                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() ); }
    144144        protected:
    145145                constexpr growable_storage() : m_size( 0 ), m_capacity( 0 ) {}
  • trunk/nv/stl/memory.hh

    r396 r399  
    3434
    3535        template< typename T >
    36         class storage_view
     36        class storage_ref
    3737        {
    3838        public:
     
    4343                static constexpr bool is_const    = false;
    4444
    45                 constexpr storage_view()
     45                constexpr storage_ref()
    4646                        : 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 )
    4848                        : m_data( a_data ), m_size( a_size ) {}
    4949
     
    6767
    6868        template< typename T >
    69         class const_storage_view
     69        class storage_view
    7070        {
    7171        public:
     
    7676                static constexpr bool is_const    = true;
    7777
    78                 constexpr const_storage_view()
     78                constexpr storage_view()
    7979                        : 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 )
    8181                        : 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 )
    8383                        : m_data( view.data() ), m_size( view.size() ) {}
    8484
     
    474474
    475475        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 >;
    480480        using mem_ref       = array_ref< char >;
    481481
  • trunk/nv/stl/string.hh

    r395 r399  
    7777        };
    7878       
    79         class string_ref;
     79        class string_view;
    8080
    8181        // 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;
    8585        public:
    8686                typedef char           value_type;
     
    197197
    198198                // string operations
    199                 string_ref substr( size_type p, size_type n = npos ) const;
     199                string_view substr( size_type p, size_type n = npos ) const;
    200200
    201201                inline size_t hash() const
     
    245245
    246246
    247         class string_ref : public string_base
     247        class string_view : public string_base
    248248        {
    249249        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 )
    252252                        : string_base( rhs.data(), rhs.size() )
    253253                {
    254254                }
    255                 inline string_ref( const string_base& rhs )
     255                inline string_view( const string_base& rhs )
    256256                        : string_base( rhs.data(), rhs.size() )
    257257                {
    258258                }
    259259
    260                 inline string_ref( const std::string& str )
     260                inline string_view( const std::string& str )
    261261                        : string_base( str.data(), str.size() )
    262262                {
    263263                }
    264264
    265                 inline string_ref( const char* str, size_type len )
     265                inline string_view( const char* str, size_type len )
    266266                        : string_base( str, len )
    267267                {
     
    270270                // Literal constructors
    271271                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 ) {}
    275275
    276276                // Non-literal constructors
    277277                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 ) ) {}
    279279
    280280                // Non-literal constructors
    281281                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 )
    285285                {
    286286                        assign( rhs.data(), rhs.size() );
     
    309309
    310310        template< typename H >
    311         struct hash< string_ref, H > : hash< string_base, H >{};
     311        struct hash< string_view, H > : hash< string_base, H >{};
    312312
    313313        // const string is movable but not copyable
     
    364364        };
    365365
    366         inline string_ref string_base::substr( size_type p, size_type n ) const
    367         {
    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" ) );
    369369                if ( n == p || p + n > size() ) n = size() - p;
    370                 return string_ref( data() + p, n );
     370                return string_view( data() + p, n );
    371371        }
    372372
     
    374374inline bool operator OPERATOR ( const string_base& lhs, const std::string& rhs )\
    375375{\
    376         return lhs OPERATOR string_ref( rhs );\
     376        return lhs OPERATOR string_view( rhs );\
    377377}\
    378378inline bool operator OPERATOR ( const std::string& lhs, const string_base& rhs )\
    379379{\
    380         return string_ref( lhs ) OPERATOR rhs;\
     380        return string_view( lhs ) OPERATOR rhs;\
    381381}\
    382382inline bool operator OPERATOR ( const string_base& lhs, const char* rhs )\
    383383{\
    384         return lhs OPERATOR string_ref( rhs );\
     384        return lhs OPERATOR string_view( rhs );\
    385385}\
    386386inline bool operator OPERATOR ( const char* lhs, const string_base& rhs )\
    387387{\
    388         return string_ref( lhs ) OPERATOR rhs;\
     388        return string_view( lhs ) OPERATOR rhs;\
    389389}\
    390390
     
    432432size_t f64_to_buffer( f64 n, char* str );
    433433
    434 inline string_ref trimmed( const string_ref& str )
     434inline string_view trimmed( const string_view& str )
    435435{
    436436        size_t endpos = str.find_last_not_of( " \r\n\t" );
    437437        size_t startpos = str.find_first_not_of( " \r\n\t" );
    438438
    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;
    443443                return str.substr( startpos, endpos );
    444444        }
     
    446446}
    447447
    448 inline string_ref rtrimmed( const string_ref& str )
     448inline string_view rtrimmed( const string_view& str )
    449449{
    450450        size_t endpos = str.find_last_not_of( " \r\n\t" );
    451         if ( string_ref::npos != endpos )
     451        if ( string_view::npos != endpos )
    452452        {
    453453                return str.substr( 0, endpos + 1 );
     
    456456}
    457457
    458 inline string_ref ltrimmed( const string_ref& str )
     458inline string_view ltrimmed( const string_view& str )
    459459{
    460460        size_t startpos = str.find_first_not_of( " \r\n\t" );
    461         if ( string_ref::npos != startpos )
     461        if ( string_view::npos != startpos )
    462462        {
    463463                return str.substr( startpos );
     
    467467
    468468
    469 inline string_ref extract_extension( string_ref filename )
     469inline string_view extract_extension( string_view filename )
    470470{
    471471        size_t lastdot = filename.find_last_of( '.' );
    472         if ( string_ref::npos != lastdot )
     472        if ( string_view::npos != lastdot )
    473473                return filename.substr( lastdot + 1 );
    474474        return filename;
  • trunk/src/core/library.cc

    r395 r399  
    4141}
    4242
    43 void library::open( string_ref name )
     43void library::open( string_view name )
    4444{
    4545        m_name.assign( name.data(), name.size() );
     
    5151}
    5252
    53 bool nv::library::try_open( string_ref name )
     53bool nv::library::try_open( string_view name )
    5454{
    5555        m_name.assign( name.data(), name.size() );
     
    6262}
    6363
    64 string_ref library::get_name() const
     64string_view library::get_name() const
    6565{
    66     return string_ref( m_name );
     66    return string_view( m_name );
    6767}
    6868
     
    7676
    7777        std::string name = m_name;
    78         string_ref ext( NV_LIB_EXT );
     78        string_view ext( NV_LIB_EXT );
    7979
    8080        if ( name.length() < ext.length() || name.substr( name.length() - ext.length(), ext.length() ) != ext )
     
    9494}
    9595
    96 void* library::get( string_ref symbol )
     96void* library::get( string_view symbol )
    9797{
    9898        void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
     
    104104}
    105105
    106 void* nv::library::try_get( string_ref symbol )
     106void* nv::library::try_get( string_view symbol )
    107107{
    108108        return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
  • trunk/src/core/logger.cc

    r395 r399  
    8585
    8686// log function
    87 void logger::log( log_level level, const string_ref& message )
     87void logger::log( log_level level, const string_view& message )
    8888{
    8989        for ( auto& sink_info : m_log_sinks )
     
    141141
    142142// console logging
    143 void log_console_sink::log( log_level level, const string_ref& message )
     143void log_console_sink::log( log_level level, const string_view& message )
    144144{
    145145        char stamp[16];
     
    177177
    178178// handle logging
    179 void log_handle_sink::log( log_level level, const string_ref& message )
     179void log_handle_sink::log( log_level level, const string_view& message )
    180180{
    181181        char stamp[16];
     
    204204}
    205205
    206 nv::log_file_sink::log_file_sink( const string_ref& file_name, bool flush_always /*= true */ )
     206nv::log_file_sink::log_file_sink( const string_view& file_name, bool flush_always /*= true */ )
    207207        : log_handle_sink( nullptr, flush_always )
    208208{
     
    257257}
    258258
    259 string_ref nv::log_sink::level_name( log_level level ) const
     259string_view nv::log_sink::level_name( log_level level ) const
    260260{
    261261        return NV_LOG_LEVEL_NAME( level );
    262262}
    263263
    264 string_ref nv::log_sink::padded_level_name( log_level level ) const
    265 {
    266         return string_ref( NV_LOG_LEVEL_NAME_PAD( level ), 8 );
    267 }
    268 
     264string_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  
    3030}
    3131
    32 void profiler::start_profile( const string_ref& tag )
     32void profiler::start_profile( const string_view& tag )
    3333{
    3434        if ( tag != m_current->m_tag )
     
    4747}
    4848
    49 profiler::node::node( const string_ref& tag, node* parent )
     49profiler::node::node( const string_view& tag, node* parent )
    5050        : m_tag( tag.to_string() )
    5151        , m_parent( parent )
     
    5858}
    5959
    60 profiler::node* profiler::node::request_child( const string_ref& tag )
     60profiler::node* profiler::node::request_child( const string_view& tag )
    6161{
    6262        std::string stag( tag.to_string() );
     
    110110        char buffer[128];
    111111        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 ) ) );
    113113        log_node_children( 0, m_root );
    114114        NV_LOG_INFO( "-- PROFILER REPORT END ---------------------------------" );
     
    131131                        snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent,
    132132                                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 ) ) );
    134134                        if ( c->m_children.size() > 0 )
    135135                        {
  • trunk/src/engine/program_manager.cc

    r395 r399  
    3737        }
    3838
    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 ) );
    4040        return add( program );
    4141}
  • trunk/src/engine/resource_system.cc

    r395 r399  
    1212{
    1313        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() ) );
    1515}
    1616
  • trunk/src/fmod/fmod_audio.cc

    r395 r399  
    8888
    8989
    90 nv::sound fmod::audio::load_sound( const string_ref& a_path )
     90nv::sound fmod::audio::load_sound( const string_view& a_path )
    9191{
    9292        FMOD_SYSTEM* system = (FMOD_SYSTEM*)m_system;
  • trunk/src/formats/assimp_loader.cc

    r395 r399  
    237237                        aiMesh* mesh = scene->mMeshes[mc];
    238238
    239                         NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_ref( (char*)mesh->mName.data ) );
     239                        NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_view( (char*)mesh->mName.data ) );
    240240                        NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
    241241                        NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
  • trunk/src/formats/md3_loader.cc

    r395 r399  
    284284}
    285285
    286 nv::key_raw_channel* nv::md3_loader::load_tags( const string_ref& tag )
     286nv::key_raw_channel* nv::md3_loader::load_tags( const string_view& tag )
    287287{
    288288        md3_t* md3 = (md3_t*)m_md3;
     
    294294                {
    295295                        const md3_tag_t& rtag = md3->tags[i + md3->header.num_tags * f];
    296                         string_ref rname((char*)(rtag.name));
     296                        string_view rname((char*)(rtag.name));
    297297                        if (rname == tag)
    298298                        {
     
    425425        {
    426426                const md3_tag_t& rtag = md3->tags[i];
    427                 string_ref name( (char*)(rtag.name) );
     427                string_view name( (char*)(rtag.name) );
    428428
    429429                nodes[i].transform = mat4();
  • trunk/src/formats/md5_loader.cc

    r398 r399  
    457457}
    458458
    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 )
     459void 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 )
    460460{
    461461        assert( m_type == ANIMATION );
  • trunk/src/formats/nmd_loader.cc

    r395 r399  
    162162static void nmd_dump_mesh( const mesh_data* mesh, stream& stream_out )
    163163{
    164         const_array_ref< mesh_raw_channel* > data  = mesh->get_raw_channels();
     164        array_view< mesh_raw_channel* > data  = mesh->get_raw_channels();
    165165
    166166        uint32 size = sizeof( nmd_element_header );
  • trunk/src/gfx/texture_font.cc

    r398 r399  
    9292}
    9393
    94 bool texture_font::load_glyphs( string_ref codes )
     94bool texture_font::load_glyphs( string_view codes )
    9595{
    9696        FT_Face face = (FT_Face)(m_rface);
  • trunk/src/gl/gl_device.cc

    r398 r399  
    2424}
    2525
    26 program gl_device::create_program( string_ref vs_source, string_ref fs_source )
     26program gl_device::create_program( string_view vs_source, string_view fs_source )
    2727{
    2828        program result = m_programs.create();
     
    4141// this is a temporary function that will be removed once we find a way to
    4242// pass binary file data around
    43 image_data* gl_device::create_image_data( string_ref filename )
     43image_data* gl_device::create_image_data( string_view filename )
    4444{
    4545        load_sdl_image_library();
     
    264264}
    265265
    266 bool nv::gl_device::compile( gl_program_info* p, string_ref vertex_program, string_ref fragment_program )
     266bool nv::gl_device::compile( gl_program_info* p, string_view vertex_program, string_view fragment_program )
    267267{
    268268        if (!compile( GL_VERTEX_SHADER,   vertex_program, p->glidv ))   { return false; }
     
    407407}
    408408
    409 bool nv::gl_device::compile( uint32 sh_type, string_ref shader_code, unsigned& glid )
     409bool nv::gl_device::compile( uint32 sh_type, string_view shader_code, unsigned& glid )
    410410{
    411411        glid = glCreateShader( sh_type );
  • trunk/src/lua/lua_nova.cc

    r395 r399  
    810810}
    811811
    812 void nv::lua::register_storage( state* a_state, string_ref name, string_ref constructor_name )
     812void nv::lua::register_storage( state* a_state, string_view name, string_view constructor_name )
    813813{
    814814        // TODO: error checking
  • trunk/src/lua/lua_path.cc

    r395 r399  
    1414{
    1515        if ( m_elements[0].length == 0 || m_elements[0].str == nullptr ) return;
    16         string_ref spath( m_elements[0].str, m_elements[0].length );
     16        string_view spath( m_elements[0].str, m_elements[0].length );
    1717        m_count = 0;
    1818        size_t point = spath.find( '.' );
    1919
    20         while ( point != string_ref::npos )
     20        while ( point != string_view::npos )
    2121        {
    2222                m_elements[m_count].str    = spath.data();
     
    3939}
    4040
    41 void nv::lua::path::push( string_ref p )
     41void nv::lua::path::push( string_view p )
    4242{
    4343        m_elements[ m_count ].str    = p.data();
  • trunk/src/lua/lua_state.cc

    r395 r399  
    8080}
    8181
    82 void lua::state_wrapper::register_native_function( lfunction f, string_ref name )
     82void lua::state_wrapper::register_native_function( lfunction f, string_view name )
    8383{
    8484        if ( m_global ) push_global_table();
     
    171171}
    172172
    173 bool lua::table_guard::has_field( string_ref element )
     173bool lua::table_guard::has_field( string_view element )
    174174{
    175175        lua_getfield( m_state, -1, element.data() );
     
    179179}
    180180
    181 std::string lua::table_guard::get_std_string( string_ref element, string_ref defval /*= string_ref() */ )
     181std::string lua::table_guard::get_std_string( string_view element, string_view defval /*= string_view() */ )
    182182{
    183183        lua_getfield( m_state, -1, element.data() );
     
    198198}
    199199
    200 const_string lua::table_guard::get_string( string_ref element, string_ref defval /*= string_ref() */ )
     200const_string lua::table_guard::get_string( string_view element, string_view defval /*= string_view() */ )
    201201{
    202202        lua_getfield( m_state, -1, element.data() );
     
    217217}
    218218
    219 char lua::table_guard::get_char( string_ref element, char defval /*= "" */ )
     219char lua::table_guard::get_char( string_view element, char defval /*= "" */ )
    220220{
    221221        lua_getfield( m_state, -1, element.data() );
     
    225225}
    226226
    227 int lua::table_guard::get_integer( string_ref element, int defval /*= "" */ )
     227int lua::table_guard::get_integer( string_view element, int defval /*= "" */ )
    228228{
    229229        lua_getfield( m_state, -1, element.data() );
     
    233233}
    234234
    235 unsigned lua::table_guard::get_unsigned( string_ref element, unsigned defval /*= "" */ )
     235unsigned lua::table_guard::get_unsigned( string_view element, unsigned defval /*= "" */ )
    236236{
    237237        lua_getfield( m_state, -1, element.data() );
     
    241241}
    242242
    243 double lua::table_guard::get_double( string_ref element, double defval /*= "" */ )
     243double lua::table_guard::get_double( string_view element, double defval /*= "" */ )
    244244{
    245245        lua_getfield( m_state, -1, element.data() );
     
    250250
    251251
    252 float nv::lua::table_guard::get_float( string_ref element, float defval /*= 0.0 */ )
     252float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ )
    253253{
    254254        lua_getfield( m_state, -1, element.data() );
     
    258258}
    259259
    260 bool lua::table_guard::get_boolean( string_ref element, bool defval /*= "" */ )
     260bool lua::table_guard::get_boolean( string_view element, bool defval /*= "" */ )
    261261{
    262262        lua_getfield( m_state, -1, element.data() );
     
    266266}
    267267
    268 bool nv::lua::table_guard::is_table( string_ref element )
     268bool nv::lua::table_guard::is_table( string_view element )
    269269{
    270270        lua_getfield( m_state, -1, element.data() );
     
    274274}
    275275
    276 bool nv::lua::table_guard::is_number( string_ref element )
     276bool nv::lua::table_guard::is_number( string_view element )
    277277{
    278278        lua_getfield( m_state, -1, element.data() );
     
    282282}
    283283
    284 bool nv::lua::table_guard::is_boolean( string_ref element )
     284bool nv::lua::table_guard::is_boolean( string_view element )
    285285{
    286286        lua_getfield( m_state, -1, element.data() );
     
    290290}
    291291
    292 bool nv::lua::table_guard::is_string( string_ref element )
     292bool nv::lua::table_guard::is_string( string_view element )
    293293{
    294294        lua_getfield( m_state, -1, element.data() );
     
    350350}
    351351
    352 int lua::state::load_string( string_ref code, string_ref name )
     352int lua::state::load_string( string_view code, string_view name )
    353353{
    354354        NV_LOG_TRACE( "Loading Lua string '", name, "'");
     
    356356}
    357357
    358 int lua::state::load_file( string_ref filename )
     358int lua::state::load_file( string_view filename )
    359359{
    360360        NV_LOG_NOTICE( "Loading Lua file '", filename, "'");
     
    362362}
    363363
    364 bool lua::state::do_string( string_ref code, string_ref name, int rvalues )
     364bool lua::state::do_string( string_view code, string_view name, int rvalues )
    365365{
    366366        lua::stack_guard( this );
     
    374374}
    375375
    376 bool lua::state::do_file( string_ref filename )
     376bool lua::state::do_file( string_view filename )
    377377{
    378378        lua::stack_guard( this );
     
    386386}
    387387
    388 int lua::state::do_current( string_ref name, int rvalues )
     388int lua::state::do_current( string_view name, int rvalues )
    389389{
    390390        int result = lua_pcall(m_state, 0, rvalues, 0);
     
    417417}
    418418
    419 lua::ref lua::state::register_object( void* o, string_ref lua_name )
     419lua::ref lua::state::register_object( void* o, string_view lua_name )
    420420{
    421421        if ( o == nullptr ) return lua::ref( lua::ref::none );
     
    430430}
    431431
    432 lua::ref lua::state::register_proto( string_ref id, string_ref storage )
     432lua::ref lua::state::register_proto( string_view id, string_view storage )
    433433{
    434434        stack_guard guard( this );
     
    446446}
    447447
    448 void lua::state::register_native_object_method( string_ref lua_name, string_ref name, lfunction f )
     448void lua::state::register_native_object_method( string_view lua_name, string_view name, lfunction f )
    449449{
    450450        stack_guard guard( this );
     
    508508}
    509509
    510 void nv::lua::state::store_metadata( ref object_index, string_ref metaname, void* pointer )
     510void nv::lua::state::store_metadata( ref object_index, string_view metaname, void* pointer )
    511511{
    512512        if ( !object_index.is_valid() ) return;
     
    518518}
    519519
    520 void nv::lua::state::register_enum( string_ref name, int value )
     520void nv::lua::state::register_enum( string_view name, int value )
    521521{
    522522        lua_pushinteger( m_state, value );
     
    524524}
    525525
    526 nv::lua::ref nv::lua::state::register_handle_component_impl( string_ref id, bool empty )
     526nv::lua::ref nv::lua::state::register_handle_component_impl( string_view id, bool empty )
    527527{
    528528        int args = empty ? 1 : 2;
     
    547547}
    548548
    549 void nv::lua::state::unregister_handle_component_impl( string_ref id )
     549void nv::lua::state::unregister_handle_component_impl( string_view id )
    550550{
    551551        NV_LUA_STACK_ASSERT( m_state, -1 );
     
    562562}
    563563
    564 void nv::lua::state::register_singleton( string_ref name, void* o )
     564void nv::lua::state::register_singleton( string_view name, void* o )
    565565{
    566566        if ( o == nullptr ) return;
  • trunk/src/lua/lua_values.cc

    r395 r399  
    7575}
    7676
    77 void nv::lua::detail::push_string_ref( lua_State *L, string_ref s )
     77void nv::lua::detail::push_string_view( lua_State *L, string_view s )
    7878{
    7979        lua_pushlstring( L, s.data(), s.size() );
     
    123123}
    124124
    125 nv::string_ref nv::lua::detail::to_string_ref( lua_State *L, int index )
     125nv::string_view nv::lua::detail::to_string_view( lua_State *L, int index )
    126126{
    127127        size_t length = 0;
    128128        const char* result = lua_tolstring( L, index, &length );
    129         return string_ref( result, length );
     129        return string_view( result, length );
    130130}
    131131
  • trunk/src/sdl/sdl_audio.cc

    r397 r399  
    8585}
    8686
    87 nv::sound nv::sdl::audio::load_sound( const string_ref& a_path )
     87nv::sound nv::sdl::audio::load_sound( const string_view& a_path )
    8888{
    8989        // 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.