From 0d377698eaee9e31cf7ef79f20664454c3de8d5b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 10 Dec 2021 12:23:18 +0200 Subject: Add support for `ucc` (upper-camel-case) value in --function-naming option --- xsd/doc/xsd-epilogue.1 | 3 +++ xsd/doc/xsd-epilogue.xhtml | 19 +++++++++++-------- xsd/xsd/cxx/tree/name-processor.cxx | 26 ++++++++++++++++++++++++++ xsd/xsd/cxx/tree/options.cli | 6 +++--- xsd/xsd/cxx/tree/validator.cxx | 2 +- 5 files changed, 44 insertions(+), 12 deletions(-) (limited to 'xsd') 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 @@

Similarly, the --function-naming option specifies the convention that should be used for naming C++ functions. Possible values for this option are knr - (default), lcc, and java. The - knr value (stands for K&R) signifies - the standard, lower-case naming convention with the underscore - used as a word delimiter, for example: foo(), - foo_bar(). The lcc 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(). + (default), lcc, ucc, and + java. The knr value (stands + for K&R) signifies the standard, lower-case naming convention + with the underscore used as a word delimiter, for example: + foo(), foo_bar(). The lcc + 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 + 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 java naming convention is similar to the lower-camel-case one except that accessor functions are prefixed with get, 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 { "