xref: /aosp_15_r20/external/pdfium/core/fpdfapi/parser/cpdf_boolean.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFAPI_PARSER_CPDF_BOOLEAN_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_BOOLEAN_H_
9 
10 #include "core/fpdfapi/parser/cpdf_object.h"
11 #include "core/fxcrt/bytestring.h"
12 #include "core/fxcrt/retain_ptr.h"
13 
14 class CPDF_Boolean final : public CPDF_Object {
15  public:
16   CONSTRUCT_VIA_MAKE_RETAIN;
17 
18   // CPDF_Object:
19   Type GetType() const override;
20   RetainPtr<CPDF_Object> Clone() const override;
21   ByteString GetString() const override;
22   int GetInteger() const override;
23   void SetString(const ByteString& str) override;
24   CPDF_Boolean* AsMutableBoolean() override;
25   bool WriteTo(IFX_ArchiveStream* archive,
26                const CPDF_Encryptor* encryptor) const override;
27 
28  private:
29   CPDF_Boolean();
30   explicit CPDF_Boolean(bool value);
31   ~CPDF_Boolean() override;
32 
33   bool m_bValue = false;
34 };
35 
ToBoolean(CPDF_Object * obj)36 inline CPDF_Boolean* ToBoolean(CPDF_Object* obj) {
37   return obj ? obj->AsMutableBoolean() : nullptr;
38 }
39 
ToBoolean(const CPDF_Object * obj)40 inline const CPDF_Boolean* ToBoolean(const CPDF_Object* obj) {
41   return obj ? obj->AsBoolean() : nullptr;
42 }
43 
44 #endif  // CORE_FPDFAPI_PARSER_CPDF_BOOLEAN_H_
45