2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file xmltooling/util/PathResolver.h
24 * Resolves local filenames into absolute pathnames.
27 #if !defined(__xmltooling_pathres_h__)
28 #define __xmltooling_pathres_h__
30 #include <xmltooling/base.h>
34 namespace xmltooling {
36 * Resolves local filenames into absolute pathnames.
38 class XMLTOOL_API PathResolver
40 MAKE_NONCOPYABLE(PathResolver);
43 virtual ~PathResolver();
45 /** Types of file resources to resolve. */
55 * Set the default package to use when resolving files.
57 * @param pkgname name of default package to use
59 virtual void setDefaultPackageName(const char* pkgname);
62 * Set the default installation prefix to use when resolving files.
64 * @param prefix name of default prefix to use
66 virtual void setDefaultPrefix(const char* prefix);
69 * Set the lib directory to use when resolving files.
70 * <p>If relative, the default prefix will be prepended.
72 * @param dir the library directory to use
74 virtual void setLibDir(const char* dir);
77 * Set the log directory to use when resolving files.
78 * <p>If relative, the default prefix will be prepended.
80 * @param dir the log directory to use
82 virtual void setLogDir(const char* dir);
85 * Set the XML directory to use when resolving files.
86 * <p>If relative, the default prefix will be prepended.
88 * @param dir the XML directory to use
90 virtual void setXMLDir(const char* dir);
93 * Set the run directory to use when resolving files.
94 * <p>If relative, the default prefix will be prepended.
96 * @param dir the run directory to use
98 virtual void setRunDir(const char* dir);
101 * Set the config directory to use when resolving files.
102 * <p>If relative, the default prefix will be prepended.
104 * @param dir the config directory to use
106 virtual void setCfgDir(const char* dir);
109 * Changes the input filename into an absolute pathname to the same file.
111 * @param s filename to resolve
112 * @param filetype type of file being resolved
113 * @param pkgname application package name to use in resolving the file (or nullptr for the default)
114 * @param prefix installation prefix to use in resolving the file (or nullptr for the default)
116 * @return a const reference to the input string
118 virtual const std::string& resolve(std::string& s, file_type_t filetype, const char* pkgname=nullptr, const char* prefix=nullptr) const;
121 bool isAbsolute(const char* s) const;
123 std::string m_defaultPackage,m_defaultPrefix,m_lib,m_log,m_xml,m_run,m_cfg;
127 #endif /* __xmltooling_pathres_h__ */