A CString question
-
How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:
-
How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:
-
Aljechin How much of characters could I store in a CString? I
A CString can hold up to MAX_INT (2 billion) characters. hope that helps Si
si_69 wrote:
A CString can hold up to MAX_INT (2 billion) characters.
I think it's suports only 64KB, taking the amount of a new memory allocation. Am I wrong?
-
How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:
Even if CString is able to store so much data, I don't think it is a good idea. Why do you want to store all this data in one CString ? What do you need to do with this data ? A better solution would probably to look at the data as smaller block and deal only with a single block at one time. Just a suggestion.
-
How much of characters could I store in a CString? I am having a function in which a CString has to be accepted. The input may be extremely large (Say about 700 pages, with 300 characters each page). Will CString be able to manage this? I know that I can chop the input to pieces and go ahead with the work. But I want to know how effective will be CString able to do this job. Thanks for your time.. Aljechin Alexander :rose:
That is ~205KB of data, which is a small amount of data in today's world. Note that if you are copying the data directly into the
CString
in one shot, the performance will be MUCH better than if you keep appending into theCString
. If you need to be messing around with individual pages or lines a lot, you might want to use something else like an embedded editor (a hidden edit/richedit control, for example), or your own implementation of a text-row table (and array of pointers, one for each page/line) or something like that. Lastly, it might be worth making sure that the function HAS to take aCString
- there are lots of examples of poorly-designed code that takeCString
parameters unnecessarily, when a simpleLPCTSTR
would work fine. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
Even if CString is able to store so much data, I don't think it is a good idea. Why do you want to store all this data in one CString ? What do you need to do with this data ? A better solution would probably to look at the data as smaller block and deal only with a single block at one time. Just a suggestion.
Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:
-
Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:
If you are already getting that data as a
LPCTSTR
(orconst char *
) stream, there is no reason to go through the overhead of putting that data into a dynamically-allocated buffer (theCString
). If speed/performance is important, I would check to see if you can pass the data directly to the processing functions. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:
And how do you communicate with the microprocessor ? You receive data for example on the serial port ? I don't think this is a great idea to store everything in a CString. They are used for string manipulatino and not as data buffer (I suppose that the data you are receiving is not only characters but also 'binary' data). And why not open a file at the begining of the communication and store everything there. Or even write your own data class that will take care of the format of the data. This could be quite fast if you design it well.
-
Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:
Aljechin The input comes extremely fast
What does this mean? Compared to what? Using what medium (serial, ethernet, USB)? When I face such a problem I tend to separate the data collection from the analysis. I store the collected data in BLOBs, put them into a queue and analyze them in a separate thread. Usually the analysis is non-critical regarding time compared to data collection. Hope this helps -- Roger
It's supposed to be hard, otherwise anybody could do it!
-
If you are already getting that data as a
LPCTSTR
(orconst char *
) stream, there is no reason to go through the overhead of putting that data into a dynamically-allocated buffer (theCString
). If speed/performance is important, I would check to see if you can pass the data directly to the processing functions. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)I did not put anything into a CString. Everything is
unsigned char *
here. That question just came into my mind.. So asked here. Thanks all. -
Aljechin The input comes extremely fast
What does this mean? Compared to what? Using what medium (serial, ethernet, USB)? When I face such a problem I tend to separate the data collection from the analysis. I store the collected data in BLOBs, put them into a queue and analyze them in a separate thread. Usually the analysis is non-critical regarding time compared to data collection. Hope this helps -- Roger
It's supposed to be hard, otherwise anybody could do it!
Actually the program here is in Plain C with some asm stuff. But this question just came into my mind. I cannot use a CString even if I want it here. The data comes through a serial port. Actually there are two other layers after the microprocessor, from where the data comes to our program. Thanks :rose:
-
si_69 wrote:
A CString can hold up to MAX_INT (2 billion) characters.
I think it's suports only 64KB, taking the amount of a new memory allocation. Am I wrong?
-
Mihai Moga wrote:
Am I wrong?
sure you are... it accepts up to 2 GB !!! where di you get such an information ?
v2.0 wrote:
where di you get such an information
MSDN for Windows 3.1 ;P No offence meant, Mihai!
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
-
Yes yes. That is what I am exactly doing. But its crucial to complete the task soon as possible. The input comes from a microprocessor and the data is about the turbulence, velocity, temperature, etc of water flowing out of a dam. The input comes extremely fast. The faster we could complete the task and log it, the better it is. Thats why I asked this question. Thanks all. :rose:
Aljechin The input comes from a microprocessor
Aljechin The input comes extremely fast
If we are talking about currently commercially available PCs,
"extremely fast"
may be anything more than Gigabit-Ethernet. In our company, we have a machine tha can generate data in a pace of about half of the capacity of a off-the-shelf IDE-Disk. (Not or long, though). This is handeled in C++ on a standard PC.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
-
Aljechin The input comes from a microprocessor
Aljechin The input comes extremely fast
If we are talking about currently commercially available PCs,
"extremely fast"
may be anything more than Gigabit-Ethernet. In our company, we have a machine tha can generate data in a pace of about half of the capacity of a off-the-shelf IDE-Disk. (Not or long, though). This is handeled in C++ on a standard PC.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
InfiniBand - the only way to fly! :) Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!) -
v2.0 wrote:
where di you get such an information
MSDN for Windows 3.1 ;P No offence meant, Mihai!
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
-
That is ~205KB of data, which is a small amount of data in today's world. Note that if you are copying the data directly into the
CString
in one shot, the performance will be MUCH better than if you keep appending into theCString
. If you need to be messing around with individual pages or lines a lot, you might want to use something else like an embedded editor (a hidden edit/richedit control, for example), or your own implementation of a text-row table (and array of pointers, one for each page/line) or something like that. Lastly, it might be worth making sure that the function HAS to take aCString
- there are lots of examples of poorly-designed code that takeCString
parameters unnecessarily, when a simpleLPCTSTR
would work fine. Peace! -=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites (Please rate this post!)Lastly, it might be worth making sure that the function HAS to take a CString - there are lots of examples of poorly-designed code that take CString parameters unnecessarily, when a simple LPCTSTR would work fine. What really makes me twinge is when they specify a CString& - by reference! when an LPCTSTR would have been just fine :rolleyes: People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks