Get the style color and number just once
[LibreOffice.git] / desktop / source / deployment / inc / dp_persmap.h
blobc36979807309c145064d0b36d30cb02fccf7aad4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <rtl/ustring.hxx>
23 #include <osl/file.hxx>
24 #include <unordered_map>
26 namespace dp_misc
28 typedef std::unordered_map<OString, OString> t_string2string_map;
30 // Class to read obsolete registered extensions
31 // should be removed for LibreOffice 4.0
32 class PersistentMap final
34 ::osl::File m_MapFile;
35 t_string2string_map m_entries;
36 bool m_bIsOpen;
37 bool m_bToBeCreated;
38 bool m_bIsDirty;
40 public:
41 ~PersistentMap();
42 PersistentMap(OUString const& url);
43 /** in mem db */
44 PersistentMap();
46 bool has(OString const& key) const;
47 bool get(OString* value, OString const& key) const;
48 const t_string2string_map& getEntries() const { return m_entries; }
49 void put(OString const& key, OString const& value);
50 bool erase(OString const& key);
52 private:
53 void open();
54 void readAll();
55 void add(OString const& key, OString const& value);
56 void flush();
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */