- Timestamp:
- Jan 19, 2019, 6:12:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/7dtd-server-fixes/src/JSON/JSONNumber.cs
r325 r351 6 6 private readonly double value; 7 7 8 public JSONNumber (double value) {9 this.value =value;8 public JSONNumber (double _value) { 9 value = _value; 10 10 } 11 11 … … 18 18 } 19 19 20 public override void ToString (StringBuilder stringBuilder, bool prettyPrint = false, intcurrentLevel = 0) {21 stringBuilder.Append (value.ToCultureInvariantString ());20 public override void ToString (StringBuilder _stringBuilder, bool _prettyPrint = false, int _currentLevel = 0) { 21 _stringBuilder.Append (value.ToCultureInvariantString ()); 22 22 } 23 23 24 public static JSONNumber Parse (string json, ref intoffset) {24 public static JSONNumber Parse (string _json, ref int _offset) { 25 25 //Log.Out ("ParseNumber enter (" + offset + ")"); 26 26 StringBuilder sbNum = new StringBuilder (); … … 28 28 bool hasDec = false; 29 29 bool hasExp = false; 30 while ( offset <json.Length) {31 if ( json [offset] >= '0' && json [offset] <= '9') {30 while (_offset < _json.Length) { 31 if (_json [_offset] >= '0' && _json [_offset] <= '9') { 32 32 if (hasExp) { 33 sbExp.Append ( json [offset]);33 sbExp.Append (_json [_offset]); 34 34 } else { 35 sbNum.Append ( json [offset]);35 sbNum.Append (_json [_offset]); 36 36 } 37 } else if ( json [offset] == '.') {37 } else if (_json [_offset] == '.') { 38 38 if (hasExp) { 39 39 throw new MalformedJSONException ("Decimal separator in exponent"); … … 50 50 sbNum.Append ('.'); 51 51 hasDec = true; 52 } else if ( json [offset] == '-') {52 } else if (_json [_offset] == '-') { 53 53 if (hasExp) { 54 54 if (sbExp.Length > 0) { … … 56 56 } 57 57 58 sbExp.Append ( json [offset]);58 sbExp.Append (_json [_offset]); 59 59 } else { 60 60 if (sbNum.Length > 0) { … … 62 62 } 63 63 64 sbNum.Append ( json [offset]);64 sbNum.Append (_json [_offset]); 65 65 } 66 } else if ( json [offset] == 'e' || json [offset] == 'E') {66 } else if (_json [_offset] == 'e' || _json [_offset] == 'E') { 67 67 if (hasExp) { 68 68 throw new MalformedJSONException ("Multiple exponential markers in number found"); … … 75 75 sbExp = new StringBuilder (); 76 76 hasExp = true; 77 } else if ( json [offset] == '+') {77 } else if (_json [_offset] == '+') { 78 78 if (hasExp) { 79 79 if (sbExp.Length > 0) { … … 81 81 } 82 82 83 sbExp.Append ( json [offset]);83 sbExp.Append (_json [_offset]); 84 84 } else { 85 85 throw new MalformedJSONException ("Positive sign in mantissa found"); … … 104 104 } 105 105 106 offset++;106 _offset++; 107 107 } 108 108
Note:
See TracChangeset
for help on using the changeset viewer.