Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfxjse_mapmodule.cpp
Go to the documentation of this file.
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#include "fxjs/xfa/cfxjse_mapmodule.h"
8
9#include "third_party/base/containers/contains.h"
10#include "xfa/fxfa/parser/cxfa_measurement.h"
11
13
15
16void CFXJSE_MapModule::SetValue(uint32_t key, int32_t value) {
17 m_StringMap.erase(key);
18 m_MeasurementMap.erase(key);
19 m_ValueMap[key] = value;
20}
21
22void CFXJSE_MapModule::SetString(uint32_t key, const WideString& wsString) {
23 m_ValueMap.erase(key);
24 m_MeasurementMap.erase(key);
25 m_StringMap[key] = wsString;
26}
27
29 const CXFA_Measurement& measurement) {
30 m_ValueMap.erase(key);
31 m_StringMap.erase(key);
32 m_MeasurementMap[key] = measurement;
33}
34
36 auto it = m_ValueMap.find(key);
37 if (it == m_ValueMap.end())
38 return absl::nullopt;
39 return it->second;
40}
41
43 auto it = m_StringMap.find(key);
44 if (it == m_StringMap.end())
45 return absl::nullopt;
46 return it->second;
47}
48
50 uint32_t key) const {
51 auto it = m_MeasurementMap.find(key);
52 if (it == m_MeasurementMap.end())
53 return absl::nullopt;
54 return it->second;
55}
56
57bool CFXJSE_MapModule::HasKey(uint32_t key) const {
58 return pdfium::Contains(m_ValueMap, key) ||
59 pdfium::Contains(m_StringMap, key) ||
60 pdfium::Contains(m_MeasurementMap, key);
61}
62
63void CFXJSE_MapModule::RemoveKey(uint32_t key) {
64 m_ValueMap.erase(key);
65 m_StringMap.erase(key);
66 m_MeasurementMap.erase(key);
67}
68
70 for (const auto& pair : pSrc->m_ValueMap)
71 SetValue(pair.first, pair.second);
72
73 for (const auto& pair : pSrc->m_StringMap)
74 SetString(pair.first, pair.second);
75
76 for (const auto& pair : pSrc->m_MeasurementMap)
77 SetMeasurement(pair.first, pair.second);
78}
absl::optional< int32_t > GetValue(uint32_t key) const
absl::optional< WideString > GetString(uint32_t key) const
absl::optional< CXFA_Measurement > GetMeasurement(uint32_t key) const
void MergeDataFrom(const CFXJSE_MapModule *pSrc)
void SetValue(uint32_t key, int32_t value)
void SetMeasurement(uint32_t key, const CXFA_Measurement &measurement)
void SetString(uint32_t key, const WideString &wsString)
void RemoveKey(uint32_t key)
bool HasKey(uint32_t key) const