Skip to content

A class which help you to manage getter/setter in cpp projects

License

Notifications You must be signed in to change notification settings

m-ri/cpp_GetterSetter_Utilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cpp_GetterSetter_Utilities

A class which help you to manage getter/setter in cpp projects. You can trasparently add/delete these modifiers on existings variables, without big changes in the code

GetSet.h contains the library, while GetSet_Experiments.cpp provides some examples (ranging from trivial examples with integers and strings, to advanced usage with copy and move constructors).

Basic example

#include "GetSet.h"

GetSet<int> positiveVariable(3);
positiveVariable.setGetter([](int& currentItem)-> int {return max(currentItem, 0); });
positiveVariable.setSetter([](int& currentItem, int newValue) {
	if (newValue >= 0)currentItem = newValue;
	else currentItem = currentItem;/* throw std::exception("Added negative value");*/;
});

positiveVariable = 5;
positiveVariable = -10;
cout << positiveVariable;//output: 5

About

A class which help you to manage getter/setter in cpp projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages