|
|
If you do not want to use the boost libraries as suggested you can create simple trim functions using the find_first_not_of() , find_last_not_of() and substr() functions.
std::tstring::size_type trim_left(std::tstring &string, const std::tstring &chars = _T(" \t"))
{
std::tstring::size_type pos = string.find_first_not_of(chars);
if (pos != std::tstring::npos)
{
string = string.substr(pos);
}
return string.length();
}
std::tstring::size_type trim_right(std::tstring &string, const std::tstring &chars = _T(" \t"))
{
std::tstring::size_type pos = string.find_last_not_of(chars);
if (pos != std::tstring::npos)
{
string = string.substr(0, pos + 1);
}
return string.length();
}
std::tstring::size_type trim(std::tstring &string, const std::tstring &chars = _T(" \t"))
{
trim_left(string, chars);
return trim_right(string, chars);
}
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I've tried this for quite a while, still clueless.
I used WNetOpenEnum and WNetEnumResource to obtain the IP address of other PC connected to my neighborhood. Now I want to know the subnet mask settings and gateway settings of them. What functions to use?
I know structure INTERFACE_INFO contains field iiNetmask, which is the network mask, but which function can give me this structure as an output?
thank you very much for the help!
|
|
|
|
|
Hello Friends
Can someone please help me with a question regarding the SDK
Now Microsoft has comeup with a new SDK
a) If i compile any sample application , will it work on old OS (eg Win 98 , etc)
b) How i can find out what files need to be redistributed & where to find them?
Regards
|
|
|
|
|
a) Not necessarily. If the sample app is demonstrating APIs that became available on Windows 2000
then it's probably not going to run on Windows 3.1.
b) Deployment (C++)[^]
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hi,
I have data coming at a really fast rate 200 times a second. I have a consumer which runs slower then the producer, and I need to have the ability to keep the data being copied off for a long period of time, namely like for 3 to 4 hours. Now the way that it is going now I have this circular queue, but because the consumer runs slower, the producer overlaps it and I lose data and everything gets off sync. I can not lose any data, and I need to be able to write the data for 3 to 4 hours, is there any way that I can do this.
Thanks in advance
|
|
|
|
|
godspeed123 wrote: is there any way that I can do this
of course, you lock the shared resource (here, your circular queue") so that only one can use it at a time (either producer, or Consumer, but not both), and release it then.
you should document yourself about semaphore, mutex, and such security locking systems...
|
|
|
|
|
Thanks for the repsonse.
By doing the locking, wont you lose data? Since the producer wont be able to write the data in at the time that it is available?
|
|
|
|
|
godspeed123 wrote: By doing the locking, wont you lose data?
thanksfully not !
actually, the producer (if it's the producer who wants to use the resource when it's locked) "hibernates" for a certain period, until the comsumer releases the resource.
the problem is if you don't release a locked resource... you can come into an infinite loop...
|
|
|
|
|
So right now what is happeneing is I have a hardware board hooked up to the computer and it throws out data 200 times a second. In the callback of the acquisition board I take the data and copy it into the circular queue. Now the consumer consumes the data at a slower rate, my estimate is 100 times a second, so because it is consuming the data at a slower rate, there will be a time where the producer will overlap the consumer in the circular queue. When this happens and there is a semaphore on it, the data will then be locked and hence I would lose the new data coming in from the acquisition board, would I? Or am I compeltely misunderstanding this
Thanks again
|
|
|
|
|
what you MUST implement however is a security which will forbid the producer to write in the queue if it's already full... it must wait for a consumer goes by there
|
|
|
|
|
godspeed123 wrote: Now the way that it is going now I have this circular queue
Why a circular queue, and not a queue? Maybe even MSMQ[^]?
|
|
|
|
|
With a queue I thought I would over run the memory, and then cause the whole computer to crash.
|
|
|
|
|
godspeed123 wrote: With a queue I thought I would over run the memory, and then cause the whole computer to crash.
The queue does not need to store items (entirely) in the memory. Again, look at MSMQ - it stores messages in files in the MSMQ\Storage folder.
|
|
|
|
|
You may also do this,
Use queue(STL,maybe) and mark the zone you push data into the queue [queue::push(msg)] using Critical section. That works, simple.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Hi,
I'm writing a MFC application with callback dll functions, but it's have the problem with the callback function and mfc. I have two callback functions: OnInviteResult and OnLoginResult are called by a function in a dll. The first function OnLoginResult works fine, but OnInviteResult make the program halt when it execute the line:
pdlg->m_status.ReplaceSel("Connected\r\n");
I have debuged and seen pdlg pointer has the same address in both OnLoginResult and OnInviteResult functions.
Below is my code:
TestDLLDlg.cpp
CTestDLLDlg* pdlg;
.....
CTestDLLDlg::CTestDLLDlg(CWnd* pParent )
: CDialog(CTestDLLDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
pdlg = this;
}
......
void CALLBACK OnLoginResult(int *registered)
{
switch (*registered){
case 1:
pdlg->m_status.ReplaceSel("Registered\r\n");
break;
case 2:
pdlg->m_status.ReplaceSel("Invalid Username or Password\r\n");
break;
case 3:
pdlg->m_status.ReplaceSel("Service Unavaiable\r\n");
break;
}
}
void CALLBACK OnInviteResult(int *status)
{
switch (*status){
case 1:
pdlg->m_status.ReplaceSel("Ringing...\r\n");
break;
case 2:
pdlg->m_status.ReplaceSel("Connected\r\n");
break;
case 3:
pdlg->m_status.ReplaceSel("Hung up\r\n");
break;
default:
break;
}
}
int CTestDLLDlg::SetCallbackFunctions(void)
{
SetCallbackLogin(OnLoginResult);
SetCallbackInvite(OnInviteResult);
return 0;
}
Do you have any idea about this problem?
Any help would be appreciated.
DBQ.
-- modified at 17:31 Wednesday 21st March, 2007
|
|
|
|
|
Van Ly Doc Hanh wrote: but OnInviteResult make the program halt when it execute the line:
pdlg->m_status.ReplaceSel("Connected\r\n");
Which doesn't tell us a whole lot. Have you set a breakpoint on that statement and debugged into it?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I did set the break point on that statement and when I press F10 for that line, it run for a long time and my app become "Not Responding".
DBQ.
|
|
|
|
|
Van Ly Doc Hanh wrote: ...when I press F10 for that line...
I said step into, not over.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm sorry. I misunderstood your words.
When I hit F11, it pop up a windows:
"Finding source: afxwin2.inl"
f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\include\afxwin2.inl
I tried to step into and it looks like:
Dialog changes the text in CEdit control and send message to Window but there is no control takes that message -> program waiting forever.
How can I solve this problem?
DBQ.
-- modified at 17:27 Wednesday 21st March, 2007
|
|
|
|
|
Press "Shift" + F11 rather than F11.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Van Ly Doc Hanh wrote: I did set the break point on that statement and when I press F10 for that line, it run for a long time and my app become "Not Responding".
Use F11 for step into and check the behavior
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hello together,
I need some help for my dialog box.
I search an entry for my message map of one dialog box. This entry shall call a function if the dialog box is completly shown on the screen.
The most entries like ON_WM_CREATE or ON_WM_ACTIVATE are called the functions before the dialog box is completely shown on the screen.
Kind regards
GruenerSchreibtisch
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am trying to allow a cold fusion app to use a dll. I do not know cold fusion but they say that they use a tag to grab the dll and send it a parameter. It does not call an API function in the dll but rather calls the dll with a parameter. If i create a win 32 dll , can i just put my code in here:
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
Oh maybe not cause this returns bool.
I think it has to be a dll with a "main" section. Any input?
|
|
|
|