42cf5bc1 |
1 | // Created on: 2018-03-15 |
2 | // Created by: Stephan GARNAUD (ARM) |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _OSD_Environment_HeaderFile |
18 | #define _OSD_Environment_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TCollection_AsciiString.hxx> |
25 | #include <OSD_Error.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | class Standard_ConstructionError; |
29 | class Standard_NullObject; |
30 | class OSD_OSDError; |
31 | class TCollection_AsciiString; |
32 | |
33 | |
34 | //! Management of system environment variables |
35 | //! An environment variable is composed of a variable name |
36 | //! and its value. |
37 | //! |
38 | //! To be portable among various systems, environment variables |
39 | //! are local to a process. |
40 | class OSD_Environment |
41 | { |
42 | public: |
43 | |
44 | DEFINE_STANDARD_ALLOC |
45 | |
46 | |
47 | //! Creates the object Environment. |
48 | Standard_EXPORT OSD_Environment(); |
49 | |
50 | //! Creates an Environment variable initialized with value |
51 | //! set to an empty AsciiString. |
52 | Standard_EXPORT OSD_Environment(const TCollection_AsciiString& Name); |
53 | |
54 | //! Creates an Environment variable initialized with Value. |
55 | Standard_EXPORT OSD_Environment(const TCollection_AsciiString& Name, const TCollection_AsciiString& Value); |
56 | |
57 | //! Changes environment variable value. |
58 | //! Raises ConstructionError either if the string contains |
59 | //! characters not in range of ' '...'~' or if the string |
60 | //! contains the character '$' which is forbiden. |
61 | Standard_EXPORT void SetValue (const TCollection_AsciiString& Value); |
62 | |
63 | //! Gets the value of an environment variable |
64 | Standard_EXPORT TCollection_AsciiString Value(); |
65 | |
66 | //! Changes environment variable name. |
67 | //! Raises ConstructionError either if the string contains |
68 | //! characters not in range of ' '...'~' or if the string |
69 | //! contains the character '$' which is forbiden. |
70 | Standard_EXPORT void SetName (const TCollection_AsciiString& name); |
71 | |
72 | //! Gets the name of <me>. |
73 | Standard_EXPORT TCollection_AsciiString Name() const; |
74 | |
75 | //! Sets the value of an environment variable |
76 | //! into system (physically). |
77 | Standard_EXPORT void Build(); |
78 | |
79 | //! Removes (physically) an environment variable |
80 | Standard_EXPORT void Remove(); |
81 | |
82 | //! Returns TRUE if an error occurs |
83 | Standard_EXPORT Standard_Boolean Failed() const; |
84 | |
85 | //! Resets error counter to zero |
86 | Standard_EXPORT void Reset(); |
87 | |
88 | //! Raises OSD_Error |
89 | Standard_EXPORT void Perror(); |
90 | |
91 | //! Returns error number if 'Failed' is TRUE. |
92 | Standard_EXPORT Standard_Integer Error() const; |
93 | |
94 | |
95 | |
96 | |
97 | protected: |
98 | |
99 | |
100 | |
101 | |
102 | |
103 | private: |
104 | |
105 | |
106 | |
107 | TCollection_AsciiString myName; |
108 | TCollection_AsciiString myValue; |
109 | OSD_Error myError; |
110 | |
111 | |
112 | }; |
113 | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | #endif // _OSD_Environment_HeaderFile |