MCPcopy Create free account
hub / github.com/glideapps/quicktype / cppNameStyle

Function cppNameStyle

src/Language/CPlusPlus.ts:91–135  ·  view source on GitHub ↗
(namingStyle: NamingStyle)

Source from the content-addressed store, hash-verified

89const legalizeName = legalizeCharacters(cp => isAscii(cp) && isLetterOrUnderscoreOrDigit(cp));
90
91function cppNameStyle(namingStyle: NamingStyle): (rawName: string) => string {
92 let separator: string;
93 let firstWordStyle: WordStyle;
94 let restWordStyle: WordStyle;
95 let firstWordAcronymStyle: WordStyle;
96 let restAcronymStyle: WordStyle;
97
98 if (namingStyle === "pascal" || namingStyle === "camel") {
99 separator = "";
100 restWordStyle = firstUpperWordStyle;
101 restAcronymStyle = allUpperWordStyle;
102 } else {
103 separator = "_";
104 }
105 switch (namingStyle) {
106 case "pascal":
107 firstWordStyle = firstWordAcronymStyle = firstUpperWordStyle;
108 break;
109 case "camel":
110 firstWordStyle = firstWordAcronymStyle = allLowerWordStyle;
111 break;
112 case "underscore":
113 firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allLowerWordStyle;
114 break;
115 case "upper-underscore":
116 firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allUpperWordStyle;
117 break;
118 default:
119 return assertNever(namingStyle);
120 }
121
122 return (original: string) => {
123 const words = splitIntoWords(original);
124 return combineWords(
125 words,
126 legalizeName,
127 firstWordStyle,
128 restWordStyle,
129 firstWordAcronymStyle,
130 restAcronymStyle,
131 separator,
132 isLetterOrUnderscore
133 );
134 };
135}
136
137const keywords = [
138 "alignas",

Callers 1

constructorMethod · 0.85

Calls 3

assertNeverFunction · 0.90
splitIntoWordsFunction · 0.90
combineWordsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…