geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3288) Replace char* with std::string
Date Wed, 29 Nov 2017 22:46:00 GMT

    [ https://issues.apache.org/jira/browse/GEODE-3288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16271698#comment-16271698
] 

ASF GitHub Bot commented on GEODE-3288:
---------------------------------------

dgkimura commented on a change in pull request #160: GEODE-3288: Converts char* to std::string
on public API.
URL: https://github.com/apache/geode-native/pull/160#discussion_r153938512
 
 

 ##########
 File path: cppcache/src/DiskPolicyType.cpp
 ##########
 @@ -18,23 +18,29 @@
 #include <geode/DiskPolicyType.hpp>
 #include "ace/OS.h"
 
-using namespace apache::geode::client;
+namespace apache {
+namespace geode {
+namespace client {
 
-const char* DiskPolicyType::names[] = {"none", "overflows", "persist", nullptr};
+const std::string DiskPolicyType::names[] = {"none", "overflows", "persist"};
 
-const char* DiskPolicyType::fromOrdinal(const uint8_t ordinal) {
-  if (ordinal > DiskPolicyType::PERSIST) return names[DiskPolicyType::NONE];
-  return names[ordinal];
-}
-
-DiskPolicyType::PolicyType DiskPolicyType::fromName(const char* name) {
-  uint32_t i = 0;
-  while ((names[i] != nullptr) ||
-         (i <= static_cast<uint32_t>(DiskPolicyType::PERSIST))) {
-    if (name && names[i] && ACE_OS::strcasecmp(names[i], name) == 0) {
-      return static_cast<DiskPolicyType::PolicyType>(i);
+DiskPolicyType::PolicyType DiskPolicyType::fromName(const std::string& name) {
+  for (int i = NONE; i <= PERSIST; i++) {
+    if (names[i] == name) {
+      return static_cast<PolicyType>(i);
     }
-    ++i;
   }
   return DiskPolicyType::NONE;
 }
+
+const std::string& DiskPolicyType::fromOrdinal(const uint8_t ordinal) {
+  if (NONE <= ordinal && ordinal <= PERSIST) {
+    return names[ordinal];
+  }
+
+  return names[NONE];
 
 Review comment:
   Created ticket here: https://issues.apache.org/jira/browse/GEODE-4032

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Replace char* with std::string
> ------------------------------
>
>                 Key: GEODE-3288
>                 URL: https://issues.apache.org/jira/browse/GEODE-3288
>             Project: Geode
>          Issue Type: Improvement
>          Components: native client
>            Reporter: Ernest Burghardt
>
> In all public API headers



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message