-
Notifications
You must be signed in to change notification settings - Fork 34
Fix#314 master #336
Fix#314 master #336
Conversation
|
This is the equivalent of the following commit from tango-9-lts branch for the master branch: |
Ingvord
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it is an utility method that is useful for any C++ type enum. I would put it into a dedicated header file as a template utility function, smth like
template<typename Enum, typename EnumNames>
Enum enum_value_of(const std::string& name){
//TODO ...
}| event = (*argin)[3]; | ||
|
|
||
| // | ||
| // Check event type validity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever there is a comment in the code describing what it is doing - extract a method.
src/server/eventcmds.cpp
Outdated
| size_t nb_event_type = sizeof(EventName)/sizeof(char *); | ||
| bool found = false; | ||
|
|
||
| for (size_t loop = 0;loop < nb_event_type;loop++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop should be renamed to i
src/server/eventcmds.cpp
Outdated
| } | ||
| } | ||
|
|
||
| if (found == false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be if(!found)
src/server/eventcmds.cpp
Outdated
| stringstream ss; | ||
| ss << "The event type you sent (" << event << ") is not valid event type"; | ||
|
|
||
| Except::throw_exception(API_WrongNumberOfArgs,ss.str(),"DServer::zmq_event_subscription_change"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to
Except::throw_exception(
API_WrongNumberOfArgs,
"The event type you sent (" + event + ") is not valid event type", //TODO name valid types
"DServer::zmq_event_subscription_change");|
I'm sorry, I don't understand the following comment:
Can you be more explicit, please? To what part of the code are you referring to for this comment? |
|
It was meant that the the added code should be extracted into a method. It is not urgent... just a remark for the future refactoring.
|
Ingvord
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me!
| string check_event = event; | ||
| transform(check_event.begin(),check_event.end(),check_event.begin(),::tolower); | ||
|
|
||
| string::size_type pos_check = check_event.find(EVENT_COMPAT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string::size_type can be replaced with auto
No description provided.