JSONWriter.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/JSONWriter.h"
  6. namespace mozilla {
  7. namespace detail {
  8. // The chars with non-'___' entries in this table are those that can be
  9. // represented with a two-char escape sequence. The value is the second char in
  10. // the sequence, that which follows the initial backslash.
  11. #define ___ 0
  12. const char gTwoCharEscapes[256] = {
  13. /* 0 1 2 3 4 5 6 7 8 9 */
  14. /* 0+ */ ___, ___, ___, ___, ___, ___, ___, ___, 'b', 't',
  15. /* 10+ */ 'n', ___, 'f', 'r', ___, ___, ___, ___, ___, ___,
  16. /* 20+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  17. /* 30+ */ ___, ___, ___, ___, '"', ___, ___, ___, ___, ___,
  18. /* 40+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  19. /* 50+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  20. /* 60+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  21. /* 70+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  22. /* 80+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  23. /* 90+ */ ___, ___,'\\', ___, ___, ___, ___, ___, ___, ___,
  24. /* 100+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  25. /* 110+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  26. /* 120+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  27. /* 130+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  28. /* 140+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  29. /* 150+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  30. /* 160+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  31. /* 170+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  32. /* 180+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  33. /* 190+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  34. /* 200+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  35. /* 210+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  36. /* 220+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  37. /* 230+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  38. /* 240+ */ ___, ___, ___, ___, ___, ___, ___, ___, ___, ___,
  39. /* 250+ */ ___, ___, ___, ___, ___, ___
  40. };
  41. #undef ___
  42. } // namespace detail
  43. } // namespace mozilla