-
Notifications
You must be signed in to change notification settings - Fork 90
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
Schema accessor #1393
base: sdf14
Are you sure you want to change the base?
Schema accessor #1393
Conversation
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.
Thanks for working on this! I have a few comments that should be easy to address.
Regarding testing, I don't think we should create new tests for this, but one way we can make sure it's working is by using SchemaFile()
instead of hard coded file names in ToElement
functions. Perhaps you can update your script to make that change as well?
.DS_Store
Outdated
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.
Remove this file
src/Actor.cc
Outdated
{ | ||
static const std::string* kSchemaFile = new std::string("actor.sdf"); | ||
return *kSchemaFile; | ||
} |
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 you add a newline after the }
? (see https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline)
src/Actor.cc
Outdated
const std::string& Actor::SchemaFile() | ||
{ | ||
static const std::string* kSchemaFile = new std::string("actor.sdf"); | ||
return *kSchemaFile; | ||
} |
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.
According to our style guide, this is sort of a last resort way to create variables with static storage. After reading through https://abseil.io/tips/140#string-view-mistake, I think the recommended way is:
const std::string& Actor::SchemaFile() | |
{ | |
static const std::string* kSchemaFile = new std::string("actor.sdf"); | |
return *kSchemaFile; | |
} | |
inline std::string_view Actor::SchemaFile() | |
{ | |
static const char kSchemaFile[] = "actor.sdf"; | |
return kSchemaFile; | |
} |
878edee
to
2a1d038
Compare
🎉 New feature
Closes #1376
Summary
Test it
Tests can be done manually as mentioned by the OP in #1376 in his code example.
I could also add tests in the DOM element unit tests, but that might be overkill because the values are hard-coded.
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.