diff options
| author | Unknown <azeem@live.ru> | 2018-11-03 11:54:21 +0000 |
|---|---|---|
| committer | Unknown <azeem@live.ru> | 2018-11-03 11:54:21 +0000 |
| commit | 90c1619363d89e0ab041f72945b36cfde8b2917a (patch) | |
| tree | b3e99a8daf7598bec2eda3dc6f488e687f0b63e8 /internal_rewrite/simple_settings.hpp | |
| parent | b48ce5a80d059d802d1ef3a872731df45ee57c9d (diff) | |
gay shit
Diffstat (limited to 'internal_rewrite/simple_settings.hpp')
| -rw-r--r-- | internal_rewrite/simple_settings.hpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/internal_rewrite/simple_settings.hpp b/internal_rewrite/simple_settings.hpp index 8dcfaca..9dffa55 100644 --- a/internal_rewrite/simple_settings.hpp +++ b/internal_rewrite/simple_settings.hpp @@ -20,6 +20,7 @@ public: virtual void load( const char* path, const char* file ) = 0;
virtual void save( const char* path, const char* file ) const = 0;
+ virtual void reset( ) const = 0;
virtual void register_( ISettingNode* node_ptr ) = 0;
virtual bool has_nodes( ) { return false; }
virtual hash_t get_hash( ) { return 0; }
@@ -59,6 +60,11 @@ public: x->save( full_path, file );
}
+ __declspec( noinline ) void reset( ) const override {
+ for( auto x : setting_nodes_ )
+ x->reset( );
+ }
+
auto& get_nodes( ) {
return setting_nodes_;
}
@@ -115,6 +121,7 @@ public: WritePrivateProfileStringA( path, std::to_string( m_name ).c_str( ), m_value, file );
}
+
char* get( ) {
return m_value;
}
@@ -129,13 +136,15 @@ class con_var : public ISetting { public:
__declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name ) :
name_( name ),
+ original_{ },
is_float_( std::is_floating_point_v< T > ),
is_integral_( std::is_integral_v< T > ) {
holder_ptr->register_( this );
}
- __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name , const T& rhs ) :
+ __declspec( noinline ) con_var( SettingHolder* holder_ptr, hash_t name, const T& rhs ) :
value_( rhs ),
name_( name ),
+ original_( value_ ),
is_float_( std::is_floating_point_v< T > ),
is_integral_( std::is_integral_v< T > ) {
holder_ptr->register_( this );
@@ -181,6 +190,11 @@ public: simple_save( path, std::to_string( name_ ).c_str( ), &value_, sizeof( value_ ), full_path );
}
+ __declspec( noinline ) void reset( ) const override {
+ // now this is really epic.
+ memcpy( ( void* )&value_, ( void* )&original_, sizeof( original_ ) );
+ }
+
__forceinline operator T&( ) { return value_; }
__forceinline T* operator &( ) { return &value_; }
@@ -261,4 +275,5 @@ private: bool is_float_;
bool is_integral_;
T value_;
+ T original_;
};
\ No newline at end of file |
