resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmXCOFF.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4
5 #include "cmConfigure.h" // IWYU pragma: keep
6
7 #include <iosfwd>
8 #include <memory>
9 #include <string>
10
11 #include <cm/optional>
12 #include <cm/string_view>
13
14 #if !defined(CMake_USE_XCOFF_PARSER)
15 #  error "This file may be included only if CMake_USE_XCOFF_PARSER is enabled."
16 #endif
17
18 class cmXCOFFInternal;
19
20 /** \class cmXCOFF
21  * \brief XCOFF parser.
22  */
23 class cmXCOFF
24 {
25 public:
26   enum class Mode
27   {
28     ReadOnly,
29     ReadWrite
30   };
31
32   /** Construct with the name of the XCOFF input file to parse.  */
33   cmXCOFF(const char* fname, Mode = Mode::ReadOnly);
34
35   /** Destruct.   */
36   ~cmXCOFF();
37
38   cmXCOFF(cmXCOFF&&) noexcept;
39   cmXCOFF(cmXCOFF const&) = delete;
40   cmXCOFF& operator=(cmXCOFF&&) noexcept;
41   cmXCOFF& operator=(cmXCOFF const&) = delete;
42
43   /** Get the error message if any.  */
44   std::string const& GetErrorMessage() const { return this->ErrorMessage; }
45
46   /** Boolean conversion.  True if the XCOFF file is valid.  */
47   explicit operator bool() const { return this->Valid(); }
48
49   /** Get the LIBPATH (RPATH) parsed from the file, if any.  */
50   cm::optional<cm::string_view> GetLibPath() const;
51
52   /** Set the LIBPATH (RPATH).
53       Works only if cmXCOFF was constructed with Mode::ReadWrite.  */
54   bool SetLibPath(cm::string_view libPath);
55
56   /** Remove the LIBPATH (RPATH).
57       Works only if cmXCOFF was constructed with Mode::ReadWrite.  */
58   bool RemoveLibPath();
59
60 private:
61   friend class cmXCOFFInternal;
62   bool Valid() const;
63   std::unique_ptr<cmXCOFFInternal> Internal;
64   std::string ErrorMessage;
65 };