@@ -102,38 +102,13 @@ trim_ws (tstring & str)
102
102
}
103
103
104
104
105
- } // namespace
106
-
107
-
108
-
109
- // /////////////////////////////////////////////////////////////////////////////
110
- // Properties ctors and dtor
111
- // /////////////////////////////////////////////////////////////////////////////
112
-
113
- Properties::Properties ()
114
- {
115
- }
116
-
117
-
118
-
119
- Properties::Properties (tistream& input)
120
- {
121
- init (input);
122
- }
123
-
124
-
125
-
126
- Properties::Properties (const tstring& inputFile, unsigned flags)
105
+ void
106
+ imbue_file_from_flags (tistream & file, unsigned flags)
127
107
{
128
- if (inputFile.empty ())
129
- return ;
130
-
131
- tifstream file;
132
-
133
- switch (flags & (fEncodingMask << fEncodingShift ))
108
+ switch (flags & (Properties::fEncodingMask << Properties::fEncodingShift ))
134
109
{
135
110
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF8_FACET) && defined (UNICODE)
136
- case fUTF8 :
111
+ case Properties:: fUTF8 :
137
112
file.imbue (
138
113
std::locale (file.getloc (),
139
114
new std::codecvt_utf8<tchar, 0x10FFFF ,
@@ -142,15 +117,15 @@ Properties::Properties(const tstring& inputFile, unsigned flags)
142
117
#endif
143
118
144
119
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF16_FACET) && defined (UNICODE)
145
- case fUTF16 :
120
+ case Properties:: fUTF16 :
146
121
file.imbue (
147
122
std::locale (file.getloc (),
148
123
new std::codecvt_utf16<tchar, 0x10FFFF ,
149
124
static_cast <std::codecvt_mode>(std::consume_header | std::little_endian)>));
150
125
break ;
151
126
152
127
#elif defined (UNICODE) && defined (WIN32)
153
- case fUTF16 :
128
+ case Properties:: fUTF16 :
154
129
file.imbue (
155
130
std::locale (file.getloc (),
156
131
// TODO: This should actually be a custom "null" facet
@@ -161,19 +136,53 @@ Properties::Properties(const tstring& inputFile, unsigned flags)
161
136
#endif
162
137
163
138
#if defined (LOG4CPLUS_HAVE_CODECVT_UTF32_FACET) && defined (UNICODE)
164
- case fUTF32 :
139
+ case Properties:: fUTF32 :
165
140
file.imbue (
166
141
std::locale (file.getloc (),
167
142
new std::codecvt_utf32<tchar, 0x10FFFF ,
168
143
static_cast <std::codecvt_mode>(std::consume_header | std::little_endian)>));
169
144
break ;
170
145
#endif
171
146
172
- case fUnspecEncoding :;
147
+ case Properties:: fUnspecEncoding :;
173
148
default :
174
149
// Do nothing.
175
150
;
176
151
}
152
+ }
153
+
154
+
155
+ } // namespace
156
+
157
+
158
+
159
+ // /////////////////////////////////////////////////////////////////////////////
160
+ // Properties ctors and dtor
161
+ // /////////////////////////////////////////////////////////////////////////////
162
+
163
+ Properties::Properties ()
164
+ : flags (0 )
165
+ {
166
+ }
167
+
168
+
169
+
170
+ Properties::Properties (tistream& input)
171
+ : flags (0 )
172
+ {
173
+ init (input);
174
+ }
175
+
176
+
177
+
178
+ Properties::Properties (const tstring& inputFile, unsigned f)
179
+ : flags (f)
180
+ {
181
+ if (inputFile.empty ())
182
+ return ;
183
+
184
+ tifstream file;
185
+ imbue_file_from_flags (file, flags);
177
186
178
187
file.open (LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME (inputFile).c_str (),
179
188
std::ios::binary);
@@ -216,6 +225,24 @@ Properties::init(tistream& input)
216
225
trim_ws (value);
217
226
setProperty (key, value);
218
227
}
228
+ else if (buffer.compare (0 , 7 , LOG4CPLUS_TEXT (" include" )) == 0
229
+ && buffer.size () >= 7 + 1 + 1
230
+ && is_space (buffer[7 ]))
231
+ {
232
+ tstring included (buffer, 8 ) ;
233
+ trim_ws (included);
234
+
235
+ tifstream file;
236
+ imbue_file_from_flags (file, flags);
237
+
238
+ file.open (LOG4CPLUS_FSTREAM_PREFERED_FILE_NAME (included).c_str (),
239
+ std::ios::binary);
240
+ if (! file.good ())
241
+ helpers::getLogLog ().error (
242
+ LOG4CPLUS_TEXT (" could not open file " ) + included);
243
+
244
+ init (file);
245
+ }
219
246
}
220
247
}
221
248
0 commit comments