| 5 | namespace Compiler |
| 6 | { |
| 7 | void IndentString(StringBuilder & sb, String src) |
| 8 | { |
| 9 | int indent = 0; |
| 10 | bool beginTrim = true; |
| 11 | for (int c = 0; c < src.Length(); c++) |
| 12 | { |
| 13 | auto ch = src[c]; |
| 14 | if (ch == '\n') |
| 15 | { |
| 16 | sb << "\n"; |
| 17 | |
| 18 | beginTrim = true; |
| 19 | } |
| 20 | else |
| 21 | { |
| 22 | if (beginTrim) |
| 23 | { |
| 24 | while (c < src.Length() - 1 && (src[c] == '\t' || src[c] == '\n' || src[c] == '\r' || src[c] == ' ')) |
| 25 | { |
| 26 | c++; |
| 27 | ch = src[c]; |
| 28 | } |
| 29 | for (int i = 0; i < indent - 1; i++) |
| 30 | sb << '\t'; |
| 31 | if (ch != '}' && indent > 0) |
| 32 | sb << '\t'; |
| 33 | beginTrim = false; |
| 34 | } |
| 35 | |
| 36 | if (ch == '{') |
| 37 | indent++; |
| 38 | else if (ch == '}') |
| 39 | indent--; |
| 40 | if (indent < 0) |
| 41 | indent = 0; |
| 42 | |
| 43 | sb << ch; |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | ShaderChoiceValue ShaderChoiceValue::Parse(String str) |
| 48 | { |
| 49 | return ShaderChoiceValue(str); |