+#if wxUSE_STREAMS
+
+wxFileConfig::wxFileConfig(wxInputStream &inStream)
+{
+ // always local_file when this constructor is called (?)
+ SetStyle(GetStyle() | wxCONFIG_USE_LOCAL_FILE);
+
+ m_pCurrentGroup =
+ m_pRootGroup = new wxFileConfigGroup(NULL, "", this);
+
+ m_linesHead =
+ m_linesTail = NULL;
+
+ // translate everything to the current (platform-dependent) line
+ // termination character
+ wxString strTrans;
+ {
+ wxString strTmp;
+
+ char buf[1024];
+ while ( !inStream.Read(buf, WXSIZEOF(buf)).Eof() )
+ strTmp.append(wxConvertMB2WX(buf), inStream.LastRead());
+
+ strTmp.append(wxConvertMB2WX(buf), inStream.LastRead());
+
+ strTrans = wxTextBuffer::Translate(strTmp);
+ }
+
+ wxMemoryText memText;
+
+ // Now we can add the text to the memory text. To do this we extract line
+ // by line from the translated string, until we've reached the end.
+ //
+ // VZ: all this is horribly inefficient, we should do the translation on
+ // the fly in one pass saving both memory and time (TODO)
+
+ const wxChar *pEOL = wxTextBuffer::GetEOL(wxTextBuffer::typeDefault);
+ const size_t EOLLen = wxStrlen(pEOL);
+
+ int posLineStart = strTrans.Find(pEOL);
+ while ( posLineStart != -1 )
+ {
+ wxString line(strTrans.Left(posLineStart));
+
+ memText.AddLine(line);
+
+ strTrans = strTrans.Mid(posLineStart + EOLLen);
+
+ posLineStart = strTrans.Find(pEOL);
+ }
+
+ // also add whatever we have left in the translated string.
+ memText.AddLine(strTrans);
+
+ // Finally we can parse it all.
+ Parse(memText, TRUE /* local */);
+
+ SetRootPath();
+}
+
+#endif // wxUSE_STREAMS
+