xref: /openbsd-src/gnu/llvm/lldb/bindings/interface/SBFileSpec.i (revision f6aab3d83b51b91c24247ad2c2573574de475a82)
1061da546Spatrick //===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9061da546Spatrick namespace lldb {
10061da546Spatrick 
11061da546Spatrick %feature("docstring",
12061da546Spatrick "Represents a file specification that divides the path into a directory and
13061da546Spatrick basename.  The string values of the paths are put into uniqued string pools
14061da546Spatrick for fast comparisons and efficient memory usage.
15061da546Spatrick 
16be691f3bSpatrick For example, the following code ::
17061da546Spatrick 
18061da546Spatrick         lineEntry = context.GetLineEntry()
19061da546Spatrick         self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory',
20061da546Spatrick                     exe=False,
21061da546Spatrick             substrs = [self.mydir])
22061da546Spatrick         self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename',
23061da546Spatrick                     exe=False,
24061da546Spatrick             substrs = ['main.c'])
25061da546Spatrick         self.assertTrue(lineEntry.GetLine() == self.line,
26061da546Spatrick                         'The line entry's line number should match ')
27061da546Spatrick 
28061da546Spatrick gets the line entry from the symbol context when a thread is stopped.
29061da546Spatrick It gets the file spec corresponding to the line entry and checks that
30061da546Spatrick the filename and the directory matches what we expect.") SBFileSpec;
31061da546Spatrick class SBFileSpec
32061da546Spatrick {
33061da546Spatrick public:
34061da546Spatrick     SBFileSpec ();
35061da546Spatrick 
36061da546Spatrick     SBFileSpec (const lldb::SBFileSpec &rhs);
37061da546Spatrick 
38061da546Spatrick     SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve)
39061da546Spatrick 
40061da546Spatrick     SBFileSpec (const char *path, bool resolve);
41061da546Spatrick 
42061da546Spatrick     ~SBFileSpec ();
43061da546Spatrick 
44061da546Spatrick     bool operator==(const SBFileSpec &rhs) const;
45061da546Spatrick 
46061da546Spatrick     bool operator!=(const SBFileSpec &rhs) const;
47061da546Spatrick 
48061da546Spatrick     bool
49061da546Spatrick     IsValid() const;
50061da546Spatrick 
51061da546Spatrick     explicit operator bool() const;
52061da546Spatrick 
53061da546Spatrick     bool
54061da546Spatrick     Exists () const;
55061da546Spatrick 
56061da546Spatrick     bool
57061da546Spatrick     ResolveExecutableLocation ();
58061da546Spatrick 
59061da546Spatrick     const char *
60061da546Spatrick     GetFilename() const;
61061da546Spatrick 
62061da546Spatrick     const char *
63061da546Spatrick     GetDirectory() const;
64061da546Spatrick 
65061da546Spatrick     void
66061da546Spatrick     SetFilename(const char *filename);
67061da546Spatrick 
68061da546Spatrick     void
69061da546Spatrick     SetDirectory(const char *directory);
70061da546Spatrick 
71061da546Spatrick     uint32_t
72061da546Spatrick     GetPath (char *dst_path, size_t dst_len) const;
73061da546Spatrick 
74061da546Spatrick     static int
75061da546Spatrick     ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
76061da546Spatrick 
77061da546Spatrick     bool
78061da546Spatrick     GetDescription (lldb::SBStream &description) const;
79061da546Spatrick 
80061da546Spatrick     void
81061da546Spatrick     AppendPathComponent (const char *file_or_directory);
82061da546Spatrick 
83061da546Spatrick     STRING_EXTENSION(SBFileSpec)
84061da546Spatrick 
85061da546Spatrick #ifdef SWIGPYTHON
86061da546Spatrick     %pythoncode %{
87*f6aab3d8Srobert         fullpath = property(str, None, doc='''A read only property that returns the fullpath as a python string.''')
88061da546Spatrick         basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
89061da546Spatrick         dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
90061da546Spatrick         exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')
91061da546Spatrick     %}
92061da546Spatrick #endif
93061da546Spatrick 
94061da546Spatrick };
95061da546Spatrick 
96061da546Spatrick } // namespace lldb
97