GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
kpse.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2016-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_kpse_h)
27 #define octave_kpse_h 1
28 
29 #include "octave-config.h"
30 
31 #include <list>
32 #include <string>
33 
34 // A way to step through a path, extracting one directory name at a
35 // time.
36 
38 {
39 public:
40 
41  kpse_path_iterator () = delete;
42 
43  kpse_path_iterator (const std::string& p)
44  : m_path (p), m_b (0), m_e (0), m_len (m_path.length ())
45  {
46  set_end ();
47  }
48 
49  OCTAVE_DEFAULT_COPY_MOVE_CTOR (kpse_path_iterator)
50  OCTAVE_DISABLE_COPY_MOVE_ASGN (kpse_path_iterator)
51 
52  ~kpse_path_iterator () = default;
53 
55  {
56  kpse_path_iterator retval (*this);
57  next ();
58  return retval;
59  }
60 
61  std::string operator * () { return m_path.substr (m_b, m_e-m_b); }
62 
63  bool operator != (const std::size_t sz) { return m_b != sz; }
64 
65 private:
66 
67  const std::string& m_path;
68  std::size_t m_b;
69  std::size_t m_e;
70  std::size_t m_len;
71 
72  void set_end ();
73  void next ();
74 };
75 
76 extern unsigned int kpse_debug;
77 
78 extern std::list<std::string>
79 kpse_all_path_search (const std::string& path, const std::string& name);
80 
81 extern std::list<std::string>
82 kpse_all_path_find_first_of (const std::string& path,
83  const std::list<std::string>& names);
84 
85 extern std::string
86 kpse_element_dir (const std::string& elt);
87 
88 extern std::list<std::string>
89 kpse_all_path_search (const std::string& path, const std::string& name);
90 
91 extern std::string
92 kpse_path_expand (const std::string& path);
93 
94 extern std::string
95 kpse_path_find_first_of (const std::string& path,
96  const std::list<std::string>& names);
97 
98 extern std::string
99 kpse_path_search (const std::string& path, const std::string& name);
100 
101 #endif
std::string operator*()
Definition: kpse.h:61
kpse_path_iterator operator++(int)
Definition: kpse.h:54
~kpse_path_iterator()=default
kpse_path_iterator()=delete
bool operator!=(const std::size_t sz)
Definition: kpse.h:63
kpse_path_iterator(const std::string &p)
Definition: kpse.h:43
std::string kpse_path_find_first_of(const std::string &path, const std::list< std::string > &names)
Definition: kpse.cc:730
std::string kpse_element_dir(const std::string &elt)
Definition: kpse.cc:1025
std::string kpse_path_expand(const std::string &path)
Definition: kpse.cc:757
std::list< std::string > kpse_all_path_find_first_of(const std::string &path, const std::list< std::string > &names)
Definition: kpse.cc:746
unsigned int kpse_debug
Definition: kpse.cc:91
std::list< std::string > kpse_all_path_search(const std::string &path, const std::string &name)
Definition: kpse.cc:566
std::string kpse_path_search(const std::string &path, const std::string &name)
Definition: kpse.cc:555