update credits
[LibreOffice.git] / include / cosv / ploc.hxx
blob81f952de52237ed46dcc5bf571207c406ccb6bee
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_PLOC_HXX
21 #define CSV_PLOC_HXX
23 // USED SERVICES
24 #include <cosv/string.hxx>
25 #include <cosv/plocroot.hxx>
26 #include <cosv/dirchain.hxx>
27 #include <cosv/tpl/dyn.hxx>
28 #include <cosv/csv_ostream.hxx>
33 namespace csv
35 class bostream;
37 namespace ploc
39 class Root;
42 /** Represents a path in the file system.
44 The path can be relative or absolute and in Unix- or Windows-syntax.
46 class Path
48 public:
50 // LIFECYCLE
51 explicit Path(
52 const char * i_sPath = ".", /// Dirs have to be ended with a '\\ or '/'.
53 bool i_bPathIsAlwaysDir = false, /// This overrides a missing Delimiter at the end of the i_sPath, if true.
54 const char * i_sDelimiter = Delimiter() );
55 Path(
56 const Path & i_rPath );
57 ~Path();
58 // OPERATORS
59 Path & operator=(
60 const Path & i_rPath );
61 // OPERATIONS
62 void Set(
63 const char * i_sPath,
64 bool i_bPathIsAlwaysDir = false,
65 const char * i_sDelimiter = Delimiter() );
66 void SetFile( // If there is already a file, that is exchanged.
67 const String & i_sName );
68 // INQUIRY
69 const Root & RootDir() const { return *pRoot; }
70 const DirectoryChain &
71 DirChain() const { return aPath; }
72 const String & File() const { return sFile; }
73 bool IsValid() const;
74 bool IsDirectory() const { return sFile.length() == 0; }
75 bool IsFile() const { return sFile.length() > 0; }
77 /// Directories have a delimiter at the end, files not.
78 void Get(
79 bostream & o_rPath ) const;
80 // ACCESS
81 DirectoryChain & DirChain() { return aPath; }
83 private:
84 Dyn<Root> pRoot;
85 DirectoryChain aPath;
86 String sFile;
92 } // namespace ploc
93 } // namespace csv
95 /// Directories produce a delimiter at the end, files not.
96 inline csv::bostream &
97 operator<<( csv::bostream & o_rOut,
98 const csv::ploc::Path & i_rPath )
100 i_rPath.Get(o_rOut);
101 return o_rOut;
104 #endif
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */