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 #include "core/fpdfapi/parser/cpdf_boolean.h" 8 9 #include "core/fxcrt/fx_stream.h" 10 11 CPDF_Boolean::CPDF_Boolean() = default; 12 CPDF_Boolean(bool value)13CPDF_Boolean::CPDF_Boolean(bool value) : m_bValue(value) {} 14 15 CPDF_Boolean::~CPDF_Boolean() = default; 16 GetType() const17CPDF_Object::Type CPDF_Boolean::GetType() const { 18 return kBoolean; 19 } 20 Clone() const21RetainPtr<CPDF_Object> CPDF_Boolean::Clone() const { 22 return pdfium::MakeRetain<CPDF_Boolean>(m_bValue); 23 } 24 GetString() const25ByteString CPDF_Boolean::GetString() const { 26 return m_bValue ? "true" : "false"; 27 } 28 GetInteger() const29int CPDF_Boolean::GetInteger() const { 30 return m_bValue; 31 } 32 SetString(const ByteString & str)33void CPDF_Boolean::SetString(const ByteString& str) { 34 m_bValue = (str == "true"); 35 } 36 AsMutableBoolean()37CPDF_Boolean* CPDF_Boolean::AsMutableBoolean() { 38 return this; 39 } 40 WriteTo(IFX_ArchiveStream * archive,const CPDF_Encryptor * encryptor) const41bool CPDF_Boolean::WriteTo(IFX_ArchiveStream* archive, 42 const CPDF_Encryptor* encryptor) const { 43 return archive->WriteString(" ") && 44 archive->WriteString(GetString().AsStringView()); 45 } 46