1 // Copyright 2020 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 FXJS_XFA_CFXJSE_MAPMODULE_H_ 8 #define FXJS_XFA_CFXJSE_MAPMODULE_H_ 9 10 #include <stdint.h> 11 12 #include <map> 13 14 #include "core/fxcrt/widestring.h" 15 #include "third_party/abseil-cpp/absl/types/optional.h" 16 17 class CXFA_Measurement; 18 19 class CFXJSE_MapModule { 20 public: 21 CFXJSE_MapModule(); 22 ~CFXJSE_MapModule(); 23 24 CFXJSE_MapModule(const CFXJSE_MapModule& that) = delete; 25 CFXJSE_MapModule& operator=(const CFXJSE_MapModule& that) = delete; 26 27 void SetValue(uint32_t key, int32_t value); 28 void SetString(uint32_t key, const WideString& wsString); 29 void SetMeasurement(uint32_t key, const CXFA_Measurement& measurement); 30 absl::optional<int32_t> GetValue(uint32_t key) const; 31 absl::optional<WideString> GetString(uint32_t key) const; 32 absl::optional<CXFA_Measurement> GetMeasurement(uint32_t key) const; 33 bool HasKey(uint32_t key) const; 34 void RemoveKey(uint32_t key); 35 void MergeDataFrom(const CFXJSE_MapModule* pSrc); 36 37 private: 38 // keyed by result of GetMapKey_*(). 39 std::map<uint32_t, int32_t> m_ValueMap; 40 std::map<uint32_t, WideString> m_StringMap; 41 std::map<uint32_t, CXFA_Measurement> m_MeasurementMap; 42 }; 43 44 #endif // FXJS_XFA_CFXJSE_MAPMODULE_H_ 45