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_NAME_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_NAME_H_ 9 10 #include "core/fpdfapi/parser/cpdf_object.h" 11 #include "core/fxcrt/retain_ptr.h" 12 #include "core/fxcrt/string_pool_template.h" 13 #include "core/fxcrt/weak_ptr.h" 14 15 class CPDF_Name final : public CPDF_Object { 16 public: 17 CONSTRUCT_VIA_MAKE_RETAIN; 18 19 // CPDF_Object: 20 Type GetType() const override; 21 RetainPtr<CPDF_Object> Clone() const override; 22 ByteString GetString() const override; 23 WideString GetUnicodeText() const override; 24 void SetString(const ByteString& str) override; 25 CPDF_Name* AsMutableName() override; 26 bool WriteTo(IFX_ArchiveStream* archive, 27 const CPDF_Encryptor* encryptor) const override; 28 29 private: 30 CPDF_Name(WeakPtr<ByteStringPool> pPool, const ByteString& str); 31 ~CPDF_Name() override; 32 33 ByteString m_Name; 34 }; 35 ToName(CPDF_Object * obj)36inline CPDF_Name* ToName(CPDF_Object* obj) { 37 return obj ? obj->AsMutableName() : nullptr; 38 } 39 ToName(const CPDF_Object * obj)40inline const CPDF_Name* ToName(const CPDF_Object* obj) { 41 return obj ? obj->AsName() : nullptr; 42 } 43 ToName(RetainPtr<CPDF_Object> obj)44inline RetainPtr<const CPDF_Name> ToName(RetainPtr<CPDF_Object> obj) { 45 return RetainPtr<CPDF_Name>(ToName(obj.Get())); 46 } 47 ToName(RetainPtr<const CPDF_Object> obj)48inline RetainPtr<const CPDF_Name> ToName(RetainPtr<const CPDF_Object> obj) { 49 return RetainPtr<const CPDF_Name>(ToName(obj.Get())); 50 } 51 52 #endif // CORE_FPDFAPI_PARSER_CPDF_NAME_H_ 53