| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| 8 #define FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 8 #define FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| 9 | 9 |
| 10 #include <memory> |
| 11 #include <vector> |
| 12 |
| 10 #include "core/fxcrt/include/fx_basic.h" | 13 #include "core/fxcrt/include/fx_basic.h" |
| 11 | 14 |
| 12 #define JS_GLOBALDATA_TYPE_NUMBER 0 | 15 #define JS_GLOBALDATA_TYPE_NUMBER 0 |
| 13 #define JS_GLOBALDATA_TYPE_BOOLEAN 1 | 16 #define JS_GLOBALDATA_TYPE_BOOLEAN 1 |
| 14 #define JS_GLOBALDATA_TYPE_STRING 2 | 17 #define JS_GLOBALDATA_TYPE_STRING 2 |
| 15 #define JS_GLOBALDATA_TYPE_OBJECT 3 | 18 #define JS_GLOBALDATA_TYPE_OBJECT 3 |
| 16 #define JS_GLOBALDATA_TYPE_NULL 4 | 19 #define JS_GLOBALDATA_TYPE_NULL 4 |
| 17 | 20 |
| 18 class CJS_KeyValue; | 21 class CJS_KeyValue; |
| 19 class CPDFDoc_Environment; | 22 class CPDFDoc_Environment; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void SetGlobalVariableNull(const FX_CHAR* propname); | 73 void SetGlobalVariableNull(const FX_CHAR* propname); |
| 71 | 74 |
| 72 FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, | 75 FX_BOOL SetGlobalVariablePersistent(const FX_CHAR* propname, |
| 73 FX_BOOL bPersistent); | 76 FX_BOOL bPersistent); |
| 74 FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); | 77 FX_BOOL DeleteGlobalVariable(const FX_CHAR* propname); |
| 75 | 78 |
| 76 int32_t GetSize() const; | 79 int32_t GetSize() const; |
| 77 CJS_GlobalData_Element* GetAt(int index) const; | 80 CJS_GlobalData_Element* GetAt(int index) const; |
| 78 | 81 |
| 79 private: | 82 private: |
| 83 using iterator = |
| 84 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::iterator; |
| 85 using const_iterator = |
| 86 std::vector<std::unique_ptr<CJS_GlobalData_Element>>::const_iterator; |
| 87 |
| 80 static CJS_GlobalData* g_Instance; | 88 static CJS_GlobalData* g_Instance; |
| 81 | 89 |
| 82 CJS_GlobalData(); | 90 CJS_GlobalData(); |
| 83 ~CJS_GlobalData(); | 91 ~CJS_GlobalData(); |
| 84 | 92 |
| 85 void LoadGlobalPersistentVariables(); | 93 void LoadGlobalPersistentVariables(); |
| 86 void SaveGlobalPersisitentVariables(); | 94 void SaveGlobalPersisitentVariables(); |
| 87 | 95 |
| 88 CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); | 96 CJS_GlobalData_Element* GetGlobalVariable(const FX_CHAR* propname); |
| 89 int FindGlobalVariable(const FX_CHAR* propname); | 97 iterator FindGlobalVariable(const FX_CHAR* propname); |
| 98 const_iterator FindGlobalVariable(const FX_CHAR* propname) const; |
| 90 | 99 |
| 91 void LoadFileBuffer(const FX_WCHAR* sFilePath, | 100 void LoadFileBuffer(const FX_WCHAR* sFilePath, |
| 92 uint8_t*& pBuffer, | 101 uint8_t*& pBuffer, |
| 93 int32_t& nLength); | 102 int32_t& nLength); |
| 94 void WriteFileBuffer(const FX_WCHAR* sFilePath, | 103 void WriteFileBuffer(const FX_WCHAR* sFilePath, |
| 95 const FX_CHAR* pBuffer, | 104 const FX_CHAR* pBuffer, |
| 96 int32_t nLength); | 105 int32_t nLength); |
| 97 void MakeByteString(const CFX_ByteString& name, | 106 void MakeByteString(const CFX_ByteString& name, |
| 98 CJS_KeyValue* pData, | 107 CJS_KeyValue* pData, |
| 99 CFX_BinaryBuf& sData); | 108 CFX_BinaryBuf& sData); |
| 100 | 109 |
| 101 size_t m_RefCount; | 110 size_t m_RefCount; |
| 102 CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData; | 111 std::vector<std::unique_ptr<CJS_GlobalData_Element>> m_arrayGlobalData; |
| 103 CFX_WideString m_sFilePath; | 112 CFX_WideString m_sFilePath; |
| 104 }; | 113 }; |
| 105 | 114 |
| 106 #endif // FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ | 115 #endif // FPDFSDK_JAVASCRIPT_JS_GLOBALDATA_H_ |
| OLD | NEW |