Index: cpp/frams/param/param.cpp
===================================================================
--- cpp/frams/param/param.cpp	(revision 704)
+++ cpp/frams/param/param.cpp	(revision 720)
@@ -10,4 +10,5 @@
 #include "common/log.h"
 #include <frams/util/sstringutils.h>
+#include <common/virtfile/stringfile.h>
 
 //#define SAVE_ALL_NAMES
@@ -356,5 +357,5 @@
 }
 
-void SimpleAbstractParam::save2(SString& f, void *defdata, bool addcr, bool all_names)
+void SimpleAbstractParam::saveSingleLine(SString& f, void *defdata, bool addcr, bool all_names)
 { // defdata!=NULL -> does not save default values
 	const char *p;
@@ -421,5 +422,55 @@
 }
 
-int ParamInterface::load(VirtFILE* f, bool warn_unknown_fields, bool *abortable, int *linenum)
+int ParamInterface::load(FileFormat format, VirtFILE* f, LoadOptions *options)
+{
+	LoadOptions default_options;
+	if (options == NULL)
+		options = &default_options;
+	switch (format)
+	{
+	case FormatMultiLine:
+		return loadMultiLine(f, *options);
+
+	case FormatSingleLine:
+	{
+		StringFILE *sf = dynamic_cast<StringFILE*>(f);
+		SString s;
+		if (sf)
+		{
+			s = sf->getString().c_str();
+			options->offset += sf->Vtell();
+		}
+		else
+		{
+			if (!loadSStringLine(f, s))
+				return -1;
+		}
+		return loadSingleLine(s, *options);
+	}
+	}
+	return -1;
+}
+
+int ParamInterface::load(FileFormat format, const SString &s, LoadOptions *options)
+{
+	LoadOptions default_options;
+	if (options == NULL)
+		options = &default_options;
+	switch (format)
+	{
+	case FormatMultiLine:
+	{
+		string std_string(s.c_str());
+		StringFILE f(std_string);
+		return loadMultiLine(&f, *options);
+	}
+
+	case FormatSingleLine:
+		return loadSingleLine(s, *options);
+	}
+	return -1;
+}
+
+int ParamInterface::loadMultiLine(VirtFILE* f, LoadOptions &options)
 {
 	SString buf;
@@ -434,7 +485,7 @@
 	if ((i = findId("beforeLoad")) >= 0)
 		call(i, NULL, NULL);
-	while (((!abortable) || (!*abortable)) && loadSStringLine(f, buf))
-	{
-		if (linenum) (*linenum)++;
+	while (((!options.abortable) || (!*options.abortable)) && loadSStringLine(f, buf))
+	{
+		if (options.linenum) (*options.linenum)++;
 		const char* t = buf.c_str();
 		p0 = t; while (isblank(*p0)) p0++;
@@ -448,6 +499,6 @@
 			case 0:
 				logPrintf("ParamInterface", "load", LOG_WARN, "Ignored unexpected line %s while reading object '%s'",
-					linenum ?
-					SString::sprintf("%d", *linenum).c_str()
+					options.linenum ?
+					SString::sprintf("%d", *options.linenum).c_str()
 					: SString::sprintf("'%s'", p0).c_str(),
 					getName());
@@ -472,6 +523,6 @@
 				{
 					fileinfo = SString::sprintf(" while reading from '%s'", fname);
-					if (linenum)
-						fileinfo += SString::sprintf(" (line %d)", *linenum);
+					if (options.linenum)
+						fileinfo += SString::sprintf(" (line %d)", *options.linenum);
 				}
 				logPrintf("ParamInterface", "load", LOG_WARN, "Multiple '%s.%s' fields found%s", getName(), id(i), fileinfo.c_str());
@@ -496,9 +547,9 @@
 					int ch; while ((ch = f->Vgetc()) != EOF) if (ch == '\n') break;
 					unquoteTilde(s);
-					if (linenum && (flags(i)&PARAM_LINECOMMENT))
-						s = SString::sprintf("@file %s\n@line %d\n", f->VgetPath(), *linenum + 1) + s;
+					if (options.linenum && (flags(i)&PARAM_LINECOMMENT))
+						s = SString::sprintf("@file %s\n@line %d\n", f->VgetPath(), *options.linenum + 1) + s;
 					set(i, s.c_str());
-					if (linenum)
-						(*linenum) += lfcount;
+					if (options.linenum)
+						(*options.linenum) += lfcount;
 				}
 				else
@@ -510,5 +561,5 @@
 			}
 		}
-		else if (warn_unknown_fields)
+		else if (options.warn_unknown_fields)
 		{
 			SString name(p0, p_len);
@@ -521,5 +572,5 @@
 			if (!readUntilTilde(f, s))
 				closingTildeError(this, f, -1);
-			if (linenum)
+			if (options.linenum)
 			{
 				const char* tmp = s.c_str();
@@ -530,5 +581,5 @@
 					lfcount++; tmp++;
 					}
-				(*linenum) += lfcount;
+				(*options.linenum) += lfcount;
 			}
 			int ch; while ((ch = f->Vgetc()) != EOF) if (ch == '\n') break;
@@ -705,5 +756,5 @@
 {
 	const char *t;
-	if (((*(t = type(i))) == 'd') && (strchr(t, '~')!=NULL)) //type is int and contains enum labels
+	if (((*(t = type(i))) == 'd') && (strchr(t, '~') != NULL)) //type is int and contains enum labels
 	{
 		paInt mn, mx, def;
@@ -1131,5 +1182,5 @@
 }
 
-int ParamInterface::load2(const SString &s, int &poz)
+int ParamInterface::loadSingleLine(const SString &s, LoadOptions &options)
 {
 	int i; // the index number of the parameter
@@ -1145,8 +1196,8 @@
 	SString tmpvalue;
 	bool parse_failed = false;
-	if (poz >= s.len()) return fields_loaded;
-	t = s.c_str() + poz;
-
-	lin = getline(s, poz, len); // all fields must be encoded in a single line
+	if (options.offset >= s.len()) return fields_loaded;
+	t = s.c_str() + options.offset;
+
+	lin = getline(s, options.offset, len); // all fields must be encoded in a single line
 	if (!len) return fields_loaded; // empty line = end
 	i = 0;
@@ -1241,5 +1292,6 @@
 #endif
 	}
-	return fields_loaded | (parse_failed ? LOAD2_PARSE_FAILED : 0);
+	if (parse_failed) options.parse_failed = true;
+	return fields_loaded;
 }
 
