|
You should probably be using XML4C (or MSXML), Steven. Just build the DOM in memory, then write it out to a file. XML4C is f-a-s-t as hell.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
No, I really don't need it. I think now it may be a good idea to put it together in blocks, I think the problem its trying to keeping adding more and more to an increasingly large string (500kb) and it just gets slower cause it does it soomany times. CString has a bad problem about stuff >100kb.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
(i assume you are using CArray cause I see xxx.GetAt(i))
Try std::vector or std::list instead of CArray.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
just a thought....
* remove the automatic bufferlock form the CString
* set the size to a realy BIG value
* add the data
* calculate the new size.
m_strNewWordSection.GetBufferSetLength(50000);
for()
{
do stuff
}
m_strNewWordSection.GetBufferSetLength(-1);
|
|
|
|
|
|
When you asked the question a few days ago, I suspected that this would be the issue.
In general, every += operation (including the str+str) operations will result in a memory allocation, two string copies and a memory deallocation. So for 8000 entries, there will be 5 of these per entry. That is 40000 memory allocations, 80000 string copies and 40000 memory deallocations.
The previous poster (if it works, I didn't know you could do that ), reduces the problems down to 1 memory allocation, 40000 string copies and 1 memory deallocation.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello,
I have the following class structure:
_________________ ________________
| | | |
| ComponentPeer |<-----------| Win32Component|
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| ContainerPeer |<-----------| Win32Container|
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| Window Peer |<-----------| Win32Window |
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| Frame Peer |<-----------| Win32Frame |
|________________| |________________|
All the classes on the left are pure interfaces.
On the right I have abstract classes. The only concrete class is Win32Frame. Win32Component contains a member variable hWnd. Well, if I have a pointer declared as ComponentPeer * which points to a Win32Frame instance I'm unable to get the correct value for hWnd. For example:
ComponentPeer *cp = new Win32Frame();
Win32Frame *ab = dynamic_cast<Win32Frame *>(cp);
HWND hWnd = ab->hWnd;
this code crashes sometimes with an exception (illegal memory access) or my hWnd has not the correct value. Why doesn't it work? Is there any error? And how could I make it work? (I don't want to have a getHwnd method in my multiplatform class componentPeer).
Thanks.
|
|
|
|
|
Weird, that looks alot like the VCF's class layout.
I don't want to have a getHwnd method in my multiplatform class componentPeer
Well you could do what I did:
VCF::ControlPeer
just have a method called getHandleID (or something like that) and return an unsigned long. Then typecast that to an HWND.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Jun Misugi wrote:
Win32Frame *ab = dynamic_cast(cp);
HWND hWnd = ab->hWnd;
Warning! Danger! If you call dynamic_cast, you may get back a NULL if its argument could not be casted to the right class. So always check for NULL in this case.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Ok, I have found the problem. I just had to select the option "General-Purpose always" instead of the default "Base-Cast Always *" in Project/Settings/C/C++/C++Language RepresentationMethod.
I don't know what this stuff means but it makes it work correctly. Does anyone know anything about it?
Thank you anyway for answering.
|
|
|
|
|
I am trying to track down a crash on application exit that causes the program to dump in _free_dbg_lk. This memory deallocation is called from a third party component that I have been using for a while without a problem. I am trying to determine what I changed that is now causing the app to dump on exit.
I know about "no mans land" (0xFD), dynamically allocated but uninitialized memory (0xCD), dynamically allocated and freed memory (0xDD). In this problem the pointer is 0xFEEEFEEE, which I have also seen plenty of times when debugging memory allocation problems.
My question is: Does anybody know what causes a pointer to be changed to 0xFEEEFEEE? This should help me track down what is messing up my application shutdown.
|
|
|
|
|
i need some help in getting data from a txt file to an array. i'm using C++ in visual studio .net. and yes i'm a newbie and this is a homework assignment so please be easy on me hahaha...
here's the txt file contents:
75 83 77 91 76
80 90 95 93 48
78 81 11 90 73
92 83 30 69 87
23 45 96 38 59
60 85 45 39 67
27 31 52 74 83
93 94 89 77 97
79 85 28 93 82
85 72 49 75 63
i need to use the numbers in the file for calculations. here's part of my code using StreamReader to get the data from the txt file.
Code:
<br />
int main() <br />
{ <br />
double average = 0.0; <br />
int rows = 0; <br />
int cols = 0; <br />
<br />
IO::StreamReader *inData; <br />
inData = IO::File::OpenText("InData.txt"); <br />
<br />
while (inData->Peek()) <br />
{ <br />
} <br />
inData->Close(); <br />
this is where i get tripped up.. i'm unsure what i need to add to get that data into an array to do calculations. I know i still need to declare the array. i just need to know what do to in the while loop to get the data from the txt file into an array to do calculations. so i guess the data from the files also need to be converted to integers i guess right?
K
|
|
|
|
|
Wouldn't sscanf or one of the variants work here? That is you are really using Visual C++. If you are using Managed C++ I believe you can use a ReadLine and then use String.Split to crudely tokenize.
|
|
|
|
|
String strLine;
while ((strLine = inData->ReadLine())) != null)
{
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
If you're allowed to use the standard library, an ifstream would actually allow you to read them as ints, no problems at all.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
nah... have to use it at this .net gayness haha... so i guess is use streamreader??
k
|
|
|
|
|
I suppose so. What idiot is making you use C++.NET ? If you want to use .NET, use C#.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
it's actually a school assignment... and the gayness of my school... lets do C++ .NET for the first C++ class... but the Object Oriented C++ next semester will be in standard code.... it makes no sense...
k
|
|
|
|
|
They probably think that the .NET framework will make the jump into C++ less painful. I still think C# would have given the same effect with more long term benefit.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Do I have to write out the registry key in order to write out an ini file? In my code I'm using the WritePrivateProfileString API passing the section name, key and the path with file name. The file gets created but nothing is written.
In the example in the MSDN lib they show calls made to registry settings. But I just want to write out the file and not making any reg settings.
Here's a snippet of my code:
<br />
for(int i = 0; i < NumItems; i++)<br />
{<br />
if (ListView_GetCheckState(m_cColumnList.GetSafeHwnd(), i))<br />
{ <br />
WritePrivateProfileString ("Columns", m_cColumnList.GetItemText (i,0), NULL,CurrentDir); <br />
}<br />
}<br />
All I want to do is write out the SQL column names to an ini file. So each key will be a column name with no value.
Any help would be appreciated.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
If the third parameter to WritePrivateProfileString() is NULL, the specified key (the second parameter) will be deleted.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Is there a way to write out a key without a value?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Sure, just ensure that the third parameter is non-NULL .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Haha....duh. How come you always seem to make me see the light and it's right in front of me?
Thanks again
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Is it possible to put keys in there with out the '=' sign after them. Would I have to open this file like a normal file?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|