1 #pragma once
2 
3 #include "export.h"
4 
5 namespace hocon {
6 
7     /**
8      * A set of options related to resolving substitutions. Substitutions use the
9      * <code>${foo.bar}</code> syntax and are documented in the <a
10      * href="https://github.com/typesafehub/config/blob/master/HOCON.md">HOCON</a>
11      * spec.
12      * <p>
13      * Typically this class would be used with the method
14      * {@link config#resolve(config_resolve_options)}.
15      * <p>
16      * This object is immutable, so the "setters" return a new object.
17      * <p>
18      * Here is an example of creating a custom {@code config_resolve_options}:
19      *
20      * <pre>
21      *     config_resolve_options options = config_resolve_options()
22      *         .set_use_system_environment(false)
23      * </pre>
24      * <p>
25      * In addition to {@link config_resolve_options}, there's a prebuilt
26      * {@link config_resolve_options#no_system} which avoids looking at any system
27      * environment variables or other external system information. (Right now,
28      * environment variables are the only example.)
29      */
30     class LIBCPP_HOCON_EXPORT config_resolve_options {
31     public:
32         /**
33          * Returns the default resolve options. By default the system environment
34          * will be used and unresolved substitutions are not allowed.
35          *
36          * @return the default resolve options
37          */
38         config_resolve_options(bool use_system_environment = true, bool allow_unresolved = false);
39 
40         /**
41          * Returns resolve options that disable any reference to "system" data
42          * (currently, this means environment variables).
43          *
44          * @return the resolve options with env variables disabled
45          */
46         config_resolve_options set_use_system_environment(bool value) const;
47 
48         /**
49          * Returns whether the options enable use of system environment variables.
50          * This method is mostly used by the config lib internally, not by
51          * applications.
52          *
53          * @return true if environment variables should be used
54          */
55         bool get_use_system_environment() const;
56 
57         /**
58          * Returns options with "allow unresolved" set to the given value. By
59          * default, unresolved substitutions are an error. If unresolved
60          * substitutions are allowed, then a future attempt to use the unresolved
61          * value may fail, but {@link config#resolve(config_resolve_options)} itself
62          * will not throw.
63          *
64          * @param value
65          *            true to silently ignore unresolved substitutions.
66          * @return options with requested setting for whether to allow substitutions
67          */
68         config_resolve_options set_allow_unresolved(bool value) const;
69 
70         /**
71          * Returns whether the options allow unresolved substitutions. This method
72          * is mostly used by the config lib internally, not by applications.
73          *
74          * @return true if unresolved substitutions are allowed
75          */
76         bool get_allow_unresolved() const;
77 
78     private:
79         bool _use_system_environment;
80         bool _allow_unresovled;
81     };
82 
83 }  // namespace hocon
84