c++ - How do I get a string or stream into a CStreamFile? -
This question might look a little too specific, but I think I want to give it a shot here because I have found That's some great programming answers in the past.
I am modifying the open source program for the project on which I am working. I have visited and posted the tinycard message board, but I did not find the answer, which I am looking for. I'm having trouble wrapping my head about integrating a small XML converter class, I wrote in the loading function of tinycad.
A small background about me: I have no experience with MFC or Visual Studio, but this is what I use to use for C ++ and iostream syntax (cout, cin , New, etc.), so I do not use the old C code (like printf, sprintf, malloc, alloc, etc.), I usually want to finish my programs in QT I write, Ekin has told me that the project I would like to modify an existing program to save time. I do not know if I want to learn something completely foreign, then he will save that time, but I keep back.
I have read a small class in an XML file which is a separate structured XML file that reads inside the tinycad. My class changes it and outputs an intermediate XML file. Well, I do not want to extract an intermediate file. I have modified it to save the output as string (using string datatype from standard C ++ iostream library). I want to get this string in a stream so that tinycad can open the file, make a conversion, and then loading.
My class is called like this:
Std :: string blah; Char * filename = "library.xml"; XMLopen myXML (filename, blah);
So it takes the file name in, opens the file, parses the information related to the file, places the information in the XML structure of the tinycad, and the XML code forms the string Saves in the passage from the context.
I had an idea that using istringstream to create stream, but he was not playing well with CFile I tried to do this:
istringstream ins ; // Announce an input string stream. Ins.str (blah); // First open the stream to save the CFile theFile (INS); Below is the code in Tynice that opens and loads the selected XML file: void ClibraryStore :: LoadXML (const TCHAR * filename) { // First open the stream to save the file to CFile; // To save as a ceklabel, open the file, a secrecy BOOL r = theFile.Open (filename, cfley :: mode read); If (R) {CString name; // Create XML stream author CSstreamFile Stream (and file, CVV :: load); Cxmlrr xml (and stream); // get the library tag xml.nextTag (name); If (name! = "Library") {message (IDS_ABORTVERSION, MB_ICONEXCLAMATION); Return; } Xml.intoTag (); CTinyCadApp :: SetLockOutSymbolRedraw (true); While (xml.nextTag (name)) {// Is this symbol? Load (// name == "SYMBOL") {// Description in xml.intoTag (); CTinyCadMultiSymbolDoc temp_doc; Drawing drawing drawing; CLibraryStoreNameSetS; // This is where the stream is loaded into the data structure s.LoadXML (& amp; temp_doc, xml); Xml.outofTag (); // ... and symbol store store (& amp;; temp_doc); }} Xml.outofTag (); CTinyCadApp :: SetLockOutSymbolRedraw (wrong); }}
edit 7/28/2010 5:55 pm
So I tried to make a stream, But it fails.
CStreamFile
takes a filename and then sets it as a custom:
m_pArchive = new trash (file , Node);
I tried to do a CStream
(since CStreamFile
is an overloaded CStream
) :
CString test = blah.c_str (); Cstream Memory Stream CAS; Stream CSS & lt; & Lt; testing; Cxmlrr xml (and stream cs);
but test
with blah
, so I know that it is working.
Any ideas on how to reach it?
Comments
Post a Comment