|
If you have decided on using STL and your requirements are to generate large strings by multiple appends you might want to look at the ostringstream class.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
it does not change anything.
if I simply change my std::string with std::ostringstream and do something like
std::string m_String;
m_String.append( someText );
or
std::ostringstream m_Stream;
m_Stream << someText;
it simply, as I understand it, another way of doing the same thing.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You can preallocate size in the string by calling the std::basic_string::reserve(...) method. But it seems you already know this...
You could copy the implementation of basic_string and create your own with a higher reallocation granularity.
You could also pay attention to the current size vs. capacity (for example, if you are building the string in a loop, check the values at the beginning of the loop) and manually reallocate it to twice its current capacity so that it behaves more like a vector reallocating...
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
Sir,
I am developing an Win32 application that involves events and notification.
I am developing a simulator that fires an event and generates notification through threads.
Pls correct me If I am going wrong.
1. Develop a Win32 Application.
2. Inside Winmain, do the following.
2.1. Create a thread
2.2. Create a Handle
2.3. Call CreateEvent and assign the handle to the first.
2.4. Call the message loop
3. Inside the thread call WaitforMultipleObjects();
3.1 Use switch case To catch the event
3.2 Now when appropriate events are fired ,I want to get notification.
3.3 Where will I declare events ? Will it be in the header file or in the dll.
What further do I have to do to achieve this?
Can somebody help me with a piece of code here?
Regards
Tiger
|
|
|
|
|
Your simulator thread can post messages to a window, if your main thread created a window, or threads can post messages to each other with PostThreadMessage.
You can only wait on, I think, 32 events at any given time, so you don't want EVERY possible thing your simulator can do to be a different synchronization event.
It would be better to create a thread-safe queue, and your simulator thread puts 'data events' into the queue and posts a message or sets a synchronization event to indicate that data is available in the queue. The thread consuming the data can wait on the synchronization event and then go read the queue. If it is a window, it would go read the data queue and process data until it had read all items out of the queue, then it would be waiting again.
|
|
|
|
|
Thx for the response.
Should the events be defined in a header file.
I call a function which is already defined in a dll /in my application.
Will that function generates an event like I press a button which in turn calls a function.
The event names should be defined #define.
Can u help me with a code snippet.
Regards
Regards
Yadagiri
|
|
|
|
|
Hello,
I would like to create a GDI+ GraphicsPath vector by
std::vector<graphicspath> m_Paths;
and its iterator
std::vector<graphicspath>::iterator pathIter = m_Paths.begin() + m_iPath;
in my application view class in header and cpp file. But the compliler gives this error, What can be the reason for this error ? Thanks for your interest.
Compiling...
ImageMarkerView.cpp
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\include\vector(810) : error C2248: 'Gdiplus::GraphicsPath::GraphicsPath' : cannot access protected member declared in class 'Gdiplus::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusPath.h(862) : see declaration of 'Gdiplus::GraphicsPath::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\GdiPlusPath.h(18) : see declaration of 'Gdiplus::GraphicsPath'
d:\Programs\Microsoft Visual Studio .NET 2003\Vc7\include\vector(809) : while compiling class-template member function 'void std::vector<_Ty>::_Insert_n(std::vector<_Ty>::iterator,std::vector<_Ty>::size_type,const _Ty &)'
with
[
_Ty=Gdiplus::GraphicsPath
]
e:\Work\Cpp\ImageMarker\ImageMarkerView.h(75) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=Gdiplus::GraphicsPath
]
Generating Code...
Compiling...
ImageMarker.cpp
Generating Code...
Build log was saved at "file://e:\Work\Cpp\ImageMarker\Debug\BuildLog.htm"
ImageMarker - 1 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
|
|
|
|
|
I realized that I missed some parts, and I now add it .
the declarations should be like
std::vector<graphicspath> m_Paths; instead of std::vector m_Paths;
and
std::vector<graphicspath>::iterator pathIter = m_Paths.begin() + m_iPath; instead of std::vector::iterator pathIter = m_Paths.begin() + m_iPath;
Thanks.
|
|
|
|
|
I am a newbie with MAPI and needed some help .you see i am
writing a program which will import accounts,profiles and folders
from a PC and save it in some place so that the account information
can be plugged in to another PC .
So far i could enumarate the folders and the contacts and
profiles.But how do you enumerate the user accounts from the
profiles? is there any way MAPI lets us do that ?
I even found a way of importing account info of the default user.So
if MAPI lets me chnage the default user then i can set each account
to default one by one and then enumerate them.Is that possible?
I know of several VB application which does this , but i am writing
this application in VC++ 6.0 .however i figured that using a COM
object won't be a big troubel if i know the right API's and all.
Can anybody help ?
Thanks in advance.
Regards
Kane
Some guys hack just to get themselves a girlfriend.What a pathetic reason huh ?
|
|
|
|
|
|
well how do u think will i b able to achieve my goal then ? I could retrieve all account info from the registry, but they are all encoded in some way , not just hex values.Anybody knows how to decode them ?
Regards
Kane
Some guys hack just to get themselves a girlfriend.What a pathetic reason , huh ?
|
|
|
|
|
How can I set the position of a modal window ?
When I call DoModal method, the window is shown but I don't know
how to the the window position...
Thanks a lot !
|
|
|
|
|
in the OnInitDialog
call SetWindowPos or MoveWindow
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
If anybody is familiar with Xltable Format and how to use it please let me know.
I have a section of code that writes data to excel from DDE server.
if(!DdeCmpStringHandles(hsz1, g_hszTopicName) &&
!DdeCmpStringHandles(hsz2, g_hszItemName)) {
string xltableData[100];
// tdtTable record...
xltableData[0] = 0x0010; // tdtTable
xltableData[1] = 4; // 2 short ints following
xltableData[2] = 1; // # rows
xltableData[3] = 1; // # cols
// tdtint record...
xltableData[4] = 0x0002;
xltableData[5] = 16;
xltableData[6] = askrate;
return DdeCreateDataHandle(g_idInst, (UCHAR*)xltableData, 2*7, 0, g_hszItemName, fmt, 0);
in the code above if i define the xltabledata to short the code works fine, but my data is string. so it converts the string data to short. but if i change the data to string it doesn't work.
basically i have string data which i would like to write to excel. please help
|
|
|
|
|
test this:
byte xltableData[100];
xltableData[0] = 0x10;
xltableData[1] = 0;
xltableData[1] = 4;
xltableData[1] = 0;
xltableData[2] = 1;
xltableData[1] = 0;
xltableData[3] = 1;
xltableData[1] = 0;
xltableData[4] = 0x02;
xltableData[1] = 0;
xltableData[5] = 16;
xltableData[1] = 0;
strcpy((char*)(xltableData+13), str);
return DdeCreateDataHandle(g_idInst, (UCHAR*)xltableData, 2*askrate.GetLength()+12, 0, g_hszItemName, fmt, 0);
Zo.Naderi-Iran
|
|
|
|
|
Hi
I am developing a variable window which looks like VC++ editor's variable window. I am able to generate a tree . I am getting the contents every time from memory & displaying it.
So for every "OnStepExecute F11(my debugger command)" , i am deleting the contents of tree & regenerating the tree for variable tree.
So any one knows how to store the previous status of tree, so that every-time the user need not expand the tree to look variable(array/struct) contents.
or do any one have such appilcation which creates variable window.
thanks in advance
Irshad
|
|
|
|
|
I do not see why you need to delete the tree contents. Why not update the specific node(s) data and force a redraw of the node(s).
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Imagine that i have a pointer int* my_array and i have the following code:
for (i=0,i < max, i**)
{
result = extern_function(i)
if (result)
{
my_array[i]=1
}
}
How do i allocate memory for my_array? Note that i dont know the size of my_array cos it depends of the result of extern_function.
It seems logical that, if result=1, i should allocate dynamically one space on my pointer, so the dimension of the array will grow in consequence.
I dont know how to do this.
|
|
|
|
|
hm...
it seems that you just want to remember which
call to
extern_function() return true,
so you can save the value of
i to a linked list...
|
|
|
|
|
No, i think my example was too simplified. This one is more accurate.
while (result!=3)
{
result = extern_function();
data= exter_function_data();
my_array[i++]=data;
}
I dont know when the loop will end, so i dont know the size of my_array a priori.
|
|
|
|
|
Several choices:
-realloc
-One of the containers: Linked list, vector, CArray ...
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
i think you should use vector, like this
for( ;; )<br />
{<br />
result = extern_function();<br />
if( result == 3 )<br />
break;<br />
my_array[i++] = extern_function_data();<br />
}
hi
|
|
|
|
|
Almost... std::vector::operator[] does not reallocate; calling it with an out-of-range index results in undefined behavior (std::vector::at(...) will throw an exception).
The OP should be using push_back to add to the vector . (Of course, they might want to preallocate some space for performance reasons...) The code then looks something like:
<br />
std::vector< int > my_array;
<br />
my_array.reserve( 32 );
for( ;; )<br />
{<br />
result = extern_function();<br />
if( result == 3 )<br />
break;<br />
my_array.push_back( extern_function_data() );<br />
}
Peace!
-=- James
Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"! Articles -- Products: Delete FXP Files & Check Favorites
|
|
|
|
|
sure, i make a wrong.
if it's map it's right.
hi
|
|
|
|
|
I am writing a DDE server in VC++ to write data to Excel. I had seen some where the use of XlTable format. but that is not working well for me. Is there a better format than that i can use.
|
|
|
|