diff Implab/Formats/JSON/StringTranslator.cs @ 180:c32688129f14 ref20160224

refactoring complete, JSONParser rewritten
author cin
date Thu, 24 Mar 2016 02:30:46 +0300
parents 0c3c69fe225b
children 9428ea36838e
line wrap: on
line diff
--- a/Implab/Formats/JSON/StringTranslator.cs	Wed Mar 23 19:52:08 2016 +0300
+++ b/Implab/Formats/JSON/StringTranslator.cs	Thu Mar 24 02:30:46 2016 +0300
@@ -11,7 +11,7 @@
     /// <summary>
     /// Класс для преобразования экранированной строки JSON
     /// </summary>
-    public class StringTranslator : TextScanner<JSONGrammar.TokenType> {
+    static class StringTranslator {
         static readonly char[] _escMap;
         static readonly int[] _hexMap;
 
@@ -34,49 +34,6 @@
 
         }
 
-        public StringTranslator() {
-        }
-
-        public string Translate(string data) {
-            Safe.ArgumentNotNull(data, "data");
-            return Translate(data.ToCharArray());
-        }
-
-        public string Translate(char[] data) {
-            Safe.ArgumentNotNull(data, "data");
-            return Translate(data, data.Length);
-        }
-
-        public string Translate(char[] data, int length) {
-            Safe.ArgumentNotNull(data, "data");
-            Safe.ArgumentInRange(length, 0, data.Length, "length");
-
-            var translated = new char[length];
-
-            Feed(data,length);
-
-            int pos = 0;
-
-            while (ReadTokenInternal()) {
-                switch ((JSONGrammar.TokenType)Tags[0]) {
-                    case JSONGrammar.TokenType.UnescapedChar:
-                        Array.Copy(m_buffer,m_tokenOffset,translated,pos,m_tokenLen);
-                        pos += m_tokenLen;
-                        break;
-                    case JSONGrammar.TokenType.EscapedChar:
-                        translated[pos] = _escMap[m_buffer[m_tokenOffset + 1]];
-                        pos++;
-                        break;
-                    case JSONGrammar.TokenType.EscapedUnicode:
-                        translated[pos] = TranslateHexUnicode(m_buffer,m_tokenOffset + 2);
-                        pos++;
-                        break;
-                }
-            }
-
-            return new String(translated, 0, pos);
-        }
-
         internal static char TranslateEscapedChar(char symbol) {
             return _escMap[symbol];
         }