473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Static Class configuration

Hi,

I have defined this class to hold configuration for each field of a
message:

class field {
public:
int fieldno;
std::string name;
rtypes type;
rtypes vtype;
int length;
bool optional;
int obitmap;
ftranslation trans;
int roffset; // Configured record offset. -1 means it is
calulated
int vfp; // specifies which index for contains the length of this
field

field(fieldHeadIdx fn, char * s, rtypes t, int l, int ro, bool o,
int bp
ftranslation tl) {
fieldno = (int)fn, name = s; type = t; length = l; roffset=
ro; optio
l=o; obitmap = bp; trans = tl, vfp=-1;
}
......
}

Then hold the configuration for each field in a vector.
std::vector<field> message;

When the class is created I set the contents of the vector in the
constructor:

void msgmap::msgmap() {
headercf.push_back(field(A, "A",
H, 1, 0, false, 0, none));
headercf.push_back(field(B, "B",
H, 1, 1, false, 1, none));
headercf.push_back(field(C, "C",
I16, 2, 2, false, 2, none));
headercf.push_back(field(D, "D",
TX5, 5, 4, false, 3, none));
headercf.push_back(field(E, "E
ion", C, 22, 9, false, 4, none));
headercf.push_back(field(F, "F",
BCDX, 33, 31, false, 5, none));
headercf.push_back(field(H, "H",
C, 8, 64, false, 6, none));
headercf.push_back(field(J, "J",
H, 1, 72, false, 7, none));
headercf.push_back(field(K, "K",
H, 18, 73, false, 8, none));
.....
}

The when decoding I use the iterator to go through each field.

My question is, can I make the configuration static (compiled)? If so
how can I do it?

Thanks
Michael

Feb 20 '06 #1
2 1548
Michael wrote:
Hi,

When the class is created I set the contents of the vector in the
constructor:

void msgmap::msgmap() {
headercf.push_back(field(A, "A",
// etc.

My question is, can I make the configuration static (compiled)? If so
how can I do it?


Create a function that takes a std::vector<field>& and populates the
vector. Compile it into a ".lib".

Now, you can call that function from your constructor and pass to it,
headercf, and link against the lib.

I don't see the point, though.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 20 '06 #2

"Michael" <ch******@evolving.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,

I have defined this class to hold configuration for each field of a
message:

My question is, can I make the configuration static (compiled)? If so
how can I do it?


What is static class? What is the use of it?

-rSukumar-
Feb 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: K | last post by:
Hi all; I don't think this is a VC compiler question, so I am asking this here. I did hunt around the web and Stroustrup before posting, but found no references to this problem. I have a base...
4
by: marvind | last post by:
I think I am running into the static initialization problem but I do not understand why. I am trying to parse a configuration file. To make this parser generic I register callbacks for various...
4
by: Steve | last post by:
I'm currently running into a problem, and I have no idea what to make of it. I have a class with nested clases and static properties that I'm using to store configuration information using a...
1
by: wenqiang.zhou | last post by:
i only kown that static members doesnt blong to any object and it have to initialize outside class, inline is near the same as define it will replace in code.but i was puzze by the following codes....
5
by: Timothy Madden | last post by:
Hy static members of non-integral type need to be declared in the class, but defined (and constructed or initialized) outside the class. Like this class SystemName { public:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.