eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
SearchPath.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #if !defined(_searchpath_h_)
36 #define _searchpath_h_
37 
38 #include <list>
39 #include <string>
40 
42 // Classes
44 
49 {
50 public:
52  enum _target_type
53  {
54  kFindFile,
55  kFindDirectory
56  };
58  typedef enum _target_type target_type_t;
61 protected:
64 
65 public:
68 
69 public:
72 
74  void addSearchPath(const std::string &path);
75 
77  void setTempPath(const std::string &path);
78 
80  bool search(const std::string &base, target_type_t targetType, bool searchCwd, std::string &result);
81 
82 protected:
83  typedef std::list<std::string> string_list_t;
84  string_list_t m_paths;
85  std::string m_tempPath;
86 
88  bool isAbsolute(const std::string &path);
89 
91  std::string joinPaths(const std::string &first, const std::string &second);
92 };
93 
94 #endif // _searchpath_h_
std::string m_tempPath
Possibility to add temporary path.
Definition: SearchPath.h:85
static PathSearcher & getGlobalSearcher()
Access global path searching object.
Definition: SearchPath.cpp:55
void addSearchPath(const std::string &path)
Add a new search path to the end of the list.
Definition: SearchPath.cpp:65
bool search(const std::string &base, target_type_t targetType, bool searchCwd, std::string &result)
Attempts to locate a file by using the search paths.
Definition: SearchPath.cpp:91
void setTempPath(const std::string &path)
Set temporary path.
Definition: SearchPath.cpp:70
bool isAbsolute(const std::string &path)
Returns whether path is absolute.
Definition: SearchPath.cpp:146
std::list< std::string > string_list_t
Linked list of strings.
Definition: SearchPath.h:83
std::string joinPaths(const std::string &first, const std::string &second)
Combines two paths into a single one.
Definition: SearchPath.cpp:155
enum _target_type target_type_t
Definition: SearchPath.h:59
string_list_t m_paths
Ordered list of paths to search.
Definition: SearchPath.h:84
Handles searching a list of paths for a file.
Definition: SearchPath.h:48
PathSearcher()
Constructor.
Definition: SearchPath.h:71
static PathSearcher * s_searcher
Global search object singleton.
Definition: SearchPath.h:63