Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/generate-names.h
1 /* 2 * Copyright 2016 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_GENERATE_NAMES_H_ 18 #define WABT_GENERATE_NAMES_H_ 19 20 #include "wabt/common.h" 21 22 namespace wabt { 23 24 struct Module; 25 26 enum NameOpts { 27 None = 0, 28 AlphaNames = 1 << 0, 29 }; 30 31 Result GenerateNames(struct Module*, NameOpts opts = NameOpts::None); 32 33 inline std::string IndexToAlphaName(Index index) { 34 std::string s; 35 do { 36 // For multiple chars, put most frequently changing char first. 37 s += 'a' + (index % 26); 38 index /= 26; 39 // Continue remaining sequence with 'a' rather than 'b'. 40 } while (index--); 41 return s; 42 } 43 44 } // namespace wabt 45 46 #endif /* WABT_GENERATE_NAMES_H_ */