Get list of available functions from exprtk::symbol_table - c++

I would like to query all available function names from a symbol_table. I can see that symbol_table has methods for getting variables, vectors, and stringvars (i.e. symbol_table::get_variable_list). However, I don't see a corresponding symbol_table::get_function_list. Is there some other way that I can get this information?

Related

Coldfusion GetComponentMetaData functions order

The functions list returned by GetComponentMetaData seems to be ordered randomly. Is there any way to get the proper order of functions as defined in the cfc? Thanks.

How to automatically initialize component parameters?

While doing a game engine that uses .lua files in order to read parameter values, I got stuck when I had to read these values and assign them to the parameters of each component in C++. I tried to investigate the way Unity does it, but I didn't find it (and I'm starting to doubt that Unity has to do it at all).
I want the parameters to be initialized automatically, without the user having to do the process of
myComponentParameter = readFromLuaFile("myParameterName")
for each one of the parameters.
My initial idea is to use the std::variant type, and storing an array of variants in order to read them automatically. My problems with this are:
First of all, I don't know how to know the type that std::variant is storing at the moment (tried with std::variant::type, but it didn't work for the template), in order to cast from the untyped .lua value to the C++ value. For reference, my component initialization looks like this:
bool init(luabridge::LuaRef parameterTable)
{
myIntParameter = readVariable<int>(parameterTable, "myIntParameter");
myStringParameter = readVariable<std::string>(parameterTable, "myStringParameter");
return true;
}
(readVariable function is already written in this question, in case you're curious)
The second problem is that the user would have to write std::get(myIntParameter); whenever they want to access to the value stored by the variant, and that sounds like something worse than making the user read the parameter value.
The third problem is that I can't create an array of std::variant<any type>, which is what I would like to do in order to automatically initialize the parameters.
Is there any good solution for this kind of situation where I want the init function to not be necessary, and the user doesn't need to manually set up the parameter values?
Thanks in advance.
Let's expand my comment. In a nutshell, you need to get from
"I have some things entered by the user in some file"
to:
"the client code can read the value without std::get"
…which roughly translates to:
"input validation was done, and values are ready for direct use."
…which implies you do not store your variables in variants.
In the end it is a design question. One module somewhere must have the knowledge of which variable names exist, and the type of each, and the valid values.
The input of that module will be unverified values.
The output of the module will probably be some regular c++ struct.
And the body of that module will likely have a bunch of those:
config.foo = readVariable<int>("foo");
config.bar = readVariable<std::string>("bar");
// you also want to validate values there - all ints may not be valid values for foo,
// maybe bar must follow some specific rules, etc
assuming somewhere else it was defined as:
struct Configuration {
int fooVariable;
std::string bar;
};
Where that module lives depends on your application. If all expected types are known, there is no reason to ever use a variant, just parse right away.
You would read to variants if some things do not make sense until later. For instance if you want to read configuration values that will be used by plugins, so you cannot make sense of them yet.
(actually even then simply re-parsing the file later, or just saving values as text for later parsing would work)

Marking functions with comment-like tags for their user

How would I go about telling the user of a function that he/she should be calling the function within a specific context or in a specific way? Say for example, mark a function must only be called on a designated thread.
Basically, something that doesn't affect the behavior of the program but conveys information not using comments nor changing function names and in a uniform, non-code-repeating way(using macros?) across all functions that are marked. My first thought is using an empty macro in the function definition, this works but the problem is that tools like intellisense don't display this "tag" of sorts to the user.

Generic Mutator/Accessor functions

Is there a way to create generic set/get functions in C++? I have a class with a large number of attributes but no functions (ok I should probably use a struct), and really don't want to write individual set and get functions for each data member. The functions I'm thinking of would be something like 'set_member( T variable ), where T could be anything, primitive types or user defined. I imagine perhaps you could create a struct with a struct as a member, then whenever you want to access a specific member of the member struct, you refer to it by the appropriate pointer. I've tried writing something to achieve this but no luck so far.
C++ has (as far as I know) no inbuilt way to autogenerate setter/getter functions.
You might be able to work some macro-magic (with all its pitfalls), otherwise your options are slim.
I can think of following alternatives:
Some IDEs generate get, set methods automatically for the data members of class. I am not sure if it is possible for C++ IDE. But I know that Eclipse IDE for Java does it. You may check once if Eclipse IDE for C++ has this facility.
You may write a short shell script or python script for automatically generating get, set method given a text file containing names and types of variables in each line.
By default all the members of struct are public. So use struct. Or if you decide to use class, then, put all the data members in public section. If you are not doing anything other than simple set, get, then, it might be ok to do so. However, debugging will be tedious in case if you encounter issues with changes in the data members.

CGAL: Modify an extended DCEL fetched from a locate call

I have an Arrangement_2 class, instantiated with a custom Arr_face_extended_dcel to map some data to each cell.
I'd like to find some cells with a locate invocation and change their associated data, but unfortunately locate returns an iterator to some Face_const_handles, so I can't invoke set_data(...) because that would break the constness.
So, my question: is there a way to efficiently change the data mapped to a face found with a locate without resorting to nasty const_casts?
You have to use the overloaded member template functions non_const_handle() of the Arrangement_2 template class. There are 3 versions, which accept Vertex_const_handle, Halfedge_const_handle, and Face_const_handle, respectively; see the manual.
BW, const_cast<> will not work. because, for example, Vertex_const_handle and Vertex_handle are simply different types.