xref: /aoo42x/main/autodoc/inc/cosv/ploc.hxx (revision 8a106958)
1ac3d0c65SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ac3d0c65SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ac3d0c65SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ac3d0c65SAndrew Rist  * distributed with this work for additional information
6ac3d0c65SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ac3d0c65SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ac3d0c65SAndrew Rist  * "License"); you may not use this file except in compliance
9ac3d0c65SAndrew Rist  * with the License.  You may obtain a copy of the License at
10ac3d0c65SAndrew Rist  *
11ac3d0c65SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ac3d0c65SAndrew Rist  *
13ac3d0c65SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ac3d0c65SAndrew Rist  * software distributed under the License is distributed on an
15ac3d0c65SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ac3d0c65SAndrew Rist  * KIND, either express or implied.  See the License for the
17ac3d0c65SAndrew Rist  * specific language governing permissions and limitations
18ac3d0c65SAndrew Rist  * under the License.
19ac3d0c65SAndrew Rist  *
20ac3d0c65SAndrew Rist  *************************************************************/
21ac3d0c65SAndrew Rist 
22ac3d0c65SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CSV_PLOC_HXX
25cdf0e10cSrcweir #define CSV_PLOC_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // USED SERVICES
28cdf0e10cSrcweir #include <cosv/string.hxx>
29cdf0e10cSrcweir #include <cosv/plocroot.hxx>
30cdf0e10cSrcweir #include <cosv/dirchain.hxx>
31cdf0e10cSrcweir #include <cosv/tpl/dyn.hxx>
32cdf0e10cSrcweir #include <cosv/csv_ostream.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace csv
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     class bostream;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace ploc
42cdf0e10cSrcweir {
43cdf0e10cSrcweir     class Root;
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /** Represents a path in the file system.
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     The path can be relative or absolute and in Unix- or Windows-syntax.
49cdf0e10cSrcweir */
50cdf0e10cSrcweir class Path
51cdf0e10cSrcweir {
52cdf0e10cSrcweir   public:
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     // LIFECYCLE
55cdf0e10cSrcweir     explicit            Path(
56cdf0e10cSrcweir                             const char *        i_sPath = ".",                  /// Dirs have to be ended with a '\\ or '/'.
57cdf0e10cSrcweir                             bool                i_bPathIsAlwaysDir = false,     /// This overrides a missing Delimiter at the end of the i_sPath, if true.
58cdf0e10cSrcweir                             const char *        i_sDelimiter = Delimiter() );
59cdf0e10cSrcweir                         Path(
60cdf0e10cSrcweir                             const Path &        i_rPath );
61cdf0e10cSrcweir                         ~Path();
62cdf0e10cSrcweir     // OPERATORS
63cdf0e10cSrcweir     Path &              operator=(
64cdf0e10cSrcweir                             const Path &        i_rPath );
65cdf0e10cSrcweir     // OPERATIONS
66cdf0e10cSrcweir     void                Set(
67cdf0e10cSrcweir                             const char *        i_sPath,
68cdf0e10cSrcweir                             bool                i_bPathIsAlwaysDir = false,
69cdf0e10cSrcweir                             const char *        i_sDelimiter = Delimiter() );
70cdf0e10cSrcweir     void                SetFile(                // If there is already a file, that is exchanged.
71cdf0e10cSrcweir                             const String &      i_sName );
72cdf0e10cSrcweir     // INQUIRY
RootDir() const73cdf0e10cSrcweir     const Root &        RootDir() const         { return *pRoot; }
74cdf0e10cSrcweir     const DirectoryChain &
DirChain() const75cdf0e10cSrcweir                         DirChain() const        { return aPath; }
File() const76cdf0e10cSrcweir     const String  &     File() const            { return sFile; }
77cdf0e10cSrcweir     const char *        FileExtension() const;
78cdf0e10cSrcweir     bool                IsValid() const;
IsDirectory() const79cdf0e10cSrcweir     bool                IsDirectory() const     { return sFile.length() == 0; }
IsFile() const80cdf0e10cSrcweir     bool                IsFile() const          { return sFile.length() > 0; }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /// Directories have a delimiter at the end, files not.
83cdf0e10cSrcweir     void                Get(
84cdf0e10cSrcweir                             ostream &           o_rPath ) const;
85cdf0e10cSrcweir     /// Directories have a delimiter at the end, files not.
86cdf0e10cSrcweir     void                Get(
87cdf0e10cSrcweir                             bostream &          o_rPath ) const;
88cdf0e10cSrcweir     // ACCESS
DirChain()89cdf0e10cSrcweir     DirectoryChain &    DirChain()              { return aPath; }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir   private:
92cdf0e10cSrcweir     Dyn<Root>           pRoot;
93cdf0e10cSrcweir     DirectoryChain      aPath;
94cdf0e10cSrcweir     String              sFile;
95cdf0e10cSrcweir };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir }   // namespace ploc
101cdf0e10cSrcweir }   // namespace csv
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /// Directories produce a delimiter at the end, files not.
106cdf0e10cSrcweir inline csv::ostream &
operator <<(csv::ostream & o_rOut,const csv::ploc::Path & i_rPath)107cdf0e10cSrcweir operator<<( csv::ostream &           o_rOut,
108cdf0e10cSrcweir             const csv::ploc::Path &  i_rPath )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir  	i_rPath.Get(o_rOut);
111cdf0e10cSrcweir     return o_rOut;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir /// Directories produce a delimiter at the end, files not.
115cdf0e10cSrcweir inline csv::bostream &
operator <<(csv::bostream & o_rOut,const csv::ploc::Path & i_rPath)116cdf0e10cSrcweir operator<<( csv::bostream &         o_rOut,
117cdf0e10cSrcweir             const csv::ploc::Path & i_rPath )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir  	i_rPath.Get(o_rOut);
120cdf0e10cSrcweir     return o_rOut;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir #endif
126