Reducing header overuse, non-inlining selected methods (CPPOST-35).
[shibboleth/cpp-opensaml.git] / saml / util / CommonDomainCookie.h
1 /*
2  *  Copyright 2001-2009 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file saml/util/CommonDomainCookie.h
19  * 
20  * Helper class for maintaining discovery cookie.
21  */
22
23 #ifndef __saml_cdc_h__
24 #define __saml_cdc_h__
25
26 #include <saml/base.h>
27
28 #include <string>
29 #include <vector> 
30
31 #if defined (_MSC_VER)
32     #pragma warning( push )
33     #pragma warning( disable : 4250 4251 )
34 #endif
35
36 namespace opensaml {
37     /**
38      * Helper class for maintaining discovery cookie.
39      */
40     class SAML_API CommonDomainCookie {
41         MAKE_NONCOPYABLE(CommonDomainCookie);
42     public:
43         /**
44          * Parses a cookie for reading or writing.
45          * 
46          * @param cookie    the raw cookie value
47          */
48         CommonDomainCookie(const char* cookie);
49         
50         ~CommonDomainCookie();
51         
52         /**
53          * Returns list of IdPs stored in cookie.
54          * 
55          * @return  reference to vector of entityIDs
56          */
57         const std::vector<std::string>& get() const;
58         
59         /**
60          * Adds/moves an IdP to the front of the list.
61          * 
62          * @param entityID  name of IdP to add
63          * @return new value of cookie
64          */
65         const char* set(const char* entityID);
66         
67         /** Name of cookie ("_saml_idp") */
68         static const char CDCName[];
69
70     private:
71         std::string m_encoded;
72         std::vector<std::string> m_list;
73     };
74 };
75
76 #if defined (_MSC_VER)
77     #pragma warning( pop )
78 #endif
79
80 #endif /* __saml_cdc_h__ */