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. */
56 * Set the default package to use when resolving files.
58 * @param pkgname name of default package to use
60 virtual void setDefaultPackageName(const char* pkgname);
63 * Set the default installation prefix to use when resolving files.
65 * @param prefix name of default prefix to use
67 virtual void setDefaultPrefix(const char* prefix);
70 * Set the lib directory to use when resolving files.
71 * <p>If relative, the default prefix will be prepended.
73 * @param dir the library directory to use
75 virtual void setLibDir(const char* dir);
78 * Set the log directory to use when resolving files.
79 * <p>If relative, the default prefix will be prepended.
81 * @param dir the log directory to use
83 virtual void setLogDir(const char* dir);
86 * Set the XML directory to use when resolving files.
87 * <p>If relative, the default prefix will be prepended.
89 * @param dir the XML directory to use
91 virtual void setXMLDir(const char* dir);
94 * Set the run directory to use when resolving files.
95 * <p>If relative, the default prefix will be prepended.
97 * @param dir the run directory to use
99 virtual void setRunDir(const char* dir);
102 * Set the config directory to use when resolving files.
103 * <p>If relative, the default prefix will be prepended.
105 * @param dir the config directory to use
107 virtual void setCfgDir(const char* dir);
110 * Set the cache directory to use when resolving files.
111 * <p>If relative, the default prefix will be prepended.
113 * @param dir the cache directory to use
115 virtual void setCacheDir(const char* dir);
118 * Changes the input filename into an absolute pathname to the same file.
120 * @param s filename to resolve
121 * @param filetype type of file being resolved
122 * @param pkgname application package name to use in resolving the file (or nullptr for the default)
123 * @param prefix installation prefix to use in resolving the file (or nullptr for the default)
125 * @return a const reference to the input string
127 virtual const std::string& resolve(std::string& s, file_type_t filetype, const char* pkgname=nullptr, const char* prefix=nullptr) const;
130 bool isAbsolute(const char* s) const;
132 std::string m_defaultPackage,m_defaultPrefix,m_lib,m_log,m_xml,m_run,m_cfg,m_cache;
136 #endif /* __xmltooling_pathres_h__ */