C ++ style: helper functions for a class

I am trying to create a redis credit. I have a class Querythat handles Redis requests. Each initial query word is a redis command, for example: GET fooor SET foo 123. When analyzing each request, I want to call a function that will analyze the request in accordance with the original word.

I created a string std::map<std::string, std::string(*)(std::string)>from a string to a function pointer.

//So when I get a query like:
query = "GET foo";

//I extract get in a string query_type. 
//And use this to do the required work on the query:
query_handler[query_type](query);

//This should call the function associated with "GET"

Now I have a question, where should these functions go? Within the class definition? Or a separate namespace? Or somewhere else?

+4
source share

All Articles