CommitDlg: Update index using libgit2 incrementally
[TortoiseGit.git] / ext / ResizableLib / ResizableState.cpp
blob90faa58e28f8027587493802946963267b32465c
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // This file is part of ResizableLib
4 // http://sourceforge.net/projects/resizablelib
5 //
6 // Copyright (C) 2000-2004 by Paolo Messina
7 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
8 //
9 // The contents of this file are subject to the Artistic License (the "License").
10 // You may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at:
12 // http://www.opensource.org/licenses/artistic-license.html
14 // If you find this code useful, credits would be nice!
16 /////////////////////////////////////////////////////////////////////////////
18 /*!
19 * @file
20 * @brief Implementation of the CResizableState class.
23 #include "stdafx.h"
24 #include "ResizableState.h"
26 #ifdef _DEBUG
27 #undef THIS_FILE
28 static char THIS_FILE[]=__FILE__;
29 #define new DEBUG_NEW
30 #endif
32 //////////////////////////////////////////////////////////////////////
33 // Construction/Destruction
34 //////////////////////////////////////////////////////////////////////
36 CResizableState::CResizableState()
38 m_sStorePath = m_sDefaultStorePath;
41 CResizableState::~CResizableState()
46 // static intializer must be called before user code
47 #pragma warning(disable:4073)
48 #pragma init_seg(lib)
49 CString CResizableState::m_sDefaultStorePath(_T("ResizableState"));
51 /*!
52 * Static function to set the default path used to store state information.
53 * This path is used to initialize all the instances of this class.
54 * @sa GetDefaultStateStore GetStateStore SetStateStore
56 * @param szPath String that specifies the new path to be set
58 void CResizableState::SetDefaultStateStore(LPCTSTR szPath)
60 m_sDefaultStorePath = szPath;
63 /*!
64 * Static function to retrieve the default path used to store state
65 * information.
66 * This path is used to initialize all the instances of this class.
67 * @sa SetDefaultStateStore GetStateStore SetStateStore
69 * @return The return value is a string that specifies the current path
71 LPCTSTR CResizableState::GetDefaultStateStore()
73 return m_sDefaultStorePath;
76 /*!
77 * This function sets the path used to store state information by
78 * the current instance of the class.
79 * @sa GetStateStore GetDefaultStateStore SetDefaultStateStore
81 * @param szPath String that specifies the new path to be set
83 void CResizableState::SetStateStore(LPCTSTR szPath)
85 m_sStorePath = szPath;
88 /*!
89 * This function retrieves the path used to store state information by
90 * the current instance of the class.
91 * @sa SetStateStore GetDefaultStateStore SetDefaultStateStore
93 * @return The return value is a string that specifies the current path
95 LPCTSTR CResizableState::GetStateStore()
97 return m_sStorePath;
101 * This function writes state information and associates it with some
102 * identification text for later retrieval.
103 * The base implementation uses the application profile to persist state
104 * information, but this function can be overridden to implement
105 * different methods.
107 * @param szId String that identifies the stored settings
108 * @param szState String that represents the state information to store
110 * @return The return value is @a TRUE if settings have been successfully
111 * stored, @a FALSE otherwise.
113 BOOL CResizableState::WriteState(LPCTSTR szId, LPCTSTR szState)
115 return AfxGetApp()->WriteProfileString(GetStateStore(), szId, szState);
119 * This function reads state information previously associated with some
120 * identification text.
121 * The base implementation uses the application profile to persist state
122 * information, but this function can be overridden to implement
123 * different methods.
125 * @param szId String that identifies the stored settings
126 * @param rsState String to be filled with the retrieved state information
128 * @return The return value is @a TRUE if settings have been successfully
129 * retrieved, @a FALSE otherwise.
131 BOOL CResizableState::ReadState(LPCTSTR szId, CString &rsState)
133 rsState = AfxGetApp()->GetProfileString(GetStateStore(), szId);
134 return !rsState.IsEmpty();