ponder
3.2
C++ reflection library
|
date: 2016-01-01 20:46:12
Ponder is a fork of CAMP, which reached the end of its life. Ponder 1.0 keeps the same API as CAMP, but makes some changes, like removing the Boost dependency, instead using C++11 features. Boost is great library, but more recent C++ changes supply a lot of this functionality in the language and standard libraries.
CAMP was originally released, by Tegesoft, under the LGPL licence, but this changed to the MIT licence in version 0.8. Ponder retains the same licence.
Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. Contact: Tegesoft Information (contact@tegesoft.com) This file is part of the CAMP library. The MIT License (MIT) Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
date: 2016-05-16
You can now use placement new to specify the location of a class instance. This is useful if you are managing your own memory.
Class::destruct()
to pair with placement new.Classes and Enums can be undeclared. This is useful if you need to unload classes which you will no longer need. E.g. when unloading dynamic libraries which contain Ponder registered objects.
Be careful not to auto register the class declarations or they will be added straight back again!
Properties and functions are easier to iterate over:
In addition to by name and functions and properties in UserObjects can be accessed by index:
Dictionaries are now ordered (sorted alphabetically) internally. The insertion cost will be more, but this will only happen on declaration. Searching for keys will become a binary search rather than linear.
date: 2016-07-01
Ponder now recognises if properties return the class they are declared in. This allows method chaining. This is also called the "named parameter idiom", see issue #28. E.g.
UserObjects may now be created from opaque user data pointers. This was previous not possible because there was no way of casting a user pointer to a Ponder metaclass pointer. See issue #30. This can now be done using the metaclass method:
User data can be stored more efficiently like the following, only creating UserObjects when the user wishes to interact with the object.
Ponder/CAMP previously had composed function bindings. This allowed class declarations to bind to access functions with a level of indirection. This adds a layer of complexity that can be solved in more flexible ways, for example, using lambda functions.
Example of a class with internal data that we would like to expose:
Previously:
This can now be done using lambda functions. This allows more flexibility, and extra logic may now be inserted.
See unit test function.cpp for examples.
The Ponder value type enumerator was changed to a C++11 enum class. This was done for readability and to modernise the API. See issue #26.
Some unit tests were re-added that were overlooked in the Ponder refactoring, i.e. function unit tests.
date: 2016-07-06
Ponder is a library which is embedded in a library and/or application. The client may have its own string type, besides std::string
, so here we allow the customisation of the identifiers (registered names), and string types.
Pre-Ponder 1.3, const std::string&
was used as the parameter type for ids. The equivalent trait is:
This, potentially, results in many needless string copies (see issue #11). This has been replaced with a string_view
version (see below).
string_view
is reference to a character range. It is implemented as a couple of pointers, which are more efficient to pass these around. It can be converted to a string on demand.
This feature is currently experimental and may not be present in all C++ standard libraries hence an internal version is provided.
Note, like iterators, or pointers into containers, you should not rely on the data always being there, as the string may change or be deleted.
Previously lambda functions had to be declared via std::function<>
wrappers. They are now disambiguated and are recognised as separate.
This means function declarations are a little easier to declare, e.g. :-
Previously, an example of how to wrap indirection:
Now:
std::auto_ptr<>
is deprecated in C++11 and will be fully removed in C++17. Support is removed as it generates a lot of warning spam in some compilers, GCC.