[
https://issues.apache.org/jira/browse/GEODE-3019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16086293#comment-16086293
]
ASF GitHub Bot commented on GEODE-3019:
---------------------------------------
Github user pivotal-jbarrett commented on a diff in the pull request:
https://github.com/apache/geode-native/pull/107#discussion_r127312259
--- Diff: src/cppcache/src/StructSetImpl.cpp ---
@@ -78,13 +78,12 @@ int32_t StructSetImpl::getFieldIndex(const char*
fieldname) {
}
}
-const char* StructSetImpl::getFieldName(int32_t index) {
- for (std::map<std::string, int32_t>::iterator iter =
- m_fieldNameIndexMap.begin();
- iter != m_fieldNameIndexMap.end(); ++iter) {
- if (iter->second == index) return iter->first.c_str();
+const std::string& StructSetImpl::getFieldName(int32_t index) {
+ for (const auto& iter : m_fieldNameIndexMap) {
+ if (iter.second == index) return (iter.first);
}
- return nullptr;
+
+ throw OutOfRangeException("Struct: fieldName not found.");
--- End diff --
I am more keen myself on using `std::exception`s rather than our own.
Thoughts?
> Refactor Struct
> ---------------
>
> Key: GEODE-3019
> URL: https://issues.apache.org/jira/browse/GEODE-3019
> Project: Geode
> Issue Type: Task
> Components: native client
> Reporter: Jacob S. Barrett
>
> Refactor Struct (geode/Struct.hpp):
> * Replace {{char *}} with {{std::string}}
> * Replace {{m_fieldname}} type with {{std::unordered_map<std::string,
> int32_t>}}
> * Add vector for index to field name lookup.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)