Skip to content

Commit

Permalink
feat[cpp]: compatible field of inside protocol class
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Oct 15, 2023
1 parent 93eecb4 commit b646d28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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());
}

/**
* 解析协议的路径
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b646d28

Please sign in to comment.