-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parseTypeName method to CommandParser #321
Add parseTypeName method to CommandParser #321
Conversation
src/stdfblib/ita/CommandParser.cpp
Outdated
return -1; | ||
} | ||
std::string result = paTypeName.substr(0, endIndex); | ||
if(!paIdentifier.pushBack(CStringDictionary::getInstance().insert(result.c_str()))){ |
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.
I would suggest using
4diac-forte/src/core/stringdict.h
Line 60 in d1afbde
TStringId insert(const char *paStr, size_t paStrSize); |
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.
This is also useful with the string_views, to set the correct string length
src/stdfblib/ita/CommandParser.cpp
Outdated
@@ -338,6 +338,18 @@ int CommandParser::parseIdentifier(char *paIdentifierStart, forte::core::TNameId | |||
return -1; | |||
} | |||
|
|||
int CommandParser::parseTypeName(std::string paTypeName, forte::core::TNameIdentifier &paIdentifier){ |
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.
Please note that this will allocate and copy the entire buffer until the end each time this is called. Maybe you could use a std::string_view instead?
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.
Yeah, that makes sense. I replaced the strings with string_view objects. Thanks for pointing that out.
745f3f6
to
bce68f3
Compare
Use parseTypeName to parse the CreateFB request instead of parseIdentifier