| 1 |
/* used by convertToWiki.d */ |
|---|
| 2 |
|
|---|
| 3 |
import std.stdio; /* for writefln */ |
|---|
| 4 |
|
|---|
| 5 |
char[] wikiCategoryName(char[] oldCategoryName) |
|---|
| 6 |
{ |
|---|
| 7 |
char[] c; |
|---|
| 8 |
|
|---|
| 9 |
switch(oldCategoryName) |
|---|
| 10 |
{ |
|---|
| 11 |
case "Fundamentals": //(20) |
|---|
| 12 |
c = "TutorialFundamentals"; |
|---|
| 13 |
break; |
|---|
| 14 |
|
|---|
| 15 |
case "Intermediate": //(14) |
|---|
| 16 |
c = "TutorialIntermediate"; |
|---|
| 17 |
break; |
|---|
| 18 |
|
|---|
| 19 |
case "Advanced": //(8) |
|---|
| 20 |
c = "TutorialAdvanced"; |
|---|
| 21 |
break; |
|---|
| 22 |
|
|---|
| 23 |
case "Keywords": //(8) |
|---|
| 24 |
c = "KeywordsCategory"; |
|---|
| 25 |
break; |
|---|
| 26 |
|
|---|
| 27 |
case "Arrays": //(5) |
|---|
| 28 |
c = "ArraysCategory"; |
|---|
| 29 |
break; |
|---|
| 30 |
|
|---|
| 31 |
case "Common Errors": //(3) |
|---|
| 32 |
c = "CommonErrorsCategory"; |
|---|
| 33 |
break; |
|---|
| 34 |
|
|---|
| 35 |
case "Delegates": //(8) |
|---|
| 36 |
c = "DelegateCategory"; |
|---|
| 37 |
break; |
|---|
| 38 |
|
|---|
| 39 |
case "Foreach": //(6) |
|---|
| 40 |
c = "ForeachCategory"; |
|---|
| 41 |
break; |
|---|
| 42 |
|
|---|
| 43 |
case "Function Literals": //(2) |
|---|
| 44 |
c = "FunctionLiteralsCategory"; |
|---|
| 45 |
break; |
|---|
| 46 |
|
|---|
| 47 |
case "Handling errors", "Handling Errors": //(2) |
|---|
| 48 |
c = "HandlingErrorsCategory"; |
|---|
| 49 |
break; |
|---|
| 50 |
|
|---|
| 51 |
case "Operator Overloading": //(4) |
|---|
| 52 |
c = "OperatorOverloadingCategory"; |
|---|
| 53 |
break; |
|---|
| 54 |
|
|---|
| 55 |
case "switch / case", "Switch / Case": //(3) |
|---|
| 56 |
c = "SwitchCaseCategory"; |
|---|
| 57 |
break; |
|---|
| 58 |
|
|---|
| 59 |
case "Templates": //(10) |
|---|
| 60 |
c = "TemplatesCategory"; |
|---|
| 61 |
break; |
|---|
| 62 |
|
|---|
| 63 |
case "Versioning": //(3) |
|---|
| 64 |
c = "VersioningCategory"; |
|---|
| 65 |
break; |
|---|
| 66 |
|
|---|
| 67 |
case "DFL": //(7) |
|---|
| 68 |
c = "DflCategory"; |
|---|
| 69 |
break; |
|---|
| 70 |
|
|---|
| 71 |
case "Mango": //(1) |
|---|
| 72 |
c = "MangoCategory"; |
|---|
| 73 |
break; |
|---|
| 74 |
|
|---|
| 75 |
case "Standard Library": //(22) |
|---|
| 76 |
c = "StandardLibraryCategory"; |
|---|
| 77 |
break; |
|---|
| 78 |
|
|---|
| 79 |
case "Windows GUI": //(3) |
|---|
| 80 |
c = "WindowsGuiCategory"; |
|---|
| 81 |
break; |
|---|
| 82 |
|
|---|
| 83 |
default: |
|---|
| 84 |
writefln("Unknown category: %s", oldCategoryName); assert(0); |
|---|
| 85 |
} |
|---|
| 86 |
return c; |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
char[] wikiExampleName(char[] oldCategoryName, char[] e) |
|---|
| 92 |
{ |
|---|
| 93 |
/* e is the example name */ |
|---|
| 94 |
char[] s; |
|---|
| 95 |
|
|---|
| 96 |
switch(oldCategoryName) |
|---|
| 97 |
{ |
|---|
| 98 |
case "Fundamentals": |
|---|
| 99 |
switch(e) |
|---|
| 100 |
{ |
|---|
| 101 |
case "It Compiles": s = "ItCompilesExample"; break; |
|---|
| 102 |
case "Do Something": s = "DoSomethingExample"; break; |
|---|
| 103 |
case "Initializing Variables": s = "InitializingVariablesExample"; break; |
|---|
| 104 |
case "Data Types": s = "DataTypesExample"; break; |
|---|
| 105 |
case "If/Else": s = "IfElseExample"; break; |
|---|
| 106 |
case "The \"for\" Loop": s = "ForLoopExample"; break; |
|---|
| 107 |
case "Variables": s = "VariablesExample"; break; |
|---|
| 108 |
case "Expressions": s = "ExpressionsExample"; break; |
|---|
| 109 |
case "Comments": s = "CommentsExample"; break; |
|---|
| 110 |
case "String Comparison Operators": s = "StringComparisonOperatorsExample"; break; |
|---|
| 111 |
case "Wait": s = "WaitExample"; break; |
|---|
| 112 |
case "Get a number from the user (uses scanf)": s = "ScanfExample"; break; |
|---|
| 113 |
case "Quadratic Equation (getting input and doing calculations)": s = "Quadratic EquationExample"; break; |
|---|
| 114 |
case "Function": s = "FunctionExample"; break; |
|---|
| 115 |
case "Nested Functions": s = "NestedFunctionsExample"; break; |
|---|
| 116 |
case "Struct": s = "StructExample"; break; |
|---|
| 117 |
case "Struct Initialization": s = "StructInitializationExample"; break; |
|---|
| 118 |
case "Class": s = "ClassExample"; break; |
|---|
| 119 |
case "Appending": s = "AppendingExample"; break; |
|---|
| 120 |
case "Assertions": s = "AssertionsExample"; break; |
|---|
| 121 |
case "Unittests": s = "UnittestsExample"; break; |
|---|
| 122 |
case "Getch/Getchar": s = "GetchGetcharExample"; break; |
|---|
| 123 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 124 |
} break; |
|---|
| 125 |
|
|---|
| 126 |
case "Intermediate": |
|---|
| 127 |
switch(e) |
|---|
| 128 |
{ |
|---|
| 129 |
case "Using more than one function": s = "MultipleFunctionExamples"; break; |
|---|
| 130 |
case "Character Initial Values": s = "CharacterInitialValuesExample"; break; |
|---|
| 131 |
case "Module usage": s = "ModuleUsageExample"; break; |
|---|
| 132 |
case "Asm code for splitting ubyte into low and high nibbles": s = "SplittingUbyteWithAsmExample"; break; |
|---|
| 133 |
case "Asm code for finding first occurrence of letter in string": s = "FindingFirstLetterWithAsmExample"; break; |
|---|
| 134 |
case "Towers of Hanoi": s = "TowersOfHanoiExample"; break; |
|---|
| 135 |
case "Factorial": s = "FactorialExample"; break; |
|---|
| 136 |
case "Escape Sequences": s = "EscapeSequencesExample"; break; |
|---|
| 137 |
case "Comments (Reprise)": s = "CommentsExampleTwo"; break; |
|---|
| 138 |
case "Nested Comments": s = "NestedCommentsExample"; break; |
|---|
| 139 |
case "String Literals": s = "StringLiteralsExample"; break; |
|---|
| 140 |
case "String and Number Literals": s = "StringAndNumberLiteralsExample"; break; |
|---|
| 141 |
case "Runtime Type Information (RTTI)": s = "RuntimeTypeInformationExample"; break; |
|---|
| 142 |
case "Statistics": s = "StatisticsExample"; break; |
|---|
| 143 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 144 |
} break; |
|---|
| 145 |
|
|---|
| 146 |
case "Advanced": |
|---|
| 147 |
switch(e) |
|---|
| 148 |
{ |
|---|
| 149 |
case "Printing international characters on Windows": s = "PrintingInternationalCharactersExamples"; break; |
|---|
| 150 |
case "Date Localization using version": s = "DateLocalizationUsingVersionExample"; break; |
|---|
| 151 |
case "Struct \"constructors\"": s = "StructConstructorsExample"; break; |
|---|
| 152 |
case "Application path": s = "ApplicationPathExample"; break; |
|---|
| 153 |
case "Locales": s = "LocalesExample"; break; |
|---|
| 154 |
case "CreateLink using COM": s = "CreateLinkUsingComExample"; break; |
|---|
| 155 |
case "Endless For Loop": s = "EndlessForLoopExample"; break; |
|---|
| 156 |
case "Meta tags (__FILE__, __LINE__, etc.)": s = "MetaTagsExample"; break; |
|---|
| 157 |
case "uudecode": s = "UudecodeExample"; break; |
|---|
| 158 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 159 |
} break; |
|---|
| 160 |
|
|---|
| 161 |
case "Keywords": |
|---|
| 162 |
switch(e) |
|---|
| 163 |
{ |
|---|
| 164 |
case "asm": s = "AsmExample"; break; |
|---|
| 165 |
case "auto": s = "AutoExample"; break; |
|---|
| 166 |
case "alias": s = "AliasExample"; break; |
|---|
| 167 |
case "interface": s = "InterfaceExample"; break; |
|---|
| 168 |
case "dchar": s = "DcharExample"; break; |
|---|
| 169 |
case "final": s = "FinalExample"; break; |
|---|
| 170 |
case "goto": s = "GotoExample"; break; |
|---|
| 171 |
case "return": s = "ReturnExample"; break; |
|---|
| 172 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 173 |
} break; |
|---|
| 174 |
|
|---|
| 175 |
case "Arrays": |
|---|
| 176 |
switch(e) |
|---|
| 177 |
{ |
|---|
| 178 |
case "Delete All Keys From Associative Array": s = "DeleteAllKeysFromAssocArrayExample"; break; |
|---|
| 179 |
case "Static vs dynamic arrays": s = "StaticVsDynamicArraysExample"; break; |
|---|
| 180 |
case "Dealing with strings copy": s = "CopyingStringsExample"; break; |
|---|
| 181 |
case "Arrays of classes": s = "ArraysOfClassesExample"; break; |
|---|
| 182 |
case "Various char arrays": s = "VariousCharArraysExample"; break; |
|---|
| 183 |
case "Dimensioning Static Arrays": s = "DimensioningStaticArraysExample"; break; |
|---|
| 184 |
case "Returning Arrays from Functions": s = "ReturningArraysFromFunctionsExample"; break; |
|---|
| 185 |
case "Using char[][] args": s = "CharArrayArgumentsExample"; break; |
|---|
| 186 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 187 |
} break; |
|---|
| 188 |
|
|---|
| 189 |
case "Common Errors": |
|---|
| 190 |
switch(e) |
|---|
| 191 |
{ |
|---|
| 192 |
case "Increasing the Size of a Dynamic Array": s = "IncreasingSizeOfDynamicArrayExample"; break; |
|---|
| 193 |
case "Using Objects": s = "ObjectErrorExample"; break; |
|---|
| 194 |
case "Printing a Slice from a String": s = "PrintingSliceFromStringExample"; break; |
|---|
| 195 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 196 |
} break; |
|---|
| 197 |
|
|---|
| 198 |
case "Delegates": |
|---|
| 199 |
switch(e) |
|---|
| 200 |
{ |
|---|
| 201 |
case "DelegateTest.d": s = "DelegatesWithinObjectsExample"; break; |
|---|
| 202 |
case "Delegates": s = "DelegateInsteadOfInterfaceExample"; break; |
|---|
| 203 |
case "Proper creation & use of stack delegates": s = "StackDelegatesExample"; break; |
|---|
| 204 |
case "Don't Return a Stack Delegate": s = "DontReturnStackDelegateExample"; break; |
|---|
| 205 |
case "Copyable stack delegates, implemented with structs and classes": s = "CopyableStackDelegatesWithStructsAndClassesExample"; break; |
|---|
| 206 |
case "Copyable stack delegates (with writefln)": s = "CopyableStackDelegatesWithWriteflnExample"; break; |
|---|
| 207 |
case "Delegate 1": s = "DelegateNonStaticNestedFunctionExample"; break; |
|---|
| 208 |
case "Delegate 2": s = "IntFunctionDelegateExample"; break; |
|---|
| 209 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 210 |
} break; |
|---|
| 211 |
|
|---|
| 212 |
case "Foreach": |
|---|
| 213 |
switch(e) |
|---|
| 214 |
{ |
|---|
| 215 |
case "Foreach on a class": s = "ForeachOnClassExample"; break; |
|---|
| 216 |
case "Foreach with an inout": s = "ForeachWithInoutExample"; break; |
|---|
| 217 |
case "Foreach with a string literal": s = "ForeachWithStringLiteralExample"; break; |
|---|
| 218 |
case "Foreach with a char[]": s = "ForeachWithCharArrayExample"; break; |
|---|
| 219 |
case "Foreach with key and value pairs": s = "ForeachKeyValuePairsExample"; break; |
|---|
| 220 |
case "Associative array of strings": s = "ForeachStringArrExample"; break; |
|---|
| 221 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 222 |
} break; |
|---|
| 223 |
|
|---|
| 224 |
case "Function Literals": |
|---|
| 225 |
switch(e) |
|---|
| 226 |
{ |
|---|
| 227 |
case "Function Literal Assignment": s = "FunctionLiteralAssignExample"; break; |
|---|
| 228 |
case "Function Literal / Anonymous Function": s = "AnonymousFunctionExample"; break; |
|---|
| 229 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 230 |
} break; |
|---|
| 231 |
|
|---|
| 232 |
case "Handling errors", "Handling Errors": |
|---|
| 233 |
switch(e) |
|---|
| 234 |
{ |
|---|
| 235 |
case "DBC: basic design by contract": s = "DesignByContractExample"; break; |
|---|
| 236 |
case "Try/Catch/Finally": s = "TryCatchFinallyExample"; break; |
|---|
| 237 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 238 |
} break; |
|---|
| 239 |
|
|---|
| 240 |
case "Operator Overloading": |
|---|
| 241 |
switch(e) |
|---|
| 242 |
{ |
|---|
| 243 |
case "Currency": s = "CurrencyExample"; break; |
|---|
| 244 |
case "Currency (Using with)": s = "CurrencyUsingWithExample"; break; |
|---|
| 245 |
case "opCall": s = "OpCallExample"; break; |
|---|
| 246 |
case "Byte.d": s = "ByteOperatingOverloadExample"; break; |
|---|
| 247 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 248 |
} break; |
|---|
| 249 |
|
|---|
| 250 |
case "switch / case", "Switch / Case": |
|---|
| 251 |
switch(e) |
|---|
| 252 |
{ |
|---|
| 253 |
case "Switch-Case Construct": s = "SwitchCaseExample"; break; |
|---|
| 254 |
case "The Twelve Days of Christmas": s = "TwelveDaysOfChristmasExampleOne"; break; |
|---|
| 255 |
case "The Twelve Days of Christmas (Reprise)": s = "TwelveDaysOfChristmasExampleTwo"; break; |
|---|
| 256 |
|
|---|
| 257 |
/* These are work-arounds for examples that should be identified as in the "Template" category. */ |
|---|
| 258 |
case "Struct Template": s = "StructTemplateExample"; break; |
|---|
| 259 |
case "Interface Template": s = "InterfaceTemplateExample"; break; |
|---|
| 260 |
case "Iterator": s = "IteratorExample"; break; |
|---|
| 261 |
case "Internal templates": s = "InternalTemplatesExample"; break; |
|---|
| 262 |
case "Simple Template": s = "SimpleTemplateExample"; break; |
|---|
| 263 |
case "Template Constructors": s = "TemplateConstructorsExample"; break; |
|---|
| 264 |
case "Template Functions": s = "TemplateFunctionsExample"; break; |
|---|
| 265 |
case "Multiple Inheritance with template 'bolt-ins'": s = "MultipleInheritanceWithTemplateBoltInsExample"; break; |
|---|
| 266 |
case "Variable Arguments": s = "TemplateVariableArgumentsExample"; break; |
|---|
| 267 |
case "Template RTTI": s = "TemplateRttiExample"; break; |
|---|
| 268 |
|
|---|
| 269 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 270 |
} break; |
|---|
| 271 |
|
|---|
| 272 |
case "Templates": |
|---|
| 273 |
switch(e) |
|---|
| 274 |
{ |
|---|
| 275 |
case "Struct Template": s = "StructTemplateExample"; break; |
|---|
| 276 |
case "Interface Template": s = "InterfaceTemplateExample"; break; |
|---|
| 277 |
case "Iterator": s = "IteratorExample"; break; |
|---|
| 278 |
case "Internal templates": s = "InternalTemplatesExample"; break; |
|---|
| 279 |
case "Simple Template": s = "SimpleTemplateExample"; break; |
|---|
| 280 |
case "Template Constructors": s = "TemplateConstructorsExample"; break; |
|---|
| 281 |
case "Template Functions": s = "TemplateFunctionsExample"; break; |
|---|
| 282 |
case "Multiple Inheritance with template 'bolt-ins'": s = "MultipleInheritanceWithTemplateBoltInsExample"; break; |
|---|
| 283 |
case "Variable Arguments": s = "TemplateVariableArgumentsExample"; break; |
|---|
| 284 |
case "Template RTTI": s = "TemplateRttiExample"; break; |
|---|
| 285 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 286 |
} break; |
|---|
| 287 |
|
|---|
| 288 |
case "Versioning": |
|---|
| 289 |
switch(e) |
|---|
| 290 |
{ |
|---|
| 291 |
case "Built-in Versions": s = "BuiltInVersionsExample"; break; |
|---|
| 292 |
case "Using versions to store multiple programs in one file": s = "VersionsToStoreMultipleProgramInOneFileExample"; break; |
|---|
| 293 |
case "Compile time versioning": s = "CompileTimeVersioningExample"; break; |
|---|
| 294 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 295 |
} break; |
|---|
| 296 |
|
|---|
| 297 |
case "DFL": |
|---|
| 298 |
switch(e) |
|---|
| 299 |
{ |
|---|
| 300 |
case "DflMiniCalc": s = "DflMiniCalc"; break; |
|---|
| 301 |
case "Resizable Dialog": s = "DflResizableDialog"; break; |
|---|
| 302 |
case "MiniCalcWithRmb": s = "DflMiniCalcWithRmbExample"; break; |
|---|
| 303 |
case "DflTextBox with Selection reverse video": s = "DflTextBoxWithSelectionExample"; break; |
|---|
| 304 |
case "ToolTips and ListBox having Object entries": s = "DflToolTipsAndListBoxExamples"; break; |
|---|
| 305 |
case "Checkboxes": s = "DflCheckboxesExample"; break; |
|---|
| 306 |
case "Controls": s = "DflControlsExample"; break; |
|---|
| 307 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 308 |
} break; |
|---|
| 309 |
|
|---|
| 310 |
case "Mango": |
|---|
| 311 |
switch(e) |
|---|
| 312 |
{ |
|---|
| 313 |
case "I/O with Mango": s = "IoWithMangoExample"; break; |
|---|
| 314 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 315 |
} break; |
|---|
| 316 |
|
|---|
| 317 |
case "Standard Library": |
|---|
| 318 |
switch(e) |
|---|
| 319 |
{ |
|---|
| 320 |
case "String usage: split and splitlines": s = "SplitAndSplitLinesExample"; break; |
|---|
| 321 |
case "I/O on stdin and stdout streams": s = "StdInStdOutStreamsExample"; break; |
|---|
| 322 |
case "httpHEAD": s = "HttpHeadExample"; break; |
|---|
| 323 |
case "OutBuffer": s = "OutBufferExample"; break; |
|---|
| 324 |
case "Win32 Registry api": s = "WinRegistryApiExample"; break; |
|---|
| 325 |
case "Using the File's \"FileMode\" attribute": s = "FileModeExample"; break; |
|---|
| 326 |
case "Elapsed Time (uses std.date and std.c.time)": s = "ElapsedTimeExample"; break; |
|---|
| 327 |
case "Base64 Decoding": s = "BaseSixtyFourDecodingExample"; break; |
|---|
| 328 |
case "Compile all files into a .lib": s = "CompileAllFilesIntoLibExample"; break; |
|---|
| 329 |
case "writef": s = "WritefExample"; break; |
|---|
| 330 |
case "std.perf": s = "StdPerfExample"; break; |
|---|
| 331 |
case "Make all.html": s = "MakeAllHtmlExample"; break; |
|---|
| 332 |
case "File Input": s = "FileInputExample"; break; |
|---|
| 333 |
case "recls": s = "ReclsExample"; break; |
|---|
| 334 |
case "Regular Expressions": s = "RegularExpressionsExample"; break; |
|---|
| 335 |
case "std.stream readLine": s = "StdStreamReadLineExample"; break; |
|---|
| 336 |
case "Threads": s = "ThreadsExample"; break; |
|---|
| 337 |
case "Variable Arguments using std.stdarg (and std.stdio)": s = "VariableArgumentsUsingStdStdargExample"; break; |
|---|
| 338 |
case "Variadic Functions": s = "VariadicFunctionsExample"; break; |
|---|
| 339 |
case "Variable Arguments": s = "VariableArgumentsExample"; break; |
|---|
| 340 |
case "zip": s = "ZipExample"; break; |
|---|
| 341 |
case "Zlib": s = "ZlibExample"; break; |
|---|
| 342 |
case "Unzip using std.zip": s = "UnzipUsingStdZipExample"; break; |
|---|
| 343 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 344 |
} break; |
|---|
| 345 |
|
|---|
| 346 |
case "Windows GUI": |
|---|
| 347 |
switch(e) |
|---|
| 348 |
{ |
|---|
| 349 |
case "MiniCalc": s = "MiniCalcExample"; break; |
|---|
| 350 |
case "TreeView": s = "TreeViewExample"; break; |
|---|
| 351 |
case "MiniCalc - RestorePosition": s = "MiniCalcRestorePositionExample"; break; |
|---|
| 352 |
default: writefln("Unknown example: %s", e); assert(0); |
|---|
| 353 |
} break; |
|---|
| 354 |
default: writefln("Unknown category: %s", oldCategoryName); assert(0); |
|---|
| 355 |
} |
|---|
| 356 |
return s; |
|---|
| 357 |
} |
|---|