Skip to content

Commit a4a3484

Browse files
committed
[C++]: Add sbe.cpp.namespaces.collapse system property
The property optionally (if set to `true`) reverts to backward-compatible collapsed namespaces in generated stubs
1 parent c538c29 commit a4a3484

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sbe-tool/src/main/java/uk/co/real_logic/sbe/SbeTool.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ public class SbeTool
121121
*/
122122
public static final String JAVA_GENERATE_INTERFACES = "sbe.java.generate.interfaces";
123123

124+
/**
125+
* Boolean system property to turn on or off collapsing of nested namespaces in generated C++ stubs. Defaults to false.
126+
*/
127+
public static final String CPP_NAMESPACES_COLLAPSE = "sbe.cpp.namespaces.collapse";
128+
124129
/**
125130
* Package in which the generated Java interfaces will be placed.
126131
*/

sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/Ir.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import org.agrona.Verify;
1919

20+
import uk.co.real_logic.sbe.SbeTool;
21+
2022
import java.util.*;
2123
import java.util.regex.Pattern;
2224

@@ -66,7 +68,14 @@ public Ir(
6668
this.semanticVersion = semanticVersion;
6769
this.headerStructure = new HeaderStructure(new ArrayList<>(headerTokens));
6870

69-
this.namespaces = Pattern.compile("\\.").split(namespaceName == null ? packageName : namespaceName);
71+
if (Boolean.getBoolean(SbeTool.CPP_NAMESPACES_COLLAPSE))
72+
{
73+
this.namespaces = new String[]{ (namespaceName == null ? packageName : namespaceName).replace(".", "_") };
74+
}
75+
else
76+
{
77+
this.namespaces = Pattern.compile("\\.").split(namespaceName == null ? packageName : namespaceName);
78+
}
7079
}
7180

7281
/**

0 commit comments

Comments
 (0)