summaryrefslogtreecommitdiff
path: root/xsd
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-12-10 12:23:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-12-10 12:23:18 +0200
commit0d377698eaee9e31cf7ef79f20664454c3de8d5b (patch)
tree53b772e548b4c9265c67569e2567d2c657fdb7c8 /xsd
parent87140ae9f841798752ae4e5422698a4090f16329 (diff)
Add support for `ucc` (upper-camel-case) value in --function-naming option
Diffstat (limited to 'xsd')
-rw-r--r--xsd/doc/xsd-epilogue.13
-rw-r--r--xsd/doc/xsd-epilogue.xhtml19
-rw-r--r--xsd/xsd/cxx/tree/name-processor.cxx26
-rw-r--r--xsd/xsd/cxx/tree/options.cli6
-rw-r--r--xsd/xsd/cxx/tree/validator.cxx2
5 files changed, 44 insertions, 12 deletions
diff --git a/xsd/doc/xsd-epilogue.1 b/xsd/doc/xsd-epilogue.1
index 192880c..a37da89 100644
--- a/xsd/doc/xsd-epilogue.1
+++ b/xsd/doc/xsd-epilogue.1
@@ -65,6 +65,9 @@ The
value (stands for lower-camel-case) signifies a naming convention where the
first letter of each word except the first is capitalized, for example: foo(),
fooBar(). The
+.B ucc
+value (stands for upper-camel-case) signifies a naming convention where the
+first letter of each word is capitalized, for example: Foo(), FooBar(). The
.B java
naming convention is similar to the lower-camel-case one except that accessor
functions are prefixed with get, modifier functions are prefixed with set,
diff --git a/xsd/doc/xsd-epilogue.xhtml b/xsd/doc/xsd-epilogue.xhtml
index aef0418..632b2d9 100644
--- a/xsd/doc/xsd-epilogue.xhtml
+++ b/xsd/doc/xsd-epilogue.xhtml
@@ -38,14 +38,17 @@
<p>Similarly, the <code><b>--function-naming</b></code> option
specifies the convention that should be used for naming C++
functions. Possible values for this option are <code><b>knr</b></code>
- (default), <code><b>lcc</b></code>, and <code><b>java</b></code>. The
- <code><b>knr</b></code> value (stands for K&amp;R) signifies
- the standard, lower-case naming convention with the underscore
- used as a word delimiter, for example: <code>foo()</code>,
- <code>foo_bar()</code>. The <code><b>lcc</b></code> value
- (stands for lower-camel-case) signifies a naming convention
- where the first letter of each word except the first is
- capitalized, for example: <code>foo()</code>, <code>fooBar()</code>.
+ (default), <code><b>lcc</b></code>, <code><b>ucc</b></code>, and
+ <code><b>java</b></code>. The <code><b>knr</b></code> value (stands
+ for K&amp;R) signifies the standard, lower-case naming convention
+ with the underscore used as a word delimiter, for example:
+ <code>foo()</code>, <code>foo_bar()</code>. The <code><b>lcc</b></code>
+ value (stands for lower-camel-case) signifies a naming convention
+ where the first letter of each word except the first is capitalized,
+ for example: <code>foo()</code>, <code>fooBar()</code>. The
+ <code><b>ucc</b></code> value (stands for upper-camel-case) signifies
+ a naming convention where the first letter of each word is capitalized,
+ for example: <code>Foo()</code>, <code>FooBar()</code>.
The <code><b>java</b></code> naming convention is similar to
the lower-camel-case one except that accessor functions are prefixed
with <code>get</code>, modifier functions are prefixed
diff --git a/xsd/xsd/cxx/tree/name-processor.cxx b/xsd/xsd/cxx/tree/name-processor.cxx
index 6ca616e..325870a 100644
--- a/xsd/xsd/cxx/tree/name-processor.cxx
+++ b/xsd/xsd/cxx/tree/name-processor.cxx
@@ -129,6 +129,12 @@ namespace CXX
accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1\\u$2\\u$3/");
accessor_regex.push_back ("/([^,]+)/\\l$1/");
}
+ else if (fn == "ucc")
+ {
+ accessor_regex.push_back ("/([^,]+),([^,]+)/\\u$1\\u$2/");
+ accessor_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\u$1\\u$2\\u$3/");
+ accessor_regex.push_back ("/([^,]+)/\\u$1/");
+ }
else
{
// Java: add get.
@@ -169,6 +175,11 @@ namespace CXX
modifier_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/");
modifier_regex.push_back ("/([^,]+)/\\l$1/");
}
+ else if (fn == "ucc")
+ {
+ modifier_regex.push_back ("/([^,]+),([^,]+)/\\u$1\\u$2/");
+ modifier_regex.push_back ("/([^,]+)/\\u$1/");
+ }
else
{
// Java: add set.
@@ -202,6 +213,10 @@ namespace CXX
{
parser_regex.push_back ("/(.+)/\\l$1/");
}
+ else if (fn == "ucc")
+ {
+ parser_regex.push_back ("/(.+)/\\u$1/");
+ }
else if (fn == "java")
{
// Java: add parse.
@@ -219,6 +234,10 @@ namespace CXX
{
serializer_regex.push_back ("/(.+)/\\l$1/");
}
+ else if (fn == "ucc")
+ {
+ serializer_regex.push_back ("/(.+)/\\u$1/");
+ }
else if (fn == "java")
{
// Java: add serialize.
@@ -244,6 +263,11 @@ namespace CXX
const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\l$1_\\u$2_\\u$3/");
const_regex.push_back ("/([^,]+),([^,]+)/\\l$1\\u$2/");
}
+ else if (fn == "ucc")
+ {
+ const_regex.push_back ("/([^,]+),([^,]+),([^,]+)/\\u$1_\\u$2_\\u$3/");
+ const_regex.push_back ("/([^,]+),([^,]+)/\\u$1\\u$2/");
+ }
else
{
// Java: all uppercase.
@@ -2173,6 +2197,8 @@ namespace CXX
if (fn == "knr")
n.context ().set ("tree-node-key", String ("tree_node_key"));
+ else if (fn == "ucc")
+ n.context ().set ("tree-node-key", String ("TreeNodeKey"));
else
n.context ().set ("tree-node-key", String ("treeNodeKey"));
diff --git a/xsd/xsd/cxx/tree/options.cli b/xsd/xsd/cxx/tree/options.cli
index 1f0b23f..0230429 100644
--- a/xsd/xsd/cxx/tree/options.cli
+++ b/xsd/xsd/cxx/tree/options.cli
@@ -257,9 +257,9 @@ namespace CXX
{
"<style>",
"Specify the function naming convention that should be used in the
- generated code. Valid styles are \cb{knr} (default), \cb{lcc}, and
- \cb{java}. See the NAMING CONVENTION section below for more
- information."
+ generated code. Valid styles are \cb{knr} (default), \cb{lcc},
+ \cb{ucc}, and \cb{java}. See the NAMING CONVENTION section below
+ for more information."
};
NarrowStrings --type-regex
diff --git a/xsd/xsd/cxx/tree/validator.cxx b/xsd/xsd/cxx/tree/validator.cxx
index 46deb6c..9785560 100644
--- a/xsd/xsd/cxx/tree/validator.cxx
+++ b/xsd/xsd/cxx/tree/validator.cxx
@@ -587,7 +587,7 @@ namespace CXX
NarrowString fn (ops.function_naming ());
- if (fn != "knr" && fn != "lcc" && fn != "java")
+ if (fn != "knr" && fn != "lcc" && fn != "ucc" && fn != "java")
{
wcerr << "error: unknown function naming style specified: '" <<
fn.c_str () << "'" << endl;