+bool TextClass::validate(std::string const & str)
+{
+ TextClass tc;
+ return tc.read(str, VALIDATION);
+}
+
+
+bool TextClass::read(std::string const & str, ReadType rt)
+{
+ Lexer lexrc(textClassTags);
+ istringstream is(str);
+ lexrc.setStream(is);
+ ReturnValues retval = read(lexrc, rt);
+
+ if (retval != FORMAT_MISMATCH)
+ return retval == OK;
+
+ // write the layout string to a temporary file
+ FileName const tempfile = FileName::tempName("TextClass_read");
+ ofstream os(tempfile.toFilesystemEncoding().c_str());
+ if (!os) {
+ LYXERR0("Unable to create temporary file");
+ return false;
+ }
+ os << str;
+ os.close();
+
+ // now try to convert it
+ bool const worx = convertLayoutFormat(tempfile, rt);
+ if (!worx) {
+ LYXERR0("Unable to convert internal layout information to format "
+ << FORMAT);
+ }
+ tempfile.removeFile();
+ return worx;
+}
+
+
+// Reads a textclass structure from file.
+TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
+{