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