Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
resolvedfile.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "resolvedfile.h"
5
6/*!
7 * \class ResolvedFile
8 *
9 * \brief Represents a file that is reachable by QDoc based on its
10 * current configuration.
11 *
12 * Instances of this type are, generally, intended to be generated by
13 * any process that needs to query the filesystem for the presence of
14 * some files based on a user-inputted path to ensure their
15 * availability.
16 *
17 * Such an example might be when QDoc is searching for a file whose
18 * path is provided by the user, such as the one in a snippet command,
19 * that should represent a file that is reachable with the current
20 * configuration.
21 *
22 * On the other side, logic that requires access to files that are
23 * known to be user-provided, such as the quoting of snippets, can use
24 * this type at the API boundary to signal that the file should be
25 * accessible so that they avoid the need to search for the file
26 * themselves.
27 *
28 * Do note that, semantically, this type doesn't actually guarantee
29 * anything about its origin and only guarantees whatever its members
30 * guarantee.
31 *
32 * The reasoning behind this lack of enforcement is to allow for an
33 * easier testing.
34 * As many parts of QDoc might require the presence of an instance of
35 * this type, we want to be able to construct those instances without
36 * the need to pass trough whichever valid generator for them.
37 *
38 * Nonetheless, inside QDoc, any boundary that requires an instance of
39 * this type can consider it guaranteed that the instance was
40 * generated trough some appropriate logic, and consider it a bug if
41 * such is not the case.
42 *
43 * An instance of this type provides two pieces of information.
44 *
45 * The path to the file that is considered resolved, accessible trough
46 * the get_path() method and the string that was used to resolve the
47 * file in the first place, accessible trough the get_query() method.
48 *
49 * The first should be used by consumer who needs to interact with the
50 * file itself, such as reading from it or copying it.
51 *
52 * The second is provided for context and can be used when consumers
53 * need to know what the user-inputted path was in the first place,
54 * for example when presenting debug information.
55 *
56 * It is not semantically guaranteed that this two pieces of
57 * information are actually related. Any such instance for which this
58 * is true should be considered malformed. Inside QDoc, tough,
59 * consumer of this type can consider it guaranteed that no malformed
60 * instance will be passed to them, and consider it a bug if it
61 * happens otherwise.
62 */
63
64/*!
65 * \fn ResolvedFile::ResolvedFile(QString query, FilePath filepath)
66 *
67 * Constructs an instance of this type from \a query and \a filepath.
68 *
69 * \a query should represent the user-inputted path that was used to
70 * resolve the file that this instance represents.
71 *
72 * \a filepath should represent the file that is found querying the
73 * filesystem trough \a query using an appropriate logic for resolving
74 * files.
75 *
76 * An instance that is built from \a query and \a filepath is
77 * guaranteed to return a value that is equivalent to \a query when
78 * get_query() is called and a value that is equivalent to \a
79 * filepath.value() when get_path() is called.
80 */
81
82/*!
83 * \fn const QString& ResolvedFile::get_query() const
84 *
85 * Returns a string representing the user-inputted path that was used
86 * to resolve the file.
87 */
88
89/*!
90 * \fn const QString& ResolvedFile::get_path() const
91 *
92 * Returns a string representing the canonicalized path to the file
93 * that was resolved.
94 *
95 * Access to this file is to be considered guranteed to be available.
96 */