Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/Content.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2022 Axel Waggershauser | |
| 3 */ | |
| 4 // SPDX-License-Identifier: Apache-2.0 | |
| 5 | |
| 6 #pragma once | |
| 7 | |
| 8 #include "ByteArray.h" | |
| 9 #include "CharacterSet.h" | |
| 10 #include "ReaderOptions.h" | |
| 11 | |
| 12 #include <string> | |
| 13 #include <vector> | |
| 14 | |
| 15 namespace ZXing { | |
| 16 | |
| 17 enum class ECI : int; | |
| 18 | |
| 19 enum class ContentType { Text, Binary, Mixed, GS1, ISO15434, UnknownECI }; | |
| 20 enum class AIFlag : char { None, GS1, AIM }; | |
| 21 | |
| 22 std::string ToString(ContentType type); | |
| 23 | |
| 24 struct SymbologyIdentifier | |
| 25 { | |
| 26 char code = 0, modifier = 0, eciModifierOffset = 0; | |
| 27 AIFlag aiFlag = AIFlag::None; | |
| 28 | |
| 29 std::string toString(bool hasECI = false) const | |
| 30 { | |
| 31 return code ? ']' + std::string(1, code) + static_cast<char>(modifier + eciModifierOffset * hasECI) : std::string(); | |
| 32 } | |
| 33 }; | |
| 34 | |
| 35 class Content | |
| 36 { | |
| 37 template <typename FUNC> | |
| 38 void ForEachECIBlock(FUNC f) const; | |
| 39 | |
| 40 void switchEncoding(ECI eci, bool isECI); | |
| 41 std::string render(bool withECI) const; | |
| 42 | |
| 43 public: | |
| 44 struct Encoding | |
| 45 { | |
| 46 ECI eci; | |
| 47 int pos; | |
| 48 }; | |
| 49 | |
| 50 ByteArray bytes; | |
| 51 std::vector<Encoding> encodings; | |
| 52 SymbologyIdentifier symbology; | |
| 53 CharacterSet defaultCharset = CharacterSet::Unknown; | |
| 54 bool hasECI = false; | |
| 55 | |
| 56 Content(); | |
| 57 Content(ByteArray&& bytes, SymbologyIdentifier si); | |
| 58 | |
| 59 void switchEncoding(ECI eci) { switchEncoding(eci, true); } | |
| 60 void switchEncoding(CharacterSet cs); | |
| 61 | |
| 62 void reserve(int count) { bytes.reserve(bytes.size() + count); } | |
| 63 | |
| 64 void push_back(uint8_t val) { bytes.push_back(val); } | |
| 65 void append(const std::string& str) { bytes.insert(bytes.end(), str.begin(), str.end()); } | |
| 66 void append(const ByteArray& ba) { bytes.insert(bytes.end(), ba.begin(), ba.end()); } | |
| 67 void append(const Content& other); | |
| 68 | |
| 69 void operator+=(char val) { push_back(val); } | |
| 70 void operator+=(const std::string& str) { append(str); } | |
| 71 | |
| 72 void erase(int pos, int n); | |
| 73 void insert(int pos, const std::string& str); | |
| 74 | |
| 75 bool empty() const { return bytes.empty(); } | |
| 76 bool canProcess() const; | |
| 77 | |
| 78 std::string text(TextMode mode) const; | |
| 79 std::wstring utfW() const; // utf16 or utf32 depending on the platform, i.e. on size_of(wchar_t) | |
| 80 std::string utf8() const { return render(false); } | |
| 81 | |
| 82 ByteArray bytesECI() const; | |
| 83 CharacterSet guessEncoding() const; | |
| 84 ContentType type() const; | |
| 85 }; | |
| 86 | |
| 87 } // ZXing |
