/src/node/src/node_dotenv.h
Line  | Count  | Source  | 
1  |  | #ifndef SRC_NODE_DOTENV_H_  | 
2  |  | #define SRC_NODE_DOTENV_H_  | 
3  |  |  | 
4  |  | #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS  | 
5  |  |  | 
6  |  | #include "util-inl.h"  | 
7  |  | #include "v8.h"  | 
8  |  |  | 
9  |  | #include <map>  | 
10  |  |  | 
11  |  | namespace node { | 
12  |  |  | 
13  |  | class Dotenv { | 
14  |  |  public:  | 
15  |  |   enum ParseResult { Valid, FileError, InvalidContent }; | 
16  |  |   struct env_file_data { | 
17  |  |     std::string path;  | 
18  |  |     bool is_optional;  | 
19  |  |   };  | 
20  |  |  | 
21  | 72  |   Dotenv() = default;  | 
22  |  |   Dotenv(const Dotenv& d) = delete;  | 
23  |  |   Dotenv(Dotenv&& d) noexcept = default;  | 
24  |  |   Dotenv& operator=(Dotenv&& d) noexcept = default;  | 
25  |  |   Dotenv& operator=(const Dotenv& d) = delete;  | 
26  | 0  |   ~Dotenv() = default;  | 
27  |  |  | 
28  |  |   void ParseContent(const std::string_view content);  | 
29  |  |   ParseResult ParsePath(const std::string_view path);  | 
30  |  |   void AssignNodeOptionsIfAvailable(std::string* node_options) const;  | 
31  |  |   v8::Maybe<void> SetEnvironment(Environment* env);  | 
32  |  |   v8::MaybeLocal<v8::Object> ToObject(Environment* env) const;  | 
33  |  |  | 
34  |  |   static std::vector<env_file_data> GetDataFromArgs(  | 
35  |  |       const std::vector<std::string>& args);  | 
36  |  |  | 
37  |  |  private:  | 
38  |  |   std::map<std::string, std::string> store_;  | 
39  |  | };  | 
40  |  |  | 
41  |  | }  // namespace node  | 
42  |  |  | 
43  |  | #endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS  | 
44  |  |  | 
45  |  | #endif  // SRC_NODE_DOTENV_H_  |