• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
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 #include "third_party/base/ptr_util.h"
9 
CPDF_Boolean()10 CPDF_Boolean::CPDF_Boolean() : m_bValue(false) {}
11 
CPDF_Boolean(bool value)12 CPDF_Boolean::CPDF_Boolean(bool value) : m_bValue(value) {}
13 
~CPDF_Boolean()14 CPDF_Boolean::~CPDF_Boolean() {}
15 
GetType() const16 CPDF_Object::Type CPDF_Boolean::GetType() const {
17   return BOOLEAN;
18 }
19 
Clone() const20 std::unique_ptr<CPDF_Object> CPDF_Boolean::Clone() const {
21   return pdfium::MakeUnique<CPDF_Boolean>(m_bValue);
22 }
23 
GetString() const24 CFX_ByteString CPDF_Boolean::GetString() const {
25   return m_bValue ? "true" : "false";
26 }
27 
GetInteger() const28 int CPDF_Boolean::GetInteger() const {
29   return m_bValue;
30 }
31 
SetString(const CFX_ByteString & str)32 void CPDF_Boolean::SetString(const CFX_ByteString& str) {
33   m_bValue = (str == "true");
34 }
35 
IsBoolean() const36 bool CPDF_Boolean::IsBoolean() const {
37   return true;
38 }
39 
AsBoolean()40 CPDF_Boolean* CPDF_Boolean::AsBoolean() {
41   return this;
42 }
43 
AsBoolean() const44 const CPDF_Boolean* CPDF_Boolean::AsBoolean() const {
45   return this;
46 }
47