DecodedBitStreamParser.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
  2. #ifndef __DECODED_BIT_STREAM_PARSER_H__
  3. #define __DECODED_BIT_STREAM_PARSER_H__
  4. /*
  5. * DecodedBitStreamParser.h
  6. * zxing
  7. *
  8. * Copyright 2010 ZXing authors All rights reserved.
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. */
  22. #include <string>
  23. #include <sstream>
  24. #include <map>
  25. #include <zxing/qrcode/decoder/Mode.h>
  26. #include <zxing/common/BitSource.h>
  27. #include <zxing/common/Counted.h>
  28. #include <zxing/common/Array.h>
  29. #include <zxing/common/DecoderResult.h>
  30. #include <zxing/common/CharacterSetECI.h>
  31. #include <zxing/DecodeHints.h>
  32. namespace zxing {
  33. namespace qrcode {
  34. class DecodedBitStreamParser {
  35. public:
  36. typedef std::map<DecodeHintType, std::string> Hashtable;
  37. private:
  38. static char const ALPHANUMERIC_CHARS[];
  39. static char toAlphaNumericChar(size_t value);
  40. static void decodeHanziSegment(Ref<BitSource> bits, std::string &result, int count);
  41. static void decodeKanjiSegment(Ref<BitSource> bits, std::string &result, int count);
  42. static void decodeByteSegment(Ref<BitSource> bits, std::string &result, int count);
  43. static void decodeByteSegment(Ref<BitSource> bits_,
  44. std::string& result,
  45. int count,
  46. zxing::common::CharacterSetECI* currentCharacterSetECI,
  47. ArrayRef< ArrayRef<char> >& byteSegments,
  48. Hashtable const& hints);
  49. static void decodeAlphanumericSegment(Ref<BitSource> bits, std::string &result, int count, bool fc1InEffect);
  50. static void decodeNumericSegment(Ref<BitSource> bits, std::string &result, int count);
  51. static void append(std::string &ost, const char *bufIn, size_t nIn, const char *src);
  52. static void append(std::string &ost, std::string const& in, const char *src);
  53. public:
  54. static Ref<DecoderResult> decode(ArrayRef<char> bytes,
  55. Version *version,
  56. ErrorCorrectionLevel const& ecLevel,
  57. Hashtable const& hints);
  58. };
  59. }
  60. }
  61. #endif // __DECODED_BIT_STREAM_PARSER_H__