xref: /aoo4110/main/soltools/inc/gen_info.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef GEN_INFO_HXX
25 #define GEN_INFO_HXX
26 
27 
28 #include "simstr.hxx"
29 #include <string.h>
30 
31 
32 
33 class List_GenericInfo;
34 
35 
36 /** Holds generic informations in a simple hierarchical format.
37 */
38 class GenericInfo
39 {
40   public:
41     // LIFECFYCLE
42 	                    GenericInfo(
43                             const Simstr &      i_sKey,
44                             const Simstr &      i_sValue = Simstr::null_(),
45                             const Simstr &      i_sComment = Simstr::null_() );
46 	                    GenericInfo(
47                             const GenericInfo & i_rInfo );
48 	                    ~GenericInfo();
49 
50     // OPERATORS
51     GenericInfo &       operator=(
52                             const GenericInfo & i_rInfo );
operator <(const GenericInfo & i_rInfo) const53     bool                operator<(
54                             const GenericInfo & i_rInfo ) const
55 #ifdef UNX
56                                                 { return strcasecmp(sKey.str(),i_rInfo.sKey.str()) < 0; }
57 #else
58                                                 { return stricmp(sKey.str(),i_rInfo.sKey.str()) < 0; }
59 #endif
60     // INFO
Key() const61     const Simstr &      Key() const             { return sKey; }
Value() const62     const Simstr &      Value() const           { return sValue; }
Comment() const63     const Simstr &      Comment() const         { return sComment; }
HasSubList() const64     bool                HasSubList() const      { return dpSubList != 0; }
65 
66 	const List_GenericInfo &
SubList() const67                         SubList() const         { return HasSubList() ? *dpSubList : CreateMyList(); }
68     // ACCESS
69 	List_GenericInfo &
SubList()70                         SubList()               { return HasSubList() ? *dpSubList : CreateMyList(); }
71 
72   private:
73     /// @precond dpSubList == 0 .
74     List_GenericInfo &  CreateMyList() const;
75 
76     // DATA
77     Simstr              sKey;
78 	Simstr              sValue;
79 	Simstr              sComment;
80 	List_GenericInfo *  dpSubList;      /// Owned by this object.
81 };
82 
83 
84 #endif
85 
86