From b646d286e63f74a3e406d395e238f311b97f92b9 Mon Sep 17 00:00:00 2001 From: godotg Date: Sun, 15 Oct 2023 11:29:21 +0800 Subject: [PATCH] feat[cpp]: compatible field of inside protocol class --- .../protocol/generate/GenerateProtocolPath.java | 14 +++++++------- .../protocol/serializer/cpp/GenerateCppUtils.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java index 3c713b277..2e387c489 100644 --- a/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java +++ b/protocol/src/main/java/com/zfoo/protocol/generate/GenerateProtocolPath.java @@ -99,6 +99,13 @@ public static String getProtocolPath(short protocolId) { return protocolPath.replaceAll(StringUtils.PERIOD_REGEX, StringUtils.SLASH); } + /** + * 获取协议生成的首字母大写的路径 + */ + public static String getCapitalizeProtocolPath(short protocolId) { + return StringUtils.joinWith(StringUtils.SLASH, Arrays.stream(getProtocolPath(protocolId).split(StringUtils.SLASH)).map(it -> StringUtils.capitalize(it)).toArray()); + } + public static String getRelativePath(short protocolId, short relativeProtocolId) { // 不是折叠协议的话,protocolPathMap一定是空,这里返回“”,上层会解析为同一个文件下 if (CollectionUtils.isEmpty(protocolPathMap)) { @@ -125,13 +132,6 @@ public static String getRelativePath(short protocolId, short relativeProtocolId) return builder.toString(); } - /** - * 获取协议生成的首字母大写的路径 - */ - public static String getCapitalizeProtocolPath(short protocolId) { - return StringUtils.joinWith(StringUtils.SLASH, Arrays.stream(getProtocolPath(protocolId).split(StringUtils.SLASH)).map(it -> StringUtils.capitalize(it)).toArray()); - } - /** * 解析协议的路径 * diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java b/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java index 6e490bb50..c7aba749d 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/cpp/GenerateCppUtils.java @@ -143,7 +143,7 @@ public static void createCppProtocolFile(ProtocolRegistration registration) thro var protocolOutputPath = StringUtils.format("{}/{}/{}.h" , GenerateCppUtils.protocolOutputPath - , GenerateProtocolPath.getCapitalizeProtocolPath(protocolId) + , GenerateProtocolPath.getProtocolPath(protocolId) , protocolClazzName); FileUtils.writeStringToFile(new File(protocolOutputPath), protocolTemplate, true); }