C++ :: Integrating XML Read / Write Design
Jan 6, 2014
I have two designs for reading/writing my classes to XML. Which do you think is better:
This is my structure (Attributes are single class members, Elements are std::vector< T > members
Structure:
+ Calibrator
+ Attrib: readLabel (string)
+ Attrib: saveLabel (string)
+ Element: Device
+ Attrib: sourceLabel (string)
+ Attrib: destLabel (string)
+ Element: CalPoint
+ Attrib: sourceVal (double)
+ Attrib: destVal (double)
1. Design 1: Have an independent class to handle everything and "friend" it with the users.
Pro: Only 1 interface needed and we can switch interface easily.
Con: There is a lot of inter-class data which destroys encapsulation
class CalibratorXML;
class Device{
string sourceLabel;
string destLabel;
vector<CalPoint> calPoints;
friend class CalibratorXML;
[Code] .....
View 1 Replies
ADVERTISEMENT
Nov 16, 2013
How to write Algorithm / Design
View 7 Replies
View Related
Jan 31, 2013
I need to create a GlobalConfig class. But I want to derive from it in another class.
Here's an example:
public class BaseConfig {
public string GlobalPath {get; set;}
}
public class ConfigA : BaseConfig {
public string pathA {get; set;}
}
public class ConfigB : ConfigA {
public string pathB {get; set;}
}
The idea behind is that I don't want to write the code multiple times and what's more important in class ConfigA I want to set GlobalPath and have access to it in ConfigB.
In other word I want class ConfigB to have a property GlobalPath which was set in class ConfigA.
To clarify I want to have only one object of Config in memory.
When I set BaseConf.GlobalPath to 'A', I want to access it from ConfigB.GlobalPath and also get 'A'.
I always design GlobalConfig as a static class, but static classes can't be inherited. So I tried to implement Singleton Pattern, but ConfigA can't find constructor of class BaseConfig because it's private.
View 1 Replies
View Related
Feb 21, 2013
At the moment im trying to integrate an dll in my project (first time).
I copy the lib and dll to my project-directory and the header to my include path.
Now i get a linker error:
1>LINK : fatal error LNK1181: cannot open input file "libWebSvcTx.obj"
the dll calls libWebSvcTx.dll.
I insert the libWebSvcTx.lib to the Dependencies.
Don't know whats the mention of the output and how to avoid it...
View 1 Replies
View Related
Apr 11, 2015
I'm trying to write some code that will integrate a function using the Trapezoid Rule. Using an online calculator I know the result should be 36621130.371094 but instead my code is giving me 31232938.000000 ....
#include <stdio.h>
#include <math.h>
int main() {
long sum1;
float i, area;
[Code] ...
View 2 Replies
View Related
Mar 3, 2013
How can I erase the data stored in /tmp/a.txt after every run of this code?
Code:
#include <stdio.h> // IO operations
#include <unistd.h> //for pid, ppid, fork functions
#include <sys/types.h> //for pid_t type, kill function
#include <stdlib.h> //for exit function
#include <signal.h> //for kill function
#include <sys/types.h>
#include <sys/stat.h>
[Code]...
View 3 Replies
View Related
Dec 22, 2013
My program needs to receive data continuously from one process and the received data is read continuously by another process.But when I am trying to create a pipe using mknod on fat32 file system in linux , it throws an error saying "mknod: operation not permitted".
View 3 Replies
View Related
Sep 8, 2013
I receive a telegram in XML format and I need to parse it and send my data in the same format back. My main problem is that I'm not allowed to use any open source software or other 3rd party software except VS2010. I have to write it in C++.
Now my question: is there any good tutorial for such a parser? I was hoping that I could write something which can be used similar to the GEtPrivateProfil-functions which are handy for ini-files.
My XML telegram looks like hat:
Code:
<Tag0 cmdId=“254“ version=“1“ ID=“87951“ action=“doing1“>
<!—comment1 -->
<Tag1 lId=“31“ type=“12“ index=“100“ state=“open“ />
<Tag1 lId=“31“ type=“12“ index=“135“ state=“open" />
<!—comment2 -->
<Tag2 lId=“42“ type=“32“ index=“2“ state=“open" >
<param key=“pos“ value=“center“ />
<param key=“car“ />
</epr>
</Tag0>
I was hoping to find a way to get to know how many tag1 and tag2 are in tag0 and then get for each tag the attributes and sub-tags like param in tag2
View 13 Replies
View Related
Aug 5, 2013
this is my read/write functions based the read from the last post! then went nuts with it! used the %19s%*s on the write to the file, solved all the probs on the read side! but any refining on this would be great. This is another program that i started with the forums, and started going my own direction!
Code:
void WriteAccount(int account,char *a[])
{
FILE *fptr;
char Memo[20];
char buff[20];
double Amount;
struct tm *sTm;
}
[code]....
the a[] is a string array with bank account names, and Account is the number on the menu based list.
View 7 Replies
View Related
Feb 4, 2013
I am planning to use this mostly to copy binary files, but why won't this work with text???
input.txt
int main(int argc, char* argv[]) {
// open file
std::ifstream ifs;
ifs.open("./input.txt", std::ios::binary);
[Code] ....
output.txt
310^?z^@^@^@^@^@300367346^A^@
Will this method always work to copy a file?
View 2 Replies
View Related
Dec 10, 2014
I'm looking to write a program in C/C++ to traverse a Fasta file formatted like:
>ID and header information
SEQUENCE1
>ID and header information
SEQUENCE2
and so on
in order to find all unique sequences (check if subset of any other sequence) and write unique sequences (and all headers) to an output file.
My approach was:
Prep: Copy all sequences to an array/list at the beginning (more efficient way to do this?)
Grab header, append it to output file, compare sequence for that header to everything in the list/array. If unique, write it under the header, if not, go on.
However, I'm a little unsure as to how to approach reading the lines in properly. I need to read the top line for the header, and then "return?" to the next line to read the sequence. Sometimes the sequence spans more then two lines, so would I use > (from the example above) as a delimiter? If I use C++, I imagine I'd use iostreams to do the reading.
View 1 Replies
View Related
Oct 12, 2014
How to read some characters from file, I know we can move a pointer to some position using seekg() & seekp() function, get current position of the pointer through tellg() & tellp() functions. By moving the pointer to appropriate position using seekg(), we can read the whole line using getline() function. But is there any function which read certain characters from the current position of the pointer and write certain characters from current position of the pointer.
View 1 Replies
View Related
Oct 12, 2014
How to read some characters from file, I know we can move a pointer to some position using seekg() & seekp() function, get current position of the pointer through tellg() & tellp() functions. By moving the pointer to appropriate position using seekg(), we can read the whole line using getline() function. But is there any function which read certain characters from the current position of the pointer and write certain characters from current position of the pointer.
View 3 Replies
View Related
Feb 19, 2014
#include <stdio.h>
#include <stdlib.h>
int main () {
FILE * pFile;
long lSize;
char * buffer;
size_t result;
pFile = fopen ( "myfile.bin" , "rb" );
[Code] .....
How to open binary for read and write? Why the buffer is char * buffer? i mean in binary u cant read chars . How can it be? how the data is represented? just like txt file? What the buffer will contain how to print this buffer???
View 3 Replies
View Related
Nov 17, 2014
reading and writing 2D arrays I've been trying out a few tutorials using FileStream but I couldn't get any of them to work.
Anyway what I'm trying to do is save the playerArray to a .txt file and then read from that .txt into the fields within the GUI. This is supposed to act as a database.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
[Code]....
View 2 Replies
View Related
Sep 22, 2012
the output of the password text file contains like this:
username
776655443322 (password encoded)
How to write the value in last line (3rd row) of the file. after that read and write or alter 3rd row value. I need logic using "C" language.
View 3 Replies
View Related
Dec 29, 2013
Explain me a working code to read and write a file using serial communication.and i need to store that file.I know normal file handling in C, but how it is through serial port i am not getting.
View 1 Replies
View Related
Sep 27, 2014
called object 'fptr_in' is not a function or function pointer
called object 'fptr_out' is not a function or function pointer
what can i do for the errors?(i mustn't use loop and arrays for the code)
Code:
#include <stdio.h>
void sum_of_2nd_and_3nd( FILE* fptr_in, FILE* fptr_out);
int main()
return 0;
}
void sum_of_2nd_and_3nd( FILE* fptr_in, FILE* fptr_out){
}
[code].....
View 2 Replies
View Related
Oct 5, 2014
I'm not sure if I should do this with malloc or a char array. What I need to do is create 4 methods to read and 4 to write to memory like this (and it has to be fast):
Code:
char GetByte(char* memory, int offset);
uint16 GetInt16(char* memory, int offset);
uint32 GetInt32(char* memory, int offset);
char[] GetString(char* memory, int offset);
So basically memory is the malloced memory and the offset is the position I want to read at.
I'm not sure if there's already a way to do this and maybe I'm overlooking something.
View 4 Replies
View Related
Jan 30, 2014
So I've been turning my programs into classes and I run into errors.
So this program is supposed to allow the user to open the file and either read or write to it.
I've omitted the read part from it as I want to attempt that on my own .
I get these compile errors:
fileclass.cpp:13: error: ISO C++ forbids declaration of ‘choice’ with no type
fileclass.cpp:21: error: ISO C++ forbids declaration of ‘choice’ with no type
fileclass.cpp: In member function ‘int file::choice()’:
[Code] .....
View 10 Replies
View Related
Oct 11, 2014
I would like to read in binary files, then write them to another file.
I write a code, what works perfectly, if I would like to just copy the file to another. But I want to make it a little other.
If I open a file in hex-editor I also can see the ASCII values. But I would like get the ONLY the hex values to the other file.
For example:
d5 57 4f ad 30 33 0b 4e 49 a7 05 18 c4 90 66 d8 45 ac 39 3e 7d f1 a8 02 80
14 20 90 6e 20 12 38 0c 65 4a 28 d2 80 72 04 20 a9 4a 82 84 60 6a 0b 25
59 4c 30 c8 69 c0 ec fa 36 ed 3a da b1 9a 82 02 e0 bb 7e 41 87 02 f6 10 34
eb 95 93 63 01 6b 8d e1 d7 43 c3 df 92 5d 8a ed 57 61 4e 36 07 2a d7 56 2b
b5 0e 55 83 b4 76 8c b7 61 77 0e c9 76 0c 81 1b 01 63 0c 8b 73 57 d5 6d 4c
0c c2 0d 52 45 18
How could I make it?
View 4 Replies
View Related
Jan 28, 2013
So I'm trying to create a program that allows one to read/write on to output.txt. I though I had everything set up right, but its only writing one word to the text file. Heres the code.
#include "stdafx.h"
#include <iostream> //Needed for User Input
#include <fstream> //needed for ofstream
#include <string> // needed for strings
#include <windows.h> //needed for Sleep
#include <cstdlib> //Needed for return EXIT_SUCCESS;
using namespace std;
int main() {
ofstream outputfile; //allows to read and write to files
[Code] .....
If I type Puppies Are Cute and go to output.txt, the only thing written in the text file is Puppies.
View 9 Replies
View Related
Jun 3, 2013
need to create a program for the following problem
1.Program takes messages as input at a rate “X” msg/sec, and outputs those messages at “Y” mgs/sec in a file.
2.The peak value of X can be 10msg/sec, and Y can be at max 5msg/sec. System should be designed in such a way that it can handle the peak input rate of 10msg/sec for not beyond 5 minutes.
3.Message contains following fields – unit id, timestamp, temperature.
4.Input data to be read from a file. Output data to be written to a file.
5.For testing design 3 types of profiles –
a.Profile 1 for 10 min – low rate, i.e. X = 4 msg/sec on an average throughout the period.
b.Profile 2 for 10 min – Max rate, i.e. X = 10 msg/sec for 2 min; then a sleep of 2 min, then repeat the same pattern till complete period
c.Profile 3 for 10 min - Max rate, i.e. X = 10 msg/sec for 5 min; then no traffic for next 5 min
View 1 Replies
View Related
Mar 26, 2014
I have looked through te tutorials here, and even google it, as well as tried to follow the power points from my class..but I still can't seem to figure out how to make this code work correctly.. Basically I have to create a file called grade and write to it a student name and their grade score, and then read from the file all students names and there grade and display this on the screen as well as calculate the grade average for all of the students and display it.
Well I am able to write to the text file, but I can't seem to get the rest to work. I can't figure out how to read from the text file..Here is my code below.
write a sample code that does something similar write to text file string and numbers and then reads from it.
#include <iostream>
#include <fstream>
using namespace std;
[Code].....
View 6 Replies
View Related
Oct 5, 2014
I decided I wanted to make a proper programming language with a virtual machine and bytecode. I used this tutorial: [URL] .....
As a starting point for my project. So far I have modified it to allow for 32-bit addressing so that I can theoretically use 4GB in my programs. Now the problem I'm having is creating the memory.
Question:
I'm not sure if I should do this with malloc or a char array. What I need to do is create 4 methods to read and 4 to write to memory like this (and it has to be fast):
char GetByte(char* memory, int offset);
uint16 GetInt16(char* memory, int offset);
uint32 GetInt32(char* memory, int offset);
char[] GetString(char* memory, int offset);
So basically memory is the malloced memory and the offset is the position I want to read at.
View 8 Replies
View Related
Sep 22, 2012
correct the below code:
file already contains entries : 1st row username; 2nd row password.
check status required to write at third line and need to read or alter the check status value.
Currently this code is working if already there is a value for check status, then it is overwriting else UI hanging.
Code:
WriteCheckStatusToFile(BOOL& locVar) {
FILE *l_pFile = NULL;
CString l_strRememberCheck;
l_strRememberCheck = GetExePath() + _T("password");
CString sVar;
sVar.Format(_T("%d"),locVar);
[code]....
View 2 Replies
View Related