OSDN Git Service

Linked with static version of CRT/MFC.
[tortoisegit/TortoiseGitJp.git] / src / Utils / RegHistory.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2007 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 \r
22 /**\r
23  * \ingroup TortoiseProc\r
24  * Maintains a list of X string items in the registry and provides methods\r
25  * to add new items. The list can be used as a 'recently used' or 'recent items' list.\r
26  */\r
27 class CRegHistory\r
28 {\r
29 public:\r
30         CRegHistory();\r
31         virtual ~CRegHistory();\r
32 \r
33         /// Loads the history\r
34         /// \param lpszSection the section in the registry, e.g., "Software\\CompanyName\\History"\r
35         /// \param lpszKeyPrefix the name of the registry values, e.g., "historyItem"\r
36         /// \return the number of history items loaded\r
37         size_t Load(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix);\r
38         /// Saves the history.\r
39         bool Save() const;\r
40         /// Adds a new string to the history list.\r
41         bool AddEntry(LPCTSTR szText);\r
42         /// Removes the entry at index \c pos.\r
43         void RemoveEntry(int pos);\r
44         /// Sets the maximum number of items in the history. Default is 25.\r
45         void SetMaxHistoryItems(int nMax) {m_nMaxHistoryItems = nMax;}\r
46         /// Returns the number of items in the history.\r
47         size_t GetCount() const {return m_arEntries.size(); }\r
48         /// Returns the entry at index \c pos\r
49         LPCTSTR GetEntry(size_t pos) {return m_arEntries[pos].c_str();}\r
50 \r
51 private:\r
52         std::wstring m_sSection;\r
53         std::wstring m_sKeyPrefix;\r
54         std::vector<std::wstring> m_arEntries;\r
55         int m_nMaxHistoryItems;\r
56 };\r