eRPC Generator (erpcgen)  Rev. 1.7.2
NXP Semiconductors
SearchPath.h
1 /*
2  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 #if !defined(_searchpath_h_)
10 #define _searchpath_h_
11 
12 #include <list>
13 #include <string>
14 
16 // Classes
18 
23 {
24 public:
26  enum _target_type
27  {
28  kFindFile,
29  kFindDirectory
30  };
32  typedef enum _target_type target_type_t;
35 protected:
38 
39 public:
42 
43 public:
46 
48  void addSearchPath(const std::string &path);
49 
51  void setTempPath(const std::string &path);
52 
54  bool search(const std::string &base, target_type_t targetType, bool searchCwd, std::string &result);
55 
56 protected:
57  typedef std::list<std::string> string_list_t;
58  string_list_t m_paths;
59  std::string m_tempPath;
60 
62  bool isAbsolute(const std::string &path);
63 
65  std::string joinPaths(const std::string &first, const std::string &second);
66 };
67 
68 #endif // _searchpath_h_
std::string m_tempPath
Possibility to add temporary path.
Definition: SearchPath.h:59
static PathSearcher & getGlobalSearcher()
Access global path searching object.
Definition: SearchPath.cpp:29
void addSearchPath(const std::string &path)
Add a new search path to the end of the list.
Definition: SearchPath.cpp:39
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:65
void setTempPath(const std::string &path)
Set temporary path.
Definition: SearchPath.cpp:44
bool isAbsolute(const std::string &path)
Returns whether path is absolute.
Definition: SearchPath.cpp:120
std::list< std::string > string_list_t
Linked list of strings.
Definition: SearchPath.h:57
std::string joinPaths(const std::string &first, const std::string &second)
Combines two paths into a single one.
Definition: SearchPath.cpp:129
enum _target_type target_type_t
Definition: SearchPath.h:33
string_list_t m_paths
Ordered list of paths to search.
Definition: SearchPath.h:58
Handles searching a list of paths for a file.
Definition: SearchPath.h:22
PathSearcher()
Constructor.
Definition: SearchPath.h:45
static PathSearcher * s_searcher
Global search object singleton.
Definition: SearchPath.h:37