C++ Properties
Redacted Software proudly presents another software engineering abomination.
This project implements C#-style properties in C++ using a class template. Properties provide a way to encapsulate fields in a class and control access to them.
Getting Started
To use properties in your C++ project, follow these steps:
Prerequisites
- C++ compiler that supports C++20 or later.
CPM Instructions
CMake Package Manager is the preferred distribution method.
On the git page, look up the latest release-tag and paste it into the indicated section below.
CPMAddPackage(
NAME Property
URL https://git.redacted.cc/josh/Property/Release-{LATEST}.zip
)
Usage
Define your class with properties:
#include "Property.h"
class MyClass {
public:
MyClass() : _value(0) {}
// Define a property named 'Value'
PROPERTY(int, Value, {
return _value;
}, {
_value = value;
})
private:
int _value;
};
In the above example:
Access properties:
MyClass obj;
obj.Value = 10;
int val = obj.Value;
The above code demonstrates setting and getting the Value
property of obj
.
Notes
- Ensure that the accessors (
getter
andsetter
) handle the property's value appropriately. - Properties provide an elegant way to encapsulate fields while maintaining control over access.
Documentation
Documentation is automatically generated from latest commit and is hosted at https://doc.redacted.cc/property .
Contributing
Contributions to Property are welcome! If you find a bug, have a feature request, or would like to contribute code, please submit an issue or pull request to the GitHub repository.
License
Property is licensed under the Public Domain. See the LICENSE file for details.
Acknowledgements
Property is developed and maintained by Joshua O'Leary from Redacted Software and contributors. Special thanks to William J Tomasine II.