You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/29 16:36:00 UTC

[jira] [Commented] (AVRO-2165) Use nested namespaces in C++ instead of :: separated ones

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

ASF GitHub Bot commented on AVRO-2165:
--------------------------------------

thiru-apache closed pull request #275: AVRO-2165 Change namespace definitions in C++. Use nested namespaces instead of…
URL: https://github.com/apache/avro/pull/275
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/c++/impl/avrogencpp.cc b/lang/c++/impl/avrogencpp.cc
index a44fe7dfe..149debd0f 100644
--- a/lang/c++/impl/avrogencpp.cc
+++ b/lang/c++/impl/avrogencpp.cc
@@ -33,6 +33,8 @@
 #include <boost/random/uniform_int.hpp>
 #include <boost/random/variate_generator.hpp>
 
+#include <boost/algorithm/string_regex.hpp>
+
 #include "Compiler.hh"
 #include "ValidSchema.hh"
 #include "NodeImpl.hh"
@@ -721,8 +723,14 @@ void CodeGen::generate(const ValidSchema& schema)
         << "#include \"" << includePrefix_ << "Decoder.hh\"\n"
         << "\n";
 
+    vector<string> nsVector;
     if (! ns_.empty()) {
-        os_ << "namespace " << ns_ << " {\n";
+        boost::algorithm::split_regex(nsVector, ns_, boost::regex("::"));
+        for (vector<string>::const_iterator it =
+            nsVector.begin();
+            it != nsVector.end(); ++it) {
+            os_ << "namespace " << *it << " {\n";
+        }
         inNamespace_ = true;
     }
 
@@ -745,7 +753,11 @@ void CodeGen::generate(const ValidSchema& schema)
 
     if (! ns_.empty()) {
         inNamespace_ = false;
-        os_ << "}\n";
+        for (vector<string>::const_iterator it =
+            nsVector.begin();
+            it != nsVector.end(); ++it) {
+            os_ << "}\n";
+        }
     }
 
     os_ << "namespace avro {\n";


 

----------------------------------------------------------------
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


> Use nested namespaces in C++ instead of :: separated ones
> ---------------------------------------------------------
>
>                 Key: AVRO-2165
>                 URL: https://issues.apache.org/jira/browse/AVRO-2165
>             Project: Avro
>          Issue Type: Improvement
>          Components: c++
>    Affects Versions: 1.8.2
>            Reporter: Thiruvalluvan M. G.
>            Assignee: Karl Wallner
>            Priority: Minor
>             Fix For: 1.8.3
>
>
> Namespace definitions using colons are supported since C++17 ([http://en.cppreference.com/w/cpp/language/namespace]).
> This fix makes the library usable for C++11 and avoids compiler error "Compiler Error C2429" ([https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2429]).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)