Changeset 368


Ignore:
Timestamp:
05/22/15 10:28:08 (10 years ago)
Author:
epyon
Message:
  • massive restructuring
  • detail::data_base class for container/reference class base
Location:
trunk
Files:
3 added
68 edited
14 moved

Legend:

Unmodified
Added
Removed
  • trunk/nv.lua

    r323 r368  
    44        kind "StaticLib"
    55        includedirs { "." }
    6         files { "nv/core/**.hh", "nv/interface/**.hh", "nv/detail/**.inc", "src/core/**.cc" }
     6        files { "nv/core/**.hh", "nv/stl/**.hh", "nv/interface/**.hh", "nv/detail/**.inc", "src/core/**.cc", "src/stl/**.cc" }
    77
    88project "nv-lib"
  • trunk/nv/core/common.hh

    r365 r368  
    137137#if NV_COMPILER == NV_MSVC
    138138#define NV_DEPRECATED(func) __declspec(deprecated) func
     139#define NV_ALIGN(value) __declspec(align(value))
     140#define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct
     141#define NV_RESTRICT __declspec(restrict)
     142#define NV_RESTRICT_VAR __restrict
     143//#define NV_CONSTEXPR
    139144#elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
    140145#define NV_DEPRECATED(func) func __attribute__ ((deprecated))
    141 #else
     146#define NV_ALIGN(value) __attribute__((aligned(value)))
     147#define NV_ALIGNED_STRUCT(value) struct __attribute__((aligned(value)))
     148#define NV_RESTRICT __restrict__
     149#define NV_RESTRICT_VAR __restrict__
     150//#define NV_CONSTEXPR constexpr
     151#else
    142152#define NV_DEPRECATED(func) func
     153#define NV_ALIGN(value)
     154#define NV_ALIGNED_STRUCT(value) struct
     155#define NV_RESTRICT
     156#define NV_RESTRICT_VAR
     157//#define NV_CONSTEXPR
    143158#endif
    144159
  • trunk/nv/core/library.hh

    r319 r368  
    1414#define NV_CORE_LIBRARY_HH
    1515
    16 #include <nv/core/exception.hh>
    17 #include <nv/core/string.hh>
     16#include <nv/stl/exception.hh>
     17#include <nv/stl/string.hh>
    1818
    1919namespace nv
  • trunk/nv/core/logger.hh

    r366 r368  
    1414#define NV_CORE_LOGGER_HH
    1515
    16 #include <nv/core/string.hh>
    1716#include <nv/core/logging.hh>
     17#include <nv/stl/string.hh>
    1818
    1919namespace nv
     
    3535                virtual void log( log_level level, const string_ref& message ) = 0;
    3636                /**
    37          * Optional timestamp string
    38                  */
    39                 string_ref timestamp() const;
    40                 /**
    41          * Log level name (unpadded)
    42                  */
     37                 * Enforcement of virtual destructor.
     38                 */
     39                virtual ~log_sink() {}
     40        protected:
     41                /**
     42                * Optional timestamp string
     43                */
     44                size_t timestamp( char* buffer ) const;
     45                /**
     46                * Log level name (unpadded)
     47                */
    4348                string_ref level_name( log_level level ) const;
    4449                /**
    45          * Log level name (padded)
    46                  */
     50                * Log level name (padded)
     51                */
    4752                string_ref padded_level_name( log_level level ) const;
    48                 /**
    49                  * Enforcement of virtual destructor.
    50                  */
    51                 virtual ~log_sink() {}
    5253        };
    5354
  • trunk/nv/core/logging.hh

    r365 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/string.hh>
    18 #include <nv/core/singleton.hh>
     17#include <nv/stl/string.hh>
     18#include <nv/stl/singleton.hh>
    1919#include <sstream>
    2020
  • trunk/nv/core/position.hh

    r328 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
    18 #include <nv/core/range.hh>
     17#include <nv/stl/math.hh>
     18#include <nv/stl/range.hh>
    1919#include <utility>
    2020
  • trunk/nv/core/profiler.hh

    r322 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/singleton.hh>
     17#include <nv/stl/singleton.hh>
    1818#include <unordered_map>
    1919
  • trunk/nv/core/random.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212#include <random>
    1313
  • trunk/nv/core/transform.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212
    1313namespace nv
  • trunk/nv/engine/particle_engine.hh

    r353 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
    12 #include <nv/core/array.hh>
    13 #include <nv/core/handle.hh>
     11#include <nv/stl/math.hh>
     12#include <nv/stl/array.hh>
     13#include <nv/stl/handle.hh>
    1414#include <nv/lua/lua_state.hh>
    1515#include <nv/gfx/texture_atlas.hh>
  • trunk/nv/formats/md2_loader.hh

    r319 r368  
    1616#include <nv/core/common.hh>
    1717#include <unordered_map>
    18 #include <nv/core/array.hh>
     18#include <nv/stl/array.hh>
    1919#include <nv/interface/mesh_loader.hh>
    2020
  • trunk/nv/formats/md3_loader.hh

    r319 r368  
    1616#include <nv/core/common.hh>
    1717#include <unordered_map>
    18 #include <nv/core/array.hh>
     18#include <nv/stl/array.hh>
    1919#include <nv/core/transform.hh>
    2020#include <nv/interface/mesh_data.hh>
  • trunk/nv/formats/md5_loader.hh

    r323 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/array.hh>
     17#include <nv/stl/array.hh>
    1818#include <nv/interface/mesh_loader.hh>
    1919
  • trunk/nv/gfx/animation.hh

    r367 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/array.hh>
     11#include <nv/stl/array.hh>
    1212#include <nv/interface/stream.hh>
    13 #include <nv/core/math.hh>
     13#include <nv/stl/math.hh>
    1414#include <nv/interface/animation_key.hh>
    1515#include <nv/interface/interpolation_raw.hh>
  • trunk/nv/gfx/debug_draw.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212#include <nv/interface/context.hh>
    1313
  • trunk/nv/gfx/image.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212#include <nv/interface/image_data.hh>
    1313
  • trunk/nv/gfx/mesh_creator.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212#include <nv/interface/mesh_data.hh>
    1313
  • trunk/nv/gfx/sliced_buffer.hh

    r323 r368  
    1212
    1313#include <nv/core/common.hh>
    14 #include <nv/core/math.hh>
     14#include <nv/stl/math.hh>
    1515
    1616namespace nv
  • trunk/nv/gfx/texture_atlas.hh

    r319 r368  
    1111
    1212#include <nv/core/common.hh>
    13 #include <nv/core/math.hh>
     13#include <nv/stl/math.hh>
    1414#include <nv/gfx/image.hh>
    1515#include <vector>
  • trunk/nv/gfx/texture_font.hh

    r319 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/string.hh>
     11#include <nv/stl/string.hh>
    1212#include <unordered_map>
    13 #include <nv/core/math.hh>
     13#include <nv/stl/math.hh>
    1414#include <nv/gfx/texture_atlas.hh>
    1515
  • trunk/nv/gl/gl_enum.hh

    r331 r368  
    1313#define NV_GL_ENUM_HH
    1414
    15 #include <nv/core/math.hh>
     15#include <nv/stl/math.hh>
    1616#include <nv/interface/clear_state.hh>
    1717#include <nv/interface/render_state.hh>
  • trunk/nv/gui/gui_ascii_renderer.hh

    r355 r368  
    1515
    1616#include <nv/core/position.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818#include <nv/interface/terminal.hh>
    1919#include <nv/gui/gui_renderer.hh>
  • trunk/nv/gui/gui_common.hh

    r351 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/handle.hh>
    18 #include <nv/core/flags.hh>
     17#include <nv/stl/handle.hh>
     18#include <nv/stl/flags.hh>
    1919
    2020namespace nv
  • trunk/nv/gui/gui_element.hh

    r351 r368  
    1717#include <nv/core/position.hh>
    1818#include <nv/core/io_event.hh>
    19 #include <nv/core/string.hh>
     19#include <nv/stl/string.hh>
    2020#include <nv/gui/gui_common.hh>
    2121#include <list>
  • trunk/nv/gui/gui_environment.hh

    r354 r368  
    1919#include <nv/core/io_event.hh>
    2020#include <nv/interface/window.hh>
    21 #include <nv/core/array.hh>
     21#include <nv/stl/array.hh>
    2222
    2323namespace nv
  • trunk/nv/gui/gui_renderer.hh

    r354 r368  
    1515
    1616#include <nv/core/position.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818#include <nv/gui/gui_common.hh>
    1919#include <nv/gui/gui_style.hh>
  • trunk/nv/interface/animated_mesh.hh

    r319 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818#include <nv/core/transform.hh>
    1919#include <nv/interface/context.hh>
  • trunk/nv/interface/animation_key.hh

    r323 r368  
    1212#include <nv/core/common.hh>
    1313#include <nv/core/transform.hh>
    14 #include <nv/core/math.hh>
     14#include <nv/stl/math.hh>
    1515
    1616namespace nv
  • trunk/nv/interface/audio.hh

    r330 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/math.hh>
    17 #include <nv/core/handle.hh>
     16#include <nv/stl/math.hh>
     17#include <nv/stl/handle.hh>
    1818
    1919namespace nv
  • trunk/nv/interface/camera.hh

    r342 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/math.hh>
     16#include <nv/stl/math.hh>
    1717
    1818namespace nv
  • trunk/nv/interface/clear_state.hh

    r342 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818
    1919namespace nv
  • trunk/nv/interface/device.hh

    r361 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/string.hh>
    17 #include <nv/core/handle.hh>
     16#include <nv/stl/string.hh>
     17#include <nv/stl/handle.hh>
    1818#include <nv/interface/uniform.hh>
    1919#include <nv/interface/mesh_data.hh>
  • trunk/nv/interface/image_data.hh

    r351 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818#include <algorithm>
    1919
  • trunk/nv/interface/interpolation_raw.hh

    r319 r368  
    1212#include <nv/core/common.hh>
    1313#include <nv/core/transform.hh>
    14 #include <nv/core/math.hh>
     14#include <nv/stl/math.hh>
    1515#include <nv/interface/animation_key.hh>
    1616
  • trunk/nv/interface/interpolation_template.hh

    r323 r368  
    1212#include <nv/core/common.hh>
    1313#include <nv/core/transform.hh>
    14 #include <nv/core/math.hh>
     14#include <nv/stl/math.hh>
    1515#include <nv/interface/animation_key.hh>
    1616
  • trunk/nv/interface/map_area.hh

    r323 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/string.hh>
    17 #include <nv/core/array.hh>
    1816#include <nv/core/position.hh>
     17#include <nv/stl/string.hh>
     18#include <nv/stl/array.hh>
    1919
    2020namespace nv
  • trunk/nv/interface/mesh_data.hh

    r323 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
    12 #include <nv/core/string.hh>
    13 #include <nv/core/array.hh>
     11#include <nv/stl/math.hh>
     12#include <nv/stl/string.hh>
     13#include <nv/stl/array.hh>
    1414#include <nv/gfx/animation.hh>
    1515#include <nv/interface/vertex.hh>
  • trunk/nv/interface/mesh_loader.hh

    r319 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/array.hh>
     17#include <nv/stl/array.hh>
    1818#include <unordered_map>
    1919#include <nv/core/transform.hh>
    20 #include <nv/core/string.hh>
     20#include <nv/stl/string.hh>
    2121#include <nv/gfx/animation.hh>
    2222#include <nv/interface/mesh_data.hh>
  • trunk/nv/interface/render_state.hh

    r322 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818#include <nv/interface/clear_state.hh>
    19 #include <nv/core/string.hh>
     19#include <nv/stl/string.hh>
    2020
    2121namespace nv
  • trunk/nv/interface/scene_node.hh

    r319 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/array.hh>
     16#include <nv/stl/array.hh>
    1717#include <nv/core/transform.hh>
    18 #include <nv/core/math.hh>
     18#include <nv/stl/math.hh>
    1919#include <nv/interface/render_state.hh>
    2020
  • trunk/nv/interface/uniform.hh

    r342 r368  
    1515#include <nv/interface/camera.hh>
    1616#include <nv/core/common.hh>
    17 #include <nv/core/string.hh>
     17#include <nv/stl/string.hh>
    1818#include <unordered_map>
    1919
  • trunk/nv/interface/vertex.hh

    r323 r368  
    1212#include <nv/core/common.hh>
    1313#include <nv/core/transform.hh>
    14 #include <nv/core/math.hh>
     14#include <nv/stl/math.hh>
    1515
    1616namespace nv
  • trunk/nv/interface/window.hh

    r343 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/string.hh>
    1716#include <nv/core/io_event.hh>
     17#include <nv/stl/string.hh>
    1818
    1919namespace nv
  • trunk/nv/interface/window_manager.hh

    r364 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/string.hh>
     16#include <nv/stl/string.hh>
    1717
    1818namespace nv
  • trunk/nv/io/string_table.hh

    r323 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/array.hh>
     16#include <nv/stl/array.hh>
    1717#include <unordered_map>
    1818#include <nv/interface/stream.hh>
  • trunk/nv/lib/assimp.hh

    r365 r368  
    1010#include <nv/core/common.hh>
    1111#include <nv/core/logging.hh>
    12 #include <nv/core/string.hh>
    13 #include <nv/core/math.hh>
     12#include <nv/stl/string.hh>
     13#include <nv/stl/math.hh>
    1414
    1515#define NV_ASSIMP_DYNAMIC
  • trunk/nv/lua/lua_dispatch.hh

    r348 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/string.hh>
     17#include <nv/stl/string.hh>
    1818#include <nv/lua/lua_values.hh>
    1919#include <nv/lua/lua_path.hh>
  • trunk/nv/lua/lua_flags.hh

    r319 r368  
    88
    99#include <nv/core/common.hh>
    10 #include <nv/core/flags.hh>
     10#include <nv/stl/flags.hh>
    1111#include <nv/lua/lua_state.hh>
    1212#include <nv/lua/lua_values.hh>
  • trunk/nv/lua/lua_glm.hh

    r319 r368  
    99#include <new>
    1010#include <nv/core/common.hh>
    11 #include <nv/core/math.hh>
     11#include <nv/stl/math.hh>
    1212#include <nv/lua/lua_values.hh>
    1313
  • trunk/nv/lua/lua_handle.hh

    r364 r368  
    88
    99#include <nv/core/common.hh>
    10 #include <nv/core/handle.hh>
     10#include <nv/stl/handle.hh>
    1111#include <nv/lua/lua_values.hh>
    1212
  • trunk/nv/lua/lua_path.hh

    r360 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/string.hh>
     17#include <nv/stl/string.hh>
    1818#include <cstring>
    1919
  • trunk/nv/lua/lua_raw.hh

    r367 r368  
    88
    99#include <nv/core/common.hh>
    10 #include <nv/core/array.hh>
     10#include <nv/stl/array.hh>
    1111#include <nv/lib/lua.hh>
    1212
  • trunk/nv/lua/lua_state.hh

    r367 r368  
    1313
    1414#include <nv/core/common.hh>
    15 #include <nv/core/flags.hh>
    16 #include <nv/core/handle.hh>
     15#include <nv/stl/flags.hh>
     16#include <nv/stl/handle.hh>
    1717
    1818#include <nv/lua/lua_handle.hh>
  • trunk/nv/lua/lua_values.hh

    r360 r368  
    99
    1010#include <nv/core/common.hh>
    11 #include <nv/core/type_traits.hh>
    12 #include <nv/core/string.hh>
     11#include <nv/stl/type_traits.hh>
     12#include <nv/stl/string.hh>
    1313
    1414struct lua_State;
  • trunk/nv/stl/array.hh

    r364 r368  
    1515
    1616#include <nv/core/common.hh>
     17#include <nv/stl/memory.hh>
    1718#include <vector>
    1819#include <algorithm>
     
    2526
    2627        template< class T, std::size_t N >
    27         class static_array
     28        class static_array : public detail::data_base< T, false, N >
    2829        {
    2930        public:
     
    3940                typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
    4041
    41                 iterator        begin()        { return m_data; }
    42                 const_iterator  begin()  const { return m_data; }
    43                 const_iterator  cbegin() const { return m_data; }
    44 
    45                 iterator        end()        { return m_data+N; }
    46                 const_iterator  end()  const { return m_data+N; }
    47                 const_iterator  cend() const { return m_data+N; }
    48 
    49                 reverse_iterator rbegin()              { return reverse_iterator( end() ); }
    50                 const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
    51                 const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
    52 
    53                 reverse_iterator rend()                { return reverse_iterator( begin() ); }
    54                 const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
    55                 const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
     42//              iterator        begin()        { return m_data; }
     43//              const_iterator  begin()  const { return m_data; }
     44//              const_iterator  cbegin() const { return m_data; }
     45//
     46//              iterator        end()        { return m_data+N; }
     47//              const_iterator  end()  const { return m_data+N; }
     48//              const_iterator  cend() const { return m_data+N; }
     49//
     50//              reverse_iterator rbegin()              { return reverse_iterator( end() ); }
     51//              const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
     52//              const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
     53//
     54//              reverse_iterator rend()                { return reverse_iterator( begin() ); }
     55//              const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
     56//              const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
    5657
    5758                reference operator[]( size_type i )
    5859                {
    5960                        NV_ASSERT( i < N, "Out of range" );
    60                         return m_data[i];
     61                        return this->m_data[i];
    6162                }
    6263
     
    6465                {     
    6566                        NV_ASSERT( i < N, "Out of range" );
    66                         return m_data[i];
     67                        return this->m_data[i];
    6768                }
    6869
    69                 reference       front()       { return m_data[0]; }
    70                 const_reference front() const { return m_data[0]; }
    71                 reference       back()        { return m_data[N-1]; }
    72                 const_reference back() const  { return m_data[N-1]; }
     70//              reference       front()       { return m_data[0]; }
     71//              const_reference front() const { return m_data[0]; }
     72//              reference       back()        { return m_data[N-1]; }
     73//              const_reference back() const  { return m_data[N-1]; }
     74//
     75//              static size_type size()     { return N; }
     76//              static bool      empty()    { return false; }
     77//              static size_type max_size() { return N; }
     78//
     79//              const value_type* data() const { return m_data; }
     80//              value_type*       data()       { return m_data; }
     81//
     82//              size_type   raw_size() const { return N * ELEMENT_SIZE; }
     83//              const char* raw_data() const { return (const char*)m_data; }
     84//              char*       raw_data()       { return (char*)m_data; }
    7385
    74                 static size_type size()     { return N; }
    75                 static bool      empty()    { return false; }
    76                 static size_type max_size() { return N; }
    77 
    78                 const value_type* data() const { return m_data; }
    79                 value_type*       data()       { return m_data; }
    80 
    81                 size_type   raw_size() const { return N * ELEMENT_SIZE; }
    82                 const char* raw_data() const { return (const char*)m_data; }
    83                 char*       raw_data()       { return (char*)m_data; }
    84 
    85                 void assign( const value_type& value ) { std::fill_n( begin(), size(), value ); }
     86                void assign( const value_type& value ) { std::fill_n( this->begin(), this->size(), value ); }
    8687
    8788                static const size_type SIZE = N;
    8889                static const size_type ELEMENT_SIZE = sizeof(T);
    89         public:
    90                 value_type m_data[N];
    9190        };
    9291
    9392        template< class T >
    94         class dynamic_array
     93        class dynamic_array : public detail::data_base< T, false, 0 >
    9594        {
    9695        public:
     
    106105                typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
    107106
    108                 dynamic_array()
    109                         : m_data( nullptr ), m_size(0) {}
    110                 explicit dynamic_array( size_type new_size )
    111                         : m_data( new value_type[ new_size ] ), m_size( new_size ) {}
    112                 dynamic_array( const value_type& value, size_type size )
    113                         : m_data( nullptr ), m_size(0) { assign( value, size ); }
    114                 dynamic_array( const_iterator values, size_type size )
    115                         : m_data( nullptr ), m_size(0) { assign( values, size ); }
     107                dynamic_array() : detail::data_base< T, false, 0 >() {}
     108//                      : m_data( nullptr ), m_size(0) {}
     109                explicit dynamic_array( size_type new_size ) : detail::data_base< T, false, 0 >( new value_type[new_size], new_size ) {}
     110//                      : m_data( new value_type[ new_size ] ), m_size( new_size ) {}
     111                dynamic_array( const value_type& value, size_type size ) : detail::data_base< T, false, 0 >()
     112//                      : m_data( nullptr ), m_size(0)
     113                { assign( value, size ); }
     114                dynamic_array( const_iterator values, size_type size ) : detail::data_base< T, false, 0 >()
     115//                      : m_data( nullptr ), m_size(0)
     116                { assign( values, size ); }
    116117
    117118                void resize( size_type new_size )
    118119                {
    119                         if ( new_size != m_size )
     120                        if ( new_size != this->m_size )
    120121                        {
    121                                 value_type* old_data = m_data;
    122                                 m_data = new_size > 0 ? new value_type[ new_size ] : nullptr;
    123                                 if ( old_data && m_data )
     122                                value_type* old_data = this->m_data;
     123                                this->m_data = new_size > 0 ? new value_type[new_size] : nullptr;
     124                                if ( old_data && this->m_data )
    124125                                {
    125                                         std::copy_n( old_data, new_size > m_size ? m_size : new_size, m_data );
     126                                        std::copy_n( old_data, new_size > this->m_size ? this->m_size : new_size, this->m_data );
    126127                                }
    127128                                delete[] old_data;
    128                                 m_size = new_size;
     129                                this->m_size = new_size;
    129130                        }
    130131                }
    131132
    132                 iterator        begin()        { return m_data; }
    133                 const_iterator  begin()  const { return m_data; }
    134                 const_iterator  cbegin() const { return m_data; }
    135 
    136                 iterator        end()        { return m_data+m_size; }
    137                 const_iterator  end()  const { return m_data+m_size; }
    138                 const_iterator  cend() const { return m_data+m_size; }
    139 
    140                 reverse_iterator rbegin()              { return reverse_iterator( end() ); }
    141                 const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
    142                 const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
    143 
    144                 reverse_iterator rend()                { return reverse_iterator( begin() ); }
    145                 const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
    146                 const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
     133//              iterator        begin()        { return m_data; }
     134//              const_iterator  begin()  const { return m_data; }
     135//              const_iterator  cbegin() const { return m_data; }
     136//
     137//              iterator        end()        { return m_data+m_size; }
     138//              const_iterator  end()  const { return m_data+m_size; }
     139//              const_iterator  cend() const { return m_data+m_size; }
     140//
     141//              reverse_iterator rbegin()              { return reverse_iterator( end() ); }
     142//              const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
     143//              const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
     144//
     145//              reverse_iterator rend()                { return reverse_iterator( begin() ); }
     146//              const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
     147//              const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
    147148
    148149                reference operator[]( size_type i )
    149150                {
    150                         NV_ASSERT( i < m_size, "Out of range" );
    151                         return m_data[i];
     151                        NV_ASSERT( i < this->m_size, "Out of range" );
     152                        return this->m_data[i];
    152153                }
    153154
    154155                const_reference operator[]( size_type i ) const
    155156                {     
    156                         NV_ASSERT( i < m_size, "Out of range" );
    157                         return m_data[i];
     157                        NV_ASSERT( i < this->m_size, "Out of range" );
     158                        return this->m_data[i];
    158159                }
    159160
    160                 reference       front()       { return m_data[0]; }
    161                 const_reference front() const { return m_data[0]; }
    162                 reference       back()        { return m_data[m_size-1]; }
    163                 const_reference back() const  { return m_data[m_size-1]; }
     161//              reference       front()       { return m_data[0]; }
     162//              const_reference front() const { return m_data[0]; }
     163//              reference       back()        { return m_data[m_size-1]; }
     164//              const_reference back() const  { return m_data[m_size-1]; }
     165//
     166//              size_type        size() const     { return m_size; }
     167//              bool             empty() const    { return m_size == 0; }
     168//              static size_type max_size()       { return std::numeric_limits< size_type >::max(); }
     169//              const value_type* data() const { return m_data; }
     170//              value_type*       data()       { return m_data; }
     171//
     172//              size_type   raw_size() const { return m_size * ELEMENT_SIZE; }
     173//              const char* raw_data() const { return (const char*)m_data; }
     174//              char*       raw_data()       { return (char*)m_data; }
    164175
    165                 size_type        size() const     { return m_size; }
    166                 bool             empty() const    { return m_size == 0; }
    167                 static size_type max_size()       { return std::numeric_limits< size_type >::max(); }
    168                 const value_type* data() const { return m_data; }
    169                 value_type*       data()       { return m_data; }
    170 
    171                 size_type   raw_size() const { return m_size * ELEMENT_SIZE; }
    172                 const char* raw_data() const { return (const char*)m_data; }
    173                 char*       raw_data()       { return (char*)m_data; }
    174 
    175                 void assign( const value_type& value ) { std::fill_n( begin(), size(), value ); }
     176                void assign( const value_type& value ) { std::fill_n( this->begin(), this->size(), value ); }
    176177                void assign( const value_type& value, size_type new_size )
    177178                {
    178179                        resize( new_size );
    179                         std::fill_n( begin(), size(), value );
     180                        std::fill_n( this->begin(), this->size(), value );
    180181                }
    181182                void assign( const_iterator values, size_type new_size )
    182183                {
    183184                        resize( new_size );
    184                         std::copy_n( values, size(), m_data );
     185                        std::copy_n( values, this->size(), this->m_data );
    185186                }
    186187
    187                 ~dynamic_array() { delete[] m_data; }
     188                ~dynamic_array() { delete[] this->m_data; }
    188189
    189190                static const size_type ELEMENT_SIZE = sizeof(T);
    190         public:
    191                 value_type* m_data;
    192                 size_type   m_size;
    193191        };
    194192
  • trunk/nv/stl/array2d.hh

    r367 r368  
    1717
    1818#include <nv/core/common.hh>
    19 #include <nv/core/math.hh>
    20 #include <nv/core/range.hh>
     19#include <nv/stl/math.hh>
     20#include <nv/stl/range.hh>
    2121
    2222namespace nv
  • trunk/nv/stl/flags.hh

    r364 r368  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/type_traits.hh>
    18 #include <nv/core/array.hh>
     17#include <nv/stl/type_traits.hh>
     18#include <nv/stl/array.hh>
    1919
    2020namespace nv
  • trunk/nv/stl/handle.hh

    r364 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/array.hh>
     16#include <nv/stl/array.hh>
    1717
    1818namespace nv
  • trunk/nv/stl/range.hh

    r364 r368  
    1414
    1515#include <nv/core/common.hh>
    16 #include <nv/core/math.hh>
    17 #include <nv/core/type_traits.hh>
     16#include <nv/stl/math.hh>
     17#include <nv/stl/type_traits.hh>
    1818#include <iterator>
    1919
  • trunk/nv/stl/string.hh

    r367 r368  
    2727#include <fstream>
    2828#include <nv/core/common.hh>
    29 #include <nv/core/exception.hh>
     29#include <nv/stl/memory.hh>
     30#include <nv/stl/exception.hh>
    3031
    3132namespace nv
     
    296297
    297298        // string base class - will become a base for a string class later
    298         class string_base
     299        class string_base : public detail::data_base< char, true, 0 >
    299300        {
    300301        public:
     
    308309                typedef std::ptrdiff_t difference_type;
    309310
    310                 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
    311                 typedef const_reverse_iterator                reverse_iterator;
    312 
    313311                static NV_CONSTEXPR_CONST size_type npos = size_type( -1 );
    314312
     
    319317                }
    320318
    321                 // iterators
    322                 inline NV_CONSTEXPR const_iterator  cbegin() const { return m_data; }
    323                 inline NV_CONSTEXPR const_iterator    cend() const { return m_data + m_size; }
    324                 inline const_reverse_iterator crbegin() const { return const_reverse_iterator( cend() ); }
    325                 inline const_reverse_iterator   crend() const { return const_reverse_iterator( cbegin() ); }
    326 
    327                 inline NV_CONSTEXPR size_type size()     const { return m_size; }
    328319                inline NV_CONSTEXPR size_type length()   const { return m_size; }
    329                 inline NV_CONSTEXPR size_type max_size() const { return m_size; }
    330                 inline NV_CONSTEXPR bool empty()         const { return m_size == 0; }
    331320
    332321                // access
     
    340329                inline NV_CONSTEXPR char front()        const { return m_data[0]; }
    341330                inline NV_CONSTEXPR char back()         const { return m_data[m_size - 1]; }
    342                 inline NV_CONSTEXPR const char* data()  const { return m_data; }
    343331
    344332                // string operations
     
    442430
    443431        protected:
    444                 inline NV_CONSTEXPR string_base() : m_data( nullptr ), m_size( 0 ) {}
     432                inline NV_CONSTEXPR string_base() : detail::data_base< char, true, 0 >() {}
    445433                inline NV_CONSTEXPR string_base( pointer a_data, size_type a_lenght )
    446                         : m_data( a_data ), m_size( a_lenght ) {}
    447 
    448         protected:
    449                 pointer   m_data;
    450                 size_type m_size;
     434                        : detail::data_base< char, true, 0 >( a_data, a_lenght ) {}
    451435        };
    452436
     
    494478                        return *this;
    495479                }
    496 
    497                 // iterators
    498                 inline NV_CONSTEXPR const_iterator   begin() const { return m_data; }
    499                 inline NV_CONSTEXPR const_iterator     end() const { return m_data + m_size; }
    500                 inline const_reverse_iterator  rbegin() const { return const_reverse_iterator( end() ); }
    501                 inline const_reverse_iterator    rend() const { return const_reverse_iterator( begin() ); }
    502480
    503481                // modifiers
  • trunk/src/core/logger.cc

    r365 r368  
    142142void log_console_sink::log( log_level level, const string_ref& message )
    143143{
     144        char stamp[16];
     145        size_t ssize = timestamp( stamp );
     146
    144147#if NV_PLATFORM == NV_WINDOWS
    145148        if ( m_color ) SetConsoleTextAttribute( m_handle, FOREGROUND_INTENSITY );
    146         string_ref stamp( timestamp() );
    147         WriteConsole( m_handle, stamp.data(), stamp.size(), nullptr, nullptr );
     149        WriteConsole( m_handle, stamp, ssize, nullptr, nullptr );
    148150        WriteConsole( m_handle, " [", 2, nullptr, nullptr );
    149151        if (m_color) SetConsoleTextAttribute( m_handle, log_color[( level ) / 10] );
     
    156158#else
    157159        if ( m_color ) fwrite( "\33[30;1m", 7, 1, stdout );
    158         fwrite( stamp.data(), stamp.size(), 1, stdout );
     160        fwrite( stamp, ssize, 1, stdout );
    159161        fwrite( " [", 2, 1, stdout );
    160162        if ( m_color )
     
    176178void log_handle_sink::log( log_level level, const string_ref& message )
    177179{
    178         string_ref stamp( timestamp() );
     180        char stamp[16];
     181        size_t ssize = timestamp( stamp );
    179182#if 0 // NV_PLATFORM == NV_WINDOWS
    180183        // Turns out WriteFile on Windows is unbuffered and quite slower than fwrite
     
    182185        // If we want to get rid of C runtime, this would need a buffered I/O layer.
    183186        DWORD unused = 0;
    184         WriteFile( m_handle, stamp.data(), stamp.size(), &unused, nullptr );
     187        WriteFile( m_handle, stamp, ssize, &unused, nullptr );
    185188        WriteFile( m_handle, " [", 2, &unused, nullptr );
    186189        WriteFile( m_handle, NV_LOG_LEVEL_NAME_PAD( level ), 8, &unused, nullptr );
     
    190193        //if ( m_flush ) FlushFileBuffers( m_handle );
    191194#else
    192         fwrite( stamp.data(), stamp.size(), 1, (FILE*)m_handle );
     195        fwrite( stamp, ssize, 1, (FILE*)m_handle );
    193196        fwrite( " [", 2, 1, (FILE*)m_handle );
    194197        fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, (FILE*)m_handle );
     
    237240}
    238241
    239 string_ref nv::log_sink::timestamp() const
     242size_t nv::log_sink::timestamp( char* buffer ) const
    240243{
    241244        uint32 ms = get_system_ms();
     
    245248        unsigned int m    = (unsigned int)(secs / 60) % 60;
    246249        unsigned int s    = secs % 60;
    247         static char buffer[16];
    248250#if NV_PLATFORM == NV_WINDOWS
    249251        sprintf_s( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm );
     
    251253        snprintf( buffer, 16, "%02d:%02d:%02d.%02d", h, m, s, mm );
    252254#endif
    253         buffer[11] = '\0';
    254         return string_ref( buffer, 10 );
     255        return 11;
    255256}
    256257
  • trunk/src/engine/program_manager.cc

    r365 r368  
    66
    77#include "nv/engine/program_manager.hh"
    8 #include "nv/core/range.hh"
     8#include "nv/stl/range.hh"
    99#include "nv/core/logging.hh"
    1010#include "nv/lua/lua_nova.hh"
  • trunk/src/engine/resource_system.cc

    r364 r368  
    66
    77#include "nv/engine/resource_system.hh"
    8 #include "nv/core/range.hh"
     8#include "nv/stl/range.hh"
    99#include "nv/lua/lua_nova.hh"
    1010
  • trunk/src/formats/nmd_loader.cc

    r323 r368  
    77#include "nv/formats/nmd_loader.hh"
    88#include "nv/io/std_stream.hh"
    9 #include "nv/core/string.hh"
     9#include "nv/stl/string.hh"
    1010
    1111using namespace nv;
  • trunk/src/lib/gl.cc

    r365 r368  
    66
    77#include "nv/core/common.hh"
    8 #include "nv/core/range.hh"
     8#include "nv/stl/range.hh"
    99#include "nv/core/logging.hh"
    1010#include "nv/lib/gl.hh"
  • trunk/src/lua/lua_area.cc

    r335 r368  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/core/string.hh"
     10#include "nv/stl/string.hh"
    1111#include "nv/core/random.hh"
    1212
  • trunk/src/lua/lua_flags.cc

    r319 r368  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/core/string.hh"
     10#include "nv/stl/string.hh"
    1111
    1212
  • trunk/src/lua/lua_glm.cc

    r319 r368  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/core/string.hh"
     10#include "nv/stl/string.hh"
    1111#include "nv/core/random.hh"
    1212
  • trunk/src/lua/lua_map_area.cc

    r360 r368  
    66
    77#include "nv/lua/lua_map_area.hh"
    8 #include "nv/core/flags.hh"
     8#include "nv/stl/flags.hh"
    99#include "nv/lua/lua_area.hh"
    1010#include "nv/lua/lua_glm.hh"
  • trunk/src/lua/lua_map_tile.cc

    r323 r368  
    99#include <numeric>
    1010#include "nv/lua/lua_map_area.hh"
    11 #include "nv/core/flags.hh"
     11#include "nv/stl/flags.hh"
    1212#include "nv/core/random.hh"
    1313#include "nv/lua/lua_area.hh"
  • trunk/src/lua/lua_raw.cc

    r319 r368  
    77#include "nv/lua/lua_raw.hh"
    88
    9 #include "nv/core/string.hh"
     9#include "nv/stl/string.hh"
    1010
    1111std::string nlua_typecontent( lua_State* L, int idx )
  • trunk/src/lua/lua_state.cc

    r367 r368  
    1010#include "nv/lua/lua_nova.hh"
    1111#include "nv/core/logging.hh"
    12 #include "nv/core/string.hh"
     12#include "nv/stl/string.hh"
    1313
    1414using namespace nv;
  • trunk/src/rogue/fov_recursive_shadowcasting.cc

    r319 r368  
    77#include "nv/rogue/fov_recursive_shadowcasting.hh"
    88
    9 #include "nv/core/math.hh"
     9#include "nv/stl/math.hh"
    1010
    1111static int nv_rogue_rs_mult[4][8] = {
  • trunk/src/sdl/sdl_audio.cc

    r367 r368  
    77#include "nv/sdl/sdl_audio.hh"
    88
    9 #include "nv/core/math.hh"
     9#include "nv/stl/math.hh"
    1010#include "nv/lib/sdl_mixer.hh"
    1111#include "nv/core/logging.hh"
  • trunk/src/stl/string.cc

    r367 r368  
    77// TODO: speedup conversion by doing divisions by 100
    88
    9 #include "nv/core/string.hh"
     9#include "nv/stl/string.hh"
    1010
    1111#include <cstdio>
Note: See TracChangeset for help on using the changeset viewer.