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
cfx_globaldata.h
Go to the documentation of this file.
1// Copyright 2014 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_CFX_GLOBALDATA_H_
8#define FXJS_CFX_GLOBALDATA_H_
9
10#include <memory>
11#include <vector>
12
13#include "core/fxcrt/binary_buffer.h"
14#include "core/fxcrt/unowned_ptr.h"
15#include "fxjs/cfx_keyvalue.h"
16#include "third_party/abseil-cpp/absl/types/optional.h"
17#include "third_party/base/containers/span.h"
18
20 public:
21 class Delegate {
22 public:
23 virtual ~Delegate() = default;
24
25 virtual bool StoreBuffer(pdfium::span<const uint8_t> pBuffer) = 0;
27 virtual void BufferDone() = 0;
28 };
29
30 class Element {
31 public:
34
36 bool bPersistent = false;
37 };
38
40 bool Release();
41
42 void SetGlobalVariableNumber(ByteString propname, double dData);
43 void SetGlobalVariableBoolean(ByteString propname, bool bData);
44 void SetGlobalVariableString(ByteString propname, const ByteString& sData);
46 ByteString propname,
47 std::vector<std::unique_ptr<CFX_KeyValue>> array);
48 void SetGlobalVariableNull(ByteString propname);
49 bool SetGlobalVariablePersistent(ByteString propname, bool bPersistent);
50 bool DeleteGlobalVariable(ByteString propname);
51
52 int32_t GetSize() const;
53 Element* GetAt(int index);
54
55 // Exposed for testing.
56 Element* GetGlobalVariable(const ByteString& sPropname);
57
58 private:
60
61 explicit CFX_GlobalData(Delegate* pDelegate);
62 ~CFX_GlobalData();
63
64 bool LoadGlobalPersistentVariables();
65 bool LoadGlobalPersistentVariablesFromBuffer(pdfium::span<uint8_t> buffer);
66 bool SaveGlobalPersisitentVariables();
67 iterator FindGlobalVariable(const ByteString& sPropname);
68
69 size_t m_RefCount = 0;
70 UnownedPtr<Delegate> const m_pDelegate;
71 std::vector<std::unique_ptr<Element>> m_arrayGlobalData;
72};
73
74#endif // FXJS_CFX_GLOBALDATA_H_
virtual ~Delegate()=default
virtual absl::optional< pdfium::span< uint8_t > > LoadBuffer()=0
virtual bool StoreBuffer(pdfium::span< const uint8_t > pBuffer)=0
virtual void BufferDone()=0
bool SetGlobalVariablePersistent(ByteString propname, bool bPersistent)
Element * GetAt(int index)
void SetGlobalVariableObject(ByteString propname, std::vector< std::unique_ptr< CFX_KeyValue > > array)
void SetGlobalVariableNull(ByteString propname)
void SetGlobalVariableNumber(ByteString propname, double dData)
bool DeleteGlobalVariable(ByteString propname)
static CFX_GlobalData * GetRetainedInstance(Delegate *pDelegate)
void SetGlobalVariableBoolean(ByteString propname, bool bData)
Element * GetGlobalVariable(const ByteString &sPropname)
void SetGlobalVariableString(ByteString propname, const ByteString &sData)
int32_t GetSize() const
double dData
DataType nType
void AppendUint16(uint16_t value)
void AppendSpan(pdfium::span< const uint8_t > span)
pdfium::span< const uint8_t > GetSpan() const
void AppendDouble(double value)
void AppendString(const ByteString &str)
void AppendUint32(uint32_t value)
pdfium::span< uint8_t > GetMutableSpan()