- Timestamp:
- Sep 4, 2018, 1:00:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/JSON/JSONBoolean.cs
r309 r325 1 using System;2 1 using System.Text; 3 2 4 namespace AllocsFixes.JSON 5 { 6 public class JSONBoolean : JSONValue 7 { 8 private bool value; 3 namespace AllocsFixes.JSON { 4 public class JSONBoolean : JSONValue { 5 private readonly bool value; 9 6 10 public JSONBoolean (bool value) 11 { 7 public JSONBoolean (bool value) { 12 8 this.value = value; 13 9 } 14 10 15 public bool GetBool () 16 { 11 public bool GetBool () { 17 12 return value; 18 13 } 19 14 20 public override void ToString (StringBuilder stringBuilder, bool prettyPrint = false, int currentLevel = 0) 21 { 15 public override void ToString (StringBuilder stringBuilder, bool prettyPrint = false, int currentLevel = 0) { 22 16 stringBuilder.Append (value ? "true" : "false"); 23 17 } 24 18 25 public static JSONBoolean Parse (string json, ref int offset) 26 { 19 public static JSONBoolean Parse (string json, ref int offset) { 27 20 //Log.Out ("ParseBool enter (" + offset + ")"); 28 21 … … 31 24 offset += 4; 32 25 return new JSONBoolean (true); 33 } else if (json.Substring (offset, 5).Equals ("false")) { 26 } 27 28 if (json.Substring (offset, 5).Equals ("false")) { 34 29 //Log.Out ("JSON:Parsed Bool: false"); 35 30 offset += 5; 36 31 return new JSONBoolean (false); 37 } else {38 throw new MalformedJSONException ("No valid boolean found");39 32 } 33 34 throw new MalformedJSONException ("No valid boolean found"); 40 35 } 41 42 36 } 43 37 } 44
Note:
See TracChangeset
for help on using the changeset viewer.