Keeping them as vectors but not using 2/3 of the vector positions is very wasteful. Why have all those different types anyway, instead of one class that contains a string and has operators to return float, int, char? It'd let you keep everything in one vector.
I have changed this into 2 classes. In some files I have, the first several rows are like extended header rows that give information about the data type and exactly what is stored in the column. I am now creating a metadata object for each col to hold the info from these first rows, and then a second object to hold the actual data. I put the different vector types into the class because the columns could contain any of those data types. For each column, only one vector will have data added to it. I presumed that the declaration of the vectors doesn't cost any significant resource since they have no size at that point.
Quote:
Originally Posted by Corona688
Why do you store each and every row in a vector when you don't need them later? Why not process the row then discard it?
This is probably temporary, in that I tend to start with a method that I know will work. In some cases, I need to look at allot of the data before I decide what to do with it, so I may not be able to process it one row at a time.
Quote:
Originally Posted by Corona688
I don't understand this at all, but I think I sort of get your pseudocode -- you want to load data from a string.
I need to load tabular data from a text file. Reading the data into a string for each row, and then parsing the row by the delimiter is the only way I know how to do that at the moment.
Here is an updated version of the code.
Header file,
Main function,
This compiles and runs, giving the expected output. I have attached the src. This part just loads the data from the first few rows into the respective col objects. Later code would load the actual data, rows 7-11 in the attached data file, into a vector of the appropriate type. There is an issue that I am loading from the input file and storing as a string, and then parsing the string, possibly to int or real. I know you can convert from string to real, etc, but that seams like a silly solution. The issue is that the rows of data contain all kinds of types, so I'm not sure what else to do.
The above code is written out in blocks, where it is obvious that there should be a function to load data,
This function works but I need to be able to pass the object.var that is being populated in the second function, since it can't be hardcoded to metadata[i].content like above.
I hope that makes it a bit more clear as to what I'm trying to do, although I'm sure it makes it no more certain I'm going about it the right way.
Is it possible to view all the functions exported by a given object file?
"dump -tv" comes the closest, but what exactly am I looking for to determine whether the symbol exists in the object file?
Essentially, I have a library that requires a call to "xdr_sizeof" and the compile is failing... (5 Replies)
Hi,
I have a base class and derived a class from the base class, i want to print & read the data for the object created for the derived class,so i have overloaded both the << and >> operators and also have done the foward declaration.
Below is the code snippet,
#include <iostream>
class... (3 Replies)
Hi ,
I have three funcions f1, f2 and f3 .
f1 calls f2 and f2 calls f3 .
I have a global variable "period" which i want to pass to f3 .
Can i pass the variable directly in the definition of f3 ?
Pls help .
sars (4 Replies)
Hello,
i am using the sigaction function to handle the SIGCHLD signal.Is it possible to use a class member function as the handler function (the sa_handler member of the sigaction structure)?
The function's signature is:
void (*sa_handler)(int);so i don't think i can use a static member function... (2 Replies)
Hi,
Anybody know any way to Call with Shell Script an external function wrote in .C or .So (Shared Object) on AIX enviroment and returning parameters of .C or .SO to Shell Script?
Tks!! (6 Replies)
I have a code as following:
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
//the class Nth is a predicates
class Nth{
private:
int nth;
int count;
public:
Nth(int n):nth(n),count(0){}
bool operator()(int){
... (2 Replies)
we have 2.2.0 of opends running on RedHat 2.6.21 and we're trying to setup a structure that will suit our needs. One of the things we'd like to do is create our own custom object classes based off some of the existing ones you get out of the box. The opends documentation covers this here (sorry, it... (1 Reply)
I have a class called Parsing with the following function. I want to create a wrapper for it, so that I call it using GetReal rather than GetFloat.
Bit confused on how to do this.
class Parsing {
private:
int Length; //
int Ptr; ... (3 Replies)
How to initialize an object of class say "A", with an object of type say "B".
The following code give the error message "error: conversion from âAâ to non-scalar type âBâ requested"
#include <iostream>
using namespace std;
class B;
class A{
public:
A() { cout <<"\nA()" << endl; }
... (1 Reply)
Hello All,
I am a learner in C++. I was testing my inheritance knowledge with following piece of code.
#include <iostream>
using namespace std;
class base
{
public :
void display()
{
cout << "In base display()" << endl;
}
void display(int k)
{... (2 Replies)