Well I have something that works. What I ended up doing is loading all of the data to the objects as string. I plan to do the conversion from string to whatever as a second step. That will simplify the loading functions, since they will only have to deal with one type. I think I can do conversion as a class method that will read the string vector in the object and do the conversion to either the int vector or the float vector. In some cases it stays as string.
Here is the code,
Header file,
main file,
What I did to load the metadata was to declare a pointer to class data member,
Then in the function definition, I pass a reference to the vector of objects, and also the pointer to data member,
As far as I can tell, the function just knows there will be a pointer, but doesn't care which data member it points to, or which object. In the loading fucntion, it's just,
Then I select a row to process,
point *var to what I want (the content string here, which is in row 0)
and call the loading function with the row, the vector of objects, and the pointer.
This lets me load each row to a different data member by changing the pointer. As far as I can tell, the only limitation is that the pointer is declared as a string, so I couldn't point to an int data member, etc. I could declare different kinds of pointer if I needed to.
For the data rows, I am loading everything as string, so the destination in the objects is always the same. I am using push_back to dynamically size the vectors.
I think that logically these functions should be class methods, but I'm not sure how to go about adding them. I seem to remember issues when referencing thing from inside a class. I also need to add methods for doing the translation from string to int and string to float.
Do you see anything grievously wrong with how I'm going about this? I am hoping to develop some nice reusable code that I can implement in other apps that use similar data. I think I can dispense with storing the entire file on input, since I am storing as string anyway, or I can just clear the storage vector when I am done with it? Is there some point at which I need to become concerned with resource allocation? I have tried the above on an input file of 250 cols and ~16,000 rows. The app uses about 135MB of RAM and takes 1min 8 seconds to complete. This includes writing the data back to an output file in an inefficient method.
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)