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 ADC_DISPLAY_OUT_POSITION_HXX
25 #define ADC_DISPLAY_OUT_POSITION_HXX
26 
27 
28 // USED SERVICES
29     // BASE CLASSES
30     // COMPONENTS
31 #include <toolkit/out_node.hxx>
32     // PARAMETERS
33 
34 
35 
36 namespace output
37 {
38 
39 
40 
41 class Position
42 {
43   public:
44     // LIFECYCLE
45                         Position();
46     explicit            Position(
47                             Node &              i_directory,
48                             const String &      i_file = String::Null_() );
49                         Position(
50                             const Position &    i_directory,
51                             const String &      i_rDifferentFile );
52                         ~Position();
53 
54     // OPERATIONS
55     Position &          operator=(
56                             Node &              i_node );
57     Position &          operator+=(
58                             const String &      i_nodeName );
59     Position &          operator-=(
60                             intt                i_levels );
61 
62     // INQUIRY
IsValid() const63     bool                IsValid() const         { return pDirectory->Depth() >= 0; }
Name() const64     const String &      Name() const            { return pDirectory->Name(); }
File() const65     const String &      File() const            { return sFile; }
Depth() const66     intt                Depth() const           { return pDirectory->Depth(); }
67 
Get_Chain(StringVector & o_result) const68     void                Get_Chain(
69                             StringVector &      o_result ) const
70                                                 { pDirectory->Get_Chain(o_result); }
71     String              LinkToRoot(
72                             const String &      i_localLabel = String::Null_() ) const;
73 
74     void                Get_LinkTo(
75                             StreamStr &         o_result,
76                             const Position &    i_destination,
77                             const String &      i_localLabel = String::Null_() ) const;
78     void                Get_LinkToRoot(
79                             StreamStr &         o_result,
80                             const String &      i_localLabel = String::Null_() ) const;
81 
Delimiter()82     static char         Delimiter()             { return '/'; }
83 
84     // ACCESS
RelatedNode() const85     Node &              RelatedNode() const     { return *pDirectory; }
86 
87     void                Set(
88                             Node &              i_node,
89                             const String &      i_file = String::Null_() );
90     void                Set_File(
91                             const String &      i_file );
92 
93   private:
94     // DATA
95     String              sFile;
96     Node *              pDirectory;
97 };
98 
99 
100 /// @return No delimiter at start, with delimiter at end.
101 const char *        get_UpLink(
102                         uintt                   i_depth );
103 
104 
105 // IMPLEMENTATION
106 
107 inline void
Set_File(const String & i_file)108 Position::Set_File( const String & i_file )
109     { sFile = i_file; }
110 
111 }   // namespace output
112 
113 #endif
114