1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #define CSV_USE_CSV_ASSERTIONS
21 #include <cosv/csv_env.hxx>
23 #include <cosv/comfunc.hxx>
24 #include <cosv/string.hxx>
25 #include <cosv/streamstr.hxx>
26 #include <cosv/std_outp.hxx>
27 #include <cosv/tpl/dyn.hxx>
28 #include <cosv/dirchain.hxx>
30 // NOT FULLY DECLARED SERVICES
31 #include <cosv/bstream.hxx>
42 DirectoryChain::DirectoryChain()
46 DirectoryChain::~DirectoryChain()
51 DirectoryChain::Set( const char * i_sSubPath
,
52 bool i_bPathIsAlwaysDir
,
53 const char * i_sDelimiter
)
55 csv_assert(i_sDelimiter
!= 0);
59 const char * pRestPath
= i_sSubPath
;
60 if (*pRestPath
== *i_sDelimiter
)
63 for ( const char * pDirEnd
= strchr(pRestPath
,*i_sDelimiter
);
65 pDirEnd
= strchr(pRestPath
,*i_sDelimiter
) )
67 aPath
.push_back( String(pRestPath
, pDirEnd
) );
68 pRestPath
= pDirEnd
+ 1;
70 if (*pRestPath
!= 0 AND i_bPathIsAlwaysDir
)
71 aPath
.push_back( String(pRestPath
) );
75 DirectoryChain::PushBack( const String
& i_sName
)
77 aPath
.push_back(i_sName
);
81 DirectoryChain::PushBack( const DirectoryChain
& i_sPath
)
83 aPath
.insert( aPath
.end(), i_sPath
.Begin(), i_sPath
.End() );
87 DirectoryChain::PopBack( uintt i_nCount
)
89 if (i_nCount
<= aPath
.size())
90 aPath
.erase( aPath
.end() - i_nCount
, aPath
.end() );
92 aPath
.erase( aPath
.begin(), aPath
.end() );
96 DirectoryChain::Get( bostream
& o_rPath
,
97 const char * i_sDelimiter
) const
99 uintt deliLen
= strlen(i_sDelimiter
);
101 for ( std::vector
<String
>::const_iterator it
= aPath
.begin();
105 o_rPath
.write( (*it
).c_str() );
106 o_rPath
.write( i_sDelimiter
, deliLen
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */