update credits
[LibreOffice.git] / include / cosv / dirchain.hxx
blob980937212690dca4c1e542c93bddcfd044982ec0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef CSV_DIRCHAIN_HXX
21 #define CSV_DIRCHAIN_HXX
24 // USED SERVICES
25 // BASE CLASSES
26 // COMPONENTS
27 #include <cosv/string.hxx>
28 // PARAMETERS
29 #include <cosv/csv_ostream.hxx>
31 #include <cosv/persist.hxx>
32 #include <cosv/tpl/tpltools.hxx>
36 namespace csv
38 class bostream;
40 namespace ploc
44 class DirectoryChain
46 public:
47 DirectoryChain();
48 DirectoryChain(
49 const DirectoryChain &
50 i_rDC );
51 ~DirectoryChain();
53 // OPERATORS
54 DirectoryChain & operator=(
55 const DirectoryChain &
56 i_rDC );
57 DirectoryChain & operator+=(
58 const String & i_sName );
59 DirectoryChain & operator+=(
60 const DirectoryChain &
61 i_rDC );
62 DirectoryChain & operator-=(
63 uintt i_nLevelsUp );
65 // OPERATIONS
66 void Set(
67 const char * i_sPath,
68 bool i_bPathIsAlwaysDir = false,
69 const char * i_sDelimiter = Delimiter() );
70 void PushBack(
71 const String & i_sName );
72 void PushBack(
73 const DirectoryChain &
74 i_sPath );
75 void PopBack(
76 uintt i_nCount = 1 );
78 // INQUIRY
79 uintt Size() const;
81 StringVector::const_iterator
82 Begin() const;
83 StringVector::const_iterator
84 End() const;
86 const String & Front() const;
87 const String & Back() const;
89 void Get(
90 bostream & o_rPath,
91 const char * i_sDelimiter ) const;
92 private:
93 StringVector aPath;
97 // IMPLEMENTATION
98 inline
99 DirectoryChain::DirectoryChain( const DirectoryChain & i_rDC )
100 { PushBack(i_rDC); }
102 // OPERATORS
103 inline DirectoryChain &
104 DirectoryChain::operator=( const DirectoryChain & i_rDC )
105 { csv::erase_container(aPath); PushBack(i_rDC); return *this; }
106 inline DirectoryChain &
107 DirectoryChain::operator+=( const String & i_sName )
108 { PushBack(i_sName); return *this; }
109 inline DirectoryChain &
110 DirectoryChain::operator+=( const DirectoryChain & i_rDC )
111 { PushBack(i_rDC); return *this; }
112 inline DirectoryChain &
113 DirectoryChain::operator-=( uintt i_nLevelsUp )
114 { PopBack(i_nLevelsUp); return *this; }
115 inline uintt
116 DirectoryChain::Size() const
117 { return aPath.size(); }
119 inline StringVector::const_iterator
120 DirectoryChain::Begin() const
121 { return aPath.begin(); }
122 inline StringVector::const_iterator
123 DirectoryChain::End() const
124 { return aPath.end(); }
125 inline const String &
126 DirectoryChain::Front() const
127 { return aPath.empty() ? String::Null_() : aPath.front(); }
128 inline const String &
129 DirectoryChain::Back() const
130 { return aPath.empty() ? String::Null_() : aPath.back(); }
133 } // namespace ploc
134 } // namespace csv
136 inline csv::bostream &
137 operator<<( csv::bostream & o_rOut,
138 const csv::ploc::DirectoryChain & i_rSubPath )
140 i_rSubPath.Get(o_rOut, csv::ploc::Delimiter());
141 return o_rOut;
144 #endif
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */