2000-11-07 07:40:31 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* $RCSfile: configpath.hxx,v $
|
2008-06-16 07:40:40 -05:00
|
|
|
* $Revision: 1.17 $
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 06:46:39 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2000-11-30 02:01:47 -06:00
|
|
|
#ifndef CONFIGMGR_CONFIGPATH_HXX_
|
|
|
|
#define CONFIGMGR_CONFIGPATH_HXX_
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
#include <rtl/ustring.hxx>
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
#ifndef INCLUDED_VECTOR
|
|
|
|
#include <vector>
|
|
|
|
#define INCLUDED_VECTOR
|
2003-06-12 04:14:01 -05:00
|
|
|
#endif // INCLUDED_VECTOR
|
2001-03-27 00:54:08 -06:00
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
namespace configmgr
|
|
|
|
{
|
|
|
|
namespace configuration
|
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
using rtl::OUString;
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
/// A tag struct for disabling validity checking on arguments
|
|
|
|
namespace argument { struct NoValidate {}; }
|
|
|
|
|
|
|
|
class Name;
|
|
|
|
class AbsolutePath;
|
|
|
|
class RelativePath;
|
|
|
|
//------------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
namespace Path { struct PackageOnly; }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// represents a name for a node in the configuration
|
|
|
|
class Name
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// A dummy parameter for disabling validity checking on arguments
|
|
|
|
typedef argument::NoValidate NoValidate;
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// construct a Name from a String (internal use only - use creation wrapper functions)
|
|
|
|
explicit Name(OUString const& aString, Path::PackageOnly) SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
public:
|
|
|
|
/// construct an empty Name
|
|
|
|
Name() SAL_THROW(()) : m_sRep() {}
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// check whether this is an empty Name
|
2001-07-05 11:05:51 -05:00
|
|
|
bool isEmpty() const SAL_THROW(()) { return m_sRep.getLength() == 0; }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// get a string representation of this Name
|
2001-07-05 11:05:51 -05:00
|
|
|
const OUString& toString() const SAL_THROW(()) { return m_sRep; }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
public:
|
|
|
|
// comparison operators
|
|
|
|
// equality (== is primary)
|
2001-07-05 11:05:51 -05:00
|
|
|
friend bool operator==(Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return !!(lhs.m_sRep == rhs.m_sRep); }
|
|
|
|
|
|
|
|
// comparison operators
|
|
|
|
// ordering (< is primary)
|
2001-07-05 11:05:51 -05:00
|
|
|
friend bool operator< (Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return !!(lhs.m_sRep < rhs.m_sRep); }
|
|
|
|
|
|
|
|
// hashing support
|
2001-07-05 11:05:51 -05:00
|
|
|
size_t hashCode() const SAL_THROW(()) { return m_sRep.hashCode(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
private:
|
|
|
|
OUString m_sRep;
|
|
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/** check if this is a well-formed name for a
|
|
|
|
config Node (excluding set elements)
|
|
|
|
*/
|
|
|
|
bool isSimpleName(OUString const& sName) SAL_THROW(());
|
|
|
|
|
|
|
|
/** check if this is a well-formed name for a
|
|
|
|
config Node (excluding set elements)
|
|
|
|
*/
|
|
|
|
inline
|
|
|
|
bool isSimpleName(Name const& sName) SAL_THROW(())
|
|
|
|
{ return isSimpleName(sName.toString()); }
|
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
/** make a <type>Name</type> out of <var>sName</var>
|
|
|
|
without full Validation.
|
|
|
|
*/
|
2001-07-05 11:05:51 -05:00
|
|
|
Name makeName(OUString const& sName, argument::NoValidate) SAL_THROW(());
|
|
|
|
|
|
|
|
/** make a <type>Name</type> out of <var>sName</var>,
|
|
|
|
which should be used for a config Node (excluding set elements)
|
|
|
|
*/
|
|
|
|
Name makeNodeName(OUString const& sName, argument::NoValidate) SAL_THROW(());
|
|
|
|
|
|
|
|
/** make a <type>Name</type> out of <var>sName</var>,
|
2001-07-27 05:59:29 -05:00
|
|
|
which should be used for a config set elements
|
2001-07-05 11:05:51 -05:00
|
|
|
*/
|
|
|
|
Name makeElementName(OUString const& sName, argument::NoValidate) SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/** make a <type>Name</type> out of <var>sName</var>,
|
|
|
|
validating that it can be used for a config Node (excluding set elements)
|
|
|
|
or template name.
|
|
|
|
@throws InvalidName
|
|
|
|
if the name is not valid for that purpose
|
|
|
|
*/
|
|
|
|
Name validateNodeName(OUString const& sName);
|
|
|
|
|
|
|
|
/** make a <type>Name</type> out of <var>sName</var>
|
|
|
|
validating that it can be used for a config set element
|
|
|
|
@throws InvalidName
|
|
|
|
if the name is not valid for that purpose
|
|
|
|
*/
|
|
|
|
Name validateElementName(OUString const& sName);
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
namespace Path
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2001-07-05 11:05:51 -05:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
/// tag for disabling validity checking on arguments
|
|
|
|
using argument::NoValidate;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
//------------------------------------------------------------------------
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
class Component
|
|
|
|
{
|
|
|
|
/// holds the contents of this path component
|
|
|
|
Name m_aName;
|
|
|
|
public:
|
|
|
|
/// construct a path component from a string, without any validation
|
|
|
|
Component(OUString const& _sName, PackageOnly) SAL_THROW(());
|
|
|
|
/// construct a path component from a Name, without any validation
|
|
|
|
Component(Name const& _aName, PackageOnly) SAL_THROW(());
|
|
|
|
|
|
|
|
/// is this component an empty name ?
|
|
|
|
bool isEmpty() const SAL_THROW(()) { return m_aName.isEmpty(); }
|
|
|
|
/// is this component a simple name ?
|
|
|
|
bool isSimpleName() const SAL_THROW(());
|
|
|
|
/// get the inner name for this component
|
|
|
|
Name getName() const SAL_THROW(());
|
|
|
|
/// get the embedded type name for this component (if any)
|
|
|
|
Name getTypeName() const SAL_THROW(());
|
|
|
|
|
|
|
|
/// get the contents of this as string (unparsed).
|
|
|
|
OUString toPathString() const SAL_THROW(()) { return m_aName.toString(); }
|
|
|
|
|
|
|
|
// hashing - for hash maps. compatible to equiv or matches
|
|
|
|
size_t hashCode() const SAL_THROW(())
|
|
|
|
{ return this->getName().hashCode(); }
|
|
|
|
|
|
|
|
/// get the contents of this as a Name (unparsed). Use with care !
|
|
|
|
Name const& getInternalName() const SAL_THROW(()) { return m_aName; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// compare taking type wildcards into account
|
|
|
|
bool matches(Component const& lhs,Component const& rhs) SAL_THROW(());
|
|
|
|
|
|
|
|
/// compare by inner names only
|
|
|
|
bool before(Component const& lhs,Component const& rhs) SAL_THROW(());
|
|
|
|
|
|
|
|
/// compare by inner names only
|
|
|
|
bool equiv(Component const& lhs,Component const& rhs) SAL_THROW(());
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// construct a empty path component
|
|
|
|
Component makeEmptyComponent() SAL_THROW(());
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/// construct a path component from a name, validating it as simple name
|
|
|
|
Component wrapSimpleName(Name const& _aName);
|
|
|
|
|
|
|
|
/// construct a path component from a type and element name, using a wildcard if no type is available
|
|
|
|
Component makeCompositeName(Name const& _aElementName, Name const& _aTypeName);
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/// construct a path component from a string, validating it as simple name
|
|
|
|
Component wrapSimpleName(OUString const& _sName);
|
|
|
|
|
|
|
|
/// construct a path component from a type and element name as strings, using a wildcard if no type is available
|
|
|
|
Component makeCompositeName(OUString const& _sElementName, OUString const& _sTypeName);
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// construct a composite path component from a element name or string, using a wildcard type
|
|
|
|
template <class NameRep>
|
|
|
|
Component wrapElementName(NameRep const& _aElementName) SAL_THROW(())
|
|
|
|
{
|
|
|
|
return makeCompositeName(_aElementName, NameRep());
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/// construct a path component from an arbitrary na,e or string
|
|
|
|
template <class NameRep>
|
|
|
|
Component wrapSafeName(NameRep const& _aName) SAL_THROW(())
|
|
|
|
{
|
|
|
|
return isSimpleName(_aName) ? wrapSimpleName(_aName) : wrapElementName(_aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** lower-level representation of a path within the configuration
|
|
|
|
<p>Keeps the data in a vector of names in reverse order! </P>
|
|
|
|
*/
|
|
|
|
class Rep
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// a sequence of element names which make up a path
|
|
|
|
typedef std::vector<Component> Components;
|
|
|
|
/// a (read-only) iterator to the element names which make up a path
|
|
|
|
typedef Components::const_reverse_iterator Iterator;
|
|
|
|
/// a (mutating) iterator to the element names which make up a path
|
|
|
|
typedef Components::reverse_iterator MutatingIterator;
|
2001-07-27 05:59:29 -05:00
|
|
|
/// type used to specify a component count
|
2001-07-05 11:05:51 -05:00
|
|
|
typedef Components::size_type size_type;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// construct an empty path
|
|
|
|
Rep() SAL_THROW(()) : m_aComponents() {}
|
|
|
|
|
|
|
|
/// construct a path consisting of a single component <var>_aName</var>
|
|
|
|
explicit Rep(Component const& _aName) SAL_THROW(()) : m_aComponents(1,_aName) {}
|
|
|
|
|
|
|
|
/// construct a path consisting of a path subrange
|
|
|
|
explicit Rep(Iterator const& _first, Iterator const& _last)
|
|
|
|
: m_aComponents(_last.base(), _first.base()) {}
|
|
|
|
|
|
|
|
/// swap contents with another instance
|
|
|
|
void swap(Rep& _aOther) SAL_THROW(()) { m_aComponents.swap(_aOther.m_aComponents); }
|
|
|
|
|
|
|
|
/// modify a path by prepending <var>aName</var>
|
|
|
|
void prepend(Component const& _aName) SAL_THROW(()) { m_aComponents.push_back(_aName); }
|
|
|
|
|
|
|
|
/// modify a path by prepending <var>aName</var>
|
|
|
|
void prepend(Rep const& _aOther) SAL_THROW(());
|
|
|
|
|
|
|
|
/// get the local name (the last component of this path)
|
|
|
|
Component const& getLocalName() const { check_not_empty(); return m_aComponents.front(); }
|
2001-02-13 09:09:53 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// get the next name (the first component of this path)
|
|
|
|
Component const& getFirstName() const { check_not_empty(); return m_aComponents.back(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// set this to the remainder after the first name (drop the first component of this path)
|
|
|
|
void dropFirstName() { check_not_empty(); m_aComponents.pop_back(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// get a /-separated string representation of this
|
|
|
|
OUString toString(bool _bAbsolute) const SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
public:
|
|
|
|
/// check if this is an empty path
|
|
|
|
bool isEmpty() const SAL_THROW(()) { return m_aComponents.empty(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// Count the components of this
|
|
|
|
size_type countComponents() const SAL_THROW(()) { return m_aComponents.size(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// Insert a component into this path
|
|
|
|
void insertComponent(MutatingIterator _it, Component _aName)
|
|
|
|
{ m_aComponents.insert(_it.base(),_aName); }
|
|
|
|
|
|
|
|
/// Remove a component from this path
|
|
|
|
void removeComponent(MutatingIterator _it) { m_aComponents.erase(_it.base()); }
|
|
|
|
|
|
|
|
/// Remove all components from this path
|
|
|
|
void clearComponents() SAL_THROW(()) { m_aComponents.clear(); }
|
|
|
|
|
|
|
|
/// get a STL style iterator to the first component
|
|
|
|
Iterator begin() const SAL_THROW(()) { return m_aComponents.rbegin(); }
|
|
|
|
/// get a STL style iterator to after the last component
|
|
|
|
Iterator end() const SAL_THROW(()) { return m_aComponents.rend(); }
|
|
|
|
|
|
|
|
/// get a STL style iterator to the first component
|
|
|
|
MutatingIterator begin_mutate() SAL_THROW(()) { return m_aComponents.rbegin(); }
|
|
|
|
/// get a STL style iterator to after the last component
|
|
|
|
MutatingIterator end_mutate() SAL_THROW(()) { return m_aComponents.rend(); }
|
|
|
|
|
|
|
|
// hashing - for hash maps
|
|
|
|
size_t hashCode() const SAL_THROW(());
|
|
|
|
|
|
|
|
/// preflight check for operations that require a non-empty path
|
|
|
|
void check_not_empty() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Components m_aComponents;
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// compare taking type wildcards into account
|
|
|
|
bool matches(Rep const& lhs,Rep const& rhs) SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// compare by inner names only
|
|
|
|
bool before(Rep const& lhs,Rep const& rhs) SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// compare by inner names only
|
|
|
|
bool equiv(Rep const& lhs,Rep const& rhs) SAL_THROW(());
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// check a path for a prefix
|
|
|
|
bool hasMatchingPrefix(Rep const& _aPath,Rep const& _aPrefix) SAL_THROW(());
|
|
|
|
|
|
|
|
/// remove a prefix from a path. Throws InvalidName if it isn't a prefix
|
|
|
|
Rep stripMatchingPrefix(Rep const& _aPath,Rep const& _aPrefix);
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// a (read-only) iterator to the element names which make up a path
|
|
|
|
typedef Rep::Iterator Iterator;
|
|
|
|
/// a (mutating) iterator to the element names which make up a path
|
|
|
|
typedef Rep::MutatingIterator MutatingIterator;
|
|
|
|
/// a (mutating) iterator to the element names which make up a path
|
|
|
|
typedef Rep::size_type size_type;
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// distinguishes which kind of path is present in a string
|
|
|
|
bool isAbsolutePath(OUString const& _sPath);
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
}
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class RelativePath
|
|
|
|
{
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Rep m_aRep;
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
/// a (read-only) iterator to the element names which make up a path
|
2001-07-05 11:05:51 -05:00
|
|
|
typedef Path::Iterator Iterator;
|
2000-11-07 07:40:31 -06:00
|
|
|
/// a (mutating) iterator to the element names which make up a path
|
2001-07-05 11:05:51 -05:00
|
|
|
typedef Path::MutatingIterator MutatingIterator;
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
// Construction
|
2001-07-05 11:05:51 -05:00
|
|
|
/// construct a relative path from <var>aString</var> throwing InvalidName for parse errors
|
|
|
|
static RelativePath parse(OUString const& _aString);
|
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
/// construct an empty relative path
|
2001-07-05 11:05:51 -05:00
|
|
|
RelativePath() SAL_THROW(()) : m_aRep() { init(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// construct a relative path having <var>aRep</var> as representation
|
|
|
|
explicit RelativePath(Path::Rep const& _aRep)
|
|
|
|
: m_aRep(_aRep) { init(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// CONVERSION: construct a relative path having <var>aName</var> as single component
|
|
|
|
RelativePath(Path::Component const& _aName) SAL_THROW(());
|
2001-02-13 09:09:53 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// build the Path that results from appending <var>aPath</var> to this
|
|
|
|
RelativePath compose(RelativePath const& _aPath) const SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// check if this is an empty path
|
2001-07-05 11:05:51 -05:00
|
|
|
bool isEmpty() const SAL_THROW(()) { return m_aRep.isEmpty(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-06-20 14:23:17 -05:00
|
|
|
/// Count the components of this
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::size_type getDepth() const SAL_THROW(()) { return m_aRep.countComponents(); }
|
2001-06-20 14:23:17 -05:00
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get the local name (the last component of this path)
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Component const& getLocalName() const { return m_aRep.getLocalName(); }
|
|
|
|
|
|
|
|
/// get the local name (the first component of this path)
|
|
|
|
Path::Component const& getFirstName() const { return m_aRep.getFirstName(); }
|
|
|
|
|
|
|
|
/// set this to the remainder of this path after the first name (drop the first component of this path)
|
|
|
|
void dropFirstName() { m_aRep.dropFirstName(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// get a /-separated string representation of this
|
2001-07-05 11:05:51 -05:00
|
|
|
OUString toString() const SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
// Iteration support
|
|
|
|
/// get a STL style iterator to the first component
|
2001-07-05 11:05:51 -05:00
|
|
|
Iterator begin() const SAL_THROW(()) { return m_aRep.begin(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get a STL style iterator to after the last component
|
2001-07-05 11:05:51 -05:00
|
|
|
Iterator end() const SAL_THROW(()) { return m_aRep.end(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// get a STL style iterator to the first component
|
2001-07-05 11:05:51 -05:00
|
|
|
MutatingIterator begin_mutate() SAL_THROW(()) { return m_aRep.begin_mutate(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get a STL style iterator to after the last component
|
2001-07-05 11:05:51 -05:00
|
|
|
MutatingIterator end_mutate() SAL_THROW(()) { return m_aRep.end_mutate(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
// Direct access - 'package' visible
|
|
|
|
/// Get a reference to (or copy of) the internal PathRep of this
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Rep const& rep() const SAL_THROW(()) { return m_aRep; }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
};
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// compare taking type wildcards into account
|
|
|
|
inline bool matches(RelativePath const& lhs,RelativePath const& rhs) SAL_THROW(())
|
|
|
|
{ return Path::matches(lhs.rep(),rhs.rep()); }
|
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class AbsolutePath
|
|
|
|
{
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Rep m_aRep;
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
/// A dummy parameter for disabling validity checking on arguments
|
|
|
|
typedef argument::NoValidate NoValidate;
|
|
|
|
|
|
|
|
/// a (read-only) iterator to the element names which make up a path
|
2001-07-05 11:05:51 -05:00
|
|
|
typedef Path::Iterator Iterator;
|
2000-11-07 07:40:31 -06:00
|
|
|
/// a (mutating) iterator to the element names which make up a path
|
2001-07-05 11:05:51 -05:00
|
|
|
typedef Path::MutatingIterator MutatingIterator;
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
// Construction
|
2001-07-05 11:05:51 -05:00
|
|
|
/// construct a absolute path from <var>aString</var> throwing InvalidName for parse errors
|
|
|
|
static AbsolutePath parse(OUString const& _aString);
|
|
|
|
|
|
|
|
/// construct a absolute path to a whole module (toplevel)
|
|
|
|
static AbsolutePath makeModulePath(Name const& _aModuleName)
|
|
|
|
{ return AbsolutePath( Path::Rep( Path::wrapSimpleName(_aModuleName) ) ); }
|
|
|
|
|
|
|
|
/// construct a absolute path to a whole module (toplevel)
|
|
|
|
static AbsolutePath makeModulePath(Name const& _aModuleName, NoValidate) SAL_THROW(());
|
|
|
|
|
|
|
|
/// construct a absolute path to a whole module (toplevel) without error checking
|
|
|
|
static AbsolutePath makeModulePath(OUString const& _aString, NoValidate) SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// construct an absolute path to the (virtual) hierarchy root
|
2001-07-05 11:05:51 -05:00
|
|
|
static AbsolutePath root() SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// construct an (otherwise invalid) substitute path for the root of a free-floating node
|
2001-07-05 11:05:51 -05:00
|
|
|
static AbsolutePath detachedRoot() SAL_THROW(());
|
|
|
|
|
|
|
|
/// construct a absolute path having <var>aRep</var> as representation
|
|
|
|
explicit AbsolutePath(Path::Rep const& _aRep) SAL_THROW(())
|
|
|
|
: m_aRep(_aRep) { init(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// build the absolute path that results from appending <var>aPath</var> to this
|
2001-07-05 11:05:51 -05:00
|
|
|
AbsolutePath compose(RelativePath const& _aPath) const SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// build the absolute path that results from removing the last component of this
|
|
|
|
AbsolutePath getParentPath() const;
|
2001-02-13 09:09:53 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// check if this is the path to the (imaginary) root node
|
|
|
|
bool isRoot() const SAL_THROW(()) { return m_aRep.isEmpty(); }
|
2008-06-16 07:40:40 -05:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2001-07-05 11:05:51 -05:00
|
|
|
/// check if this is a path to a detached node
|
|
|
|
bool isDetached() const SAL_THROW(());
|
2008-06-16 07:40:40 -05:00
|
|
|
#endif
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get the local name (the last component of this path)
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Component const& getLocalName() const { return m_aRep.getLocalName(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
Name const & getModuleName() const { return m_aRep.getFirstName().getInternalName(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// get a /-separated string representation of this
|
2001-07-05 11:05:51 -05:00
|
|
|
OUString toString() const SAL_THROW(());
|
2001-06-20 14:23:17 -05:00
|
|
|
|
|
|
|
/// Count the components of this
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::size_type getDepth() const SAL_THROW(()) { return m_aRep.countComponents(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
public:
|
|
|
|
// Iteration support
|
|
|
|
/// get a STL style iterator to the first component
|
2001-07-05 11:05:51 -05:00
|
|
|
Iterator begin() const SAL_THROW(()) { return m_aRep.begin(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get a STL style iterator to after the last component
|
2001-07-05 11:05:51 -05:00
|
|
|
Iterator end() const SAL_THROW(()) { return m_aRep.end(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
/// get a STL style iterator to the first component
|
2001-07-05 11:05:51 -05:00
|
|
|
MutatingIterator begin_mutate() SAL_THROW(()) { return m_aRep.begin_mutate(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
/// get a STL style iterator to after the last component
|
2001-07-05 11:05:51 -05:00
|
|
|
MutatingIterator end_mutate() SAL_THROW(()) { return m_aRep.end_mutate(); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
// Direct access - 'package' visible
|
|
|
|
/// Get a reference to (or copy of) the internal PathRep of this
|
2001-07-05 11:05:51 -05:00
|
|
|
Path::Rep const& rep() const SAL_THROW(()) { return m_aRep; }
|
2000-11-07 07:40:31 -06:00
|
|
|
private:
|
2001-07-05 11:05:51 -05:00
|
|
|
void init() SAL_THROW(());
|
2000-11-07 07:40:31 -06:00
|
|
|
};
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
/// compare taking type wildcards into account
|
|
|
|
inline bool matches(AbsolutePath const& lhs,AbsolutePath const& rhs) SAL_THROW(())
|
|
|
|
{ return Path::matches(lhs.rep(),rhs.rep()); }
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Derived comparison operator implementations
|
|
|
|
//------------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
inline bool operator!=(Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return !(lhs == rhs); }
|
|
|
|
//--------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
inline bool operator<=(Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return !(rhs < lhs); }
|
2001-07-05 11:05:51 -05:00
|
|
|
inline bool operator> (Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return rhs < lhs; }
|
2001-07-05 11:05:51 -05:00
|
|
|
inline bool operator>=(Name const& lhs, Name const& rhs) SAL_THROW(())
|
2000-11-07 07:40:31 -06:00
|
|
|
{ return !(lhs < rhs); }
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
namespace Path
|
|
|
|
{
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
template <class PathClass>
|
|
|
|
bool hasPrefix(PathClass const& _aPath, PathClass const& _aPrefix) SAL_THROW(())
|
|
|
|
{
|
|
|
|
return hasMatchingPrefix(_aPath.rep(),_aPrefix.rep() );
|
|
|
|
}
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
2001-07-05 11:05:51 -05:00
|
|
|
|
|
|
|
template <class PathClass>
|
|
|
|
RelativePath stripPrefix(PathClass const& _aPath, PathClass const& _aPrefix)
|
|
|
|
{
|
|
|
|
return RelativePath( stripMatchingPrefix(_aPath.rep(),_aPrefix.rep()) );
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// STL Helpers
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// a weak strict ordering considering only the name part
|
|
|
|
struct Before
|
|
|
|
{
|
|
|
|
bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
|
|
|
|
{ return before(lhs,rhs); }
|
|
|
|
bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
|
|
|
|
{ return before(lhs,rhs); }
|
|
|
|
bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return before(lhs.rep(),rhs.rep()); }
|
|
|
|
bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return before(lhs.rep(),rhs.rep()); }
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// an equality relation considering only the name part (compatible to Before)
|
|
|
|
struct Equiv
|
|
|
|
{
|
|
|
|
bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
|
|
|
|
{ return equiv(lhs,rhs); }
|
|
|
|
bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
|
|
|
|
{ return equiv(lhs,rhs); }
|
|
|
|
bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return equiv(lhs.rep(),rhs.rep()); }
|
|
|
|
bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return equiv(lhs.rep(),rhs.rep()); }
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/// a hash generator (compatible to Equiv and Before)
|
|
|
|
struct Hash
|
|
|
|
{
|
|
|
|
size_t operator()(Component const& _aObject) const SAL_THROW(())
|
|
|
|
{ return _aObject.hashCode(); }
|
|
|
|
size_t operator()(Rep const& _aObject) const SAL_THROW(())
|
|
|
|
{ return _aObject.hashCode(); }
|
|
|
|
size_t operator()(AbsolutePath const& _aObject) const SAL_THROW(())
|
|
|
|
{ return _aObject.rep().hashCode(); }
|
|
|
|
size_t operator()(RelativePath const& _aObject) const SAL_THROW(())
|
|
|
|
{ return _aObject.rep().hashCode(); }
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
/// a binary predicate that is not (!) an equivalence relation
|
|
|
|
|
|
|
|
struct Matches
|
|
|
|
{
|
|
|
|
bool operator()(Component const& lhs, Component const& rhs) const SAL_THROW(())
|
|
|
|
{ return matches(lhs,rhs); }
|
|
|
|
bool operator()(Rep const& lhs, Rep const& rhs) const SAL_THROW(())
|
|
|
|
{ return matches(lhs,rhs); }
|
|
|
|
bool operator()(AbsolutePath const& lhs, AbsolutePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return matches(lhs.rep(),rhs.rep()); }
|
|
|
|
bool operator()(RelativePath const& lhs, RelativePath const& rhs) const SAL_THROW(())
|
|
|
|
{ return matches(lhs.rep(),rhs.rep()); }
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
}
|
2000-11-07 07:40:31 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CONFIGMGR_CONFIGNAME_HXX_
|