Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am being tasked to essentially write a potentially enormous function in C++ that deals with searching and writing to an XML file.
Is there a way in C++ to search through an XML file, either as an xml file or just raw text, take in a path and write a record at the end of that path. For example:
<File>
<Record>
<Name>Joe</Name>
<Age>52</Age>
</Record>
</File>
The function would search for the end of the latest record, then insert a line for a new Record, then next go through the loop, it finds the new record tag, inserts the name, then next time it inserts the age, then it closes the Record tag.
Any ideas or sources that could be helpful for this level of manipulation? Tips on how it should go?
To those calling this a duplicate, allow me to add that I cannot use a 3rd party DLL. I have to code everything on my own.
Use boost::property_tree it can handle XML and is quite nice in my opinion.
http://www.boost.org/doc/libs/1_41_0/doc/html/boost_propertytree/tutorial.html should give you a hint. I've written a small project using it and it was useful. There are other parsers like tinyXML which is also quite good.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
My task is to create an avi file by saving n number of frames in c++ .
There are many inbuilt function which can be used to create .avi file as given in below link .
https://learn.microsoft.com/en-us/windows/desktop/multimedia/avifile-reference
Using them we can create our own avifile , one such example.is
http://www.wischik.com/lu/programmer/avi_utils.html
But i want to create it without using Windows.h and vfw.h as they are very extensive.
So i need to make my own function of avifilewrite , appendframes etc
But i can't find any reference link on internet .
Can anyone please explain how can i build avifile without using Windows.h and vfw.h .
Thank you ,
How to create an ... file ...?
You can use the standard file stream API to create a file. To write a binary file, you'll need to use an unformatted output function such as std::ofstream::write().
... an avi file from scratch?
The AVI format is specified by Microsoft: https://learn.microsoft.com/en-us/windows/desktop/directshow/avi-riff-file-reference
However, you can save a lot of effort by using an existing API.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm using Statistica 64 VB. I wrote a function "Public MyFunction()" in FileLibrary.svb (a collection of useful functions) that I want to be called by a function in FileDoStuff.svb (an analysis).
I tried to include FileLibrary.svb like this in FileDoStuff.svb:
'#Language "WWB-COM"
'#Uses "U:\TestSVB\FileLibrary.svb"
This is the result when I run Main() in FileDoStuff, and the result is the same even if I have FileLibrary open in the application.
"Script error in FileDoStuff.svb
Macro/module does not exist."
Statistica is on the E: drive. However, FileLibrary opens a spreadsheet on U: and has no problem with it. I am able to open FileLibrary from Statistica and test it.
Why would it work to open an external spreadsheet but not call an external macro? The FileLibrary is not saved within Statistica, but neither is the analysis in FileDoStuff. What am I doing wrong?
Also, what's the difference between an SVB and an SVX file?
You know what really helps, as I discovered after hours of trying everything?
Try spelling the entire path name and the entire file name correctly, including spaces, etc. And make sure the slashes go the right way, too. (In my real path/file there are spaces.)
As much as I'd like to delete this whole question, I'm leaving it here to remind us all that sometimes the answer is just that simple. Also, I want to draw more people out who are using Statistica VB because I know there will be more questions.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a little program that I made which allows me to take in some text and sort it and make it look the way I want it to. One of my functions to save the new text file allows the user to input the name of the file using C++.
What I want to do is at the end of the program, I want it to open notepad displaying that new text file. I know you use " system("notepad.exe (txt file)")." But I can't add a string variable in place of the txt file. It requires the name of the text file, but the file name could be anything depending on the user.
Any help or a link to where I can read about it would be great!
Thanks
Assemble the command in a std::string and then use its c_str function to pass to system.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to write a software for managing recipes. The recipes are valid standalone xml files. They contain string and integer values and image data (in a base64 representation). The user should be able to create/open, edit and save recipes. Now I have concerns about file management and efficiency (speed and memory).
How should I manage all the recipes? I think I could either store them all as plain xml files in a folder, or have them all in one library file of some sort. The first approach might be faster on startup, as the recipes are loaded when the user clicks them, e.g. in a QTreeView. The second approach might be more efficient and fast because the whole library would be kept in memory, although it could be more complex to change its contents.
I want to use DOM for xml file handling - or would QXmlStreamReader/writer be a better choice here?
Either way, I would have to manage the recipe data using unique IDs, e.g. for several different "Cookies" recipes. When using the first approach from question 1., I would use file names based on such an ID. Are there any convenient ways to create unique IDs? Because when using incrementing integers I'd have to track which numbers are already in use.
I'm using XML files for transferring recipes in my recipe program. I have options to import and export using XML.
I am using a database to store the recipes. I do not use XML data files to store recipes. I'll leave data management to the database (I'm not wasting my time writing and debugging a database).
For data storage, there more efficient file formats than XML. Also, you may want to create "index tables" which allow for sorted and more efficient access to files than having to always parse an XML file.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I'm we're trying to figure out if there would be a way to convert a .txt file to a .pdf file. Here's the catch. This needs to be done behind the scenes, and on the fly. Meaning, with a radio control selected, OnOK would create a .txt file. Behind the scenes, at run time, we would like for the .txt file to be converted to a .pdf file. Ideally we would like this to be done by running an executable in the background. The executable would take input "File.txt" and output "File.pdf". We're using C++ and Visual Studio 6.
Does anyone have any experience on this? Is this possible?
libHaru may do what you want. Demo.
This a2pdf tool will probably do the trick with minimal effort. Just be sure to turn off perl syntax highlighting.
http://perl.jonallen.info/projects/a2pdf
I recommend using this open source library.
Once you have the base for generating PDF documents programmatically, you would still need a method for converting the text to the PDF elements, while keeping the text flow and word wrapping. This article may help. Please pay attention to the DoText(StreamReader sr) function. It takes text and purge it into separate lines within the PDF document, keeping the rendered within the margins.
On of the simpler methods that has worked for 3 decades e.g. more than one quarter of a century is place a postscript header before the text then use ghostscript ps2pdf it is the same method as used by some commercial apps such as acrobat
at its most basic
Copy heading.ps file.txt printfile.ps
GS -sDEVICE=pdfwrite printfile.ps printfile.pdf
Master Example can be seen here
How to modify this plaintext-to-PDF-converting PostScript from 1992 to actually specify a page size?