|
Yes, the compiler errors are a problem with STL, it can take a while to work out what is wrong. STL does NOT need wrappers though, it's just a case of learning the syntax so that when there is an error, you can work it out without trying to decipher the compilers errors.
Good luck !!!
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I'm using CMap because my MFC book talked about it, and it's a lot easier to understand than std::map, at least from looking at the examples.
|
|
|
|
|
Fair enough. I used MFC containers for a while, and was only vaguely aware of vector. But I'd recommend you read my STL articles here on CP. The stl is not hard at all, the syntax is just unfamiliar - MFC containers follow MFC naming conventions which make them look more familiar, but in fact map and CMap work pretty much the same way. map is more powerful because of the way it interacts with other containers and algorithms.
You really owe it to yourself to look more closely at stl - as I said, it is far superior to the MFC alternative, which Microsoft only provided as a stopgap, expecting people to take up STL as soon as it became available in VC.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
try this:
template<>
inline UINT AFXAPI HashKey(CString& key)
{
return HashKey((LPCTSTR)key);
}
this will define a function that can convert your CString to a DWORD. just drop it in the header file where you define your map.
-c
bit, n:
A unit of measure applied to color. Twenty-four-bit color refers to expensive $3 color as opposed to the cheaper 25 cent, or two-bit, color that use to be available a few years ago.
|
|
|
|
|
Thanks, that worked perfectly!
FYI, the arguments are <CString,CString&,BuddyInfo,BuddyInfo&>
|
|
|
|
|
Why don't you use CMapStringToPtr or CMapStringToOb instead of fully generic CMap?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
My service is running on a computer i want to getsome information that are
is the computer in logoff state or not ?
if computer is in a logoff state
i want to login,if i have username,password and domain how to login programatically?
how many software are installed in a computer ?
i also want to get installed software list names?
is there any api available for this purpose?
r00d0034@yahoo.com
|
|
|
|
|
lets say i have a regular expression (im using boost::regex)
([a-z],)*
and i Match() with "a," i get the following sub-expressions:
0) a, (the whole expression is first in boost::regex)<br />
1) a, (that's inside parentheses)
if i Match() with "a,b,c," however, i get:
0) a,<br />
1) c, (the last occurence of the things in parentheses)
i NEED to get all of the occurences though, like this:
0) a,<br />
1) a,<br />
2) b,<br />
3) c,
the problem is that, this is not a bug:
from
http://www.boost.org/libs/regex/syntax.htm#syntax[^]:
For example the expression "(ab)*" would match all of the string "ababab". The matching algorithms regex_match and regex_search each take an instance of match_results that reports what caused the match, on exit from these functions the match_results contains information both on what the whole expression matched and on what each sub-expression matched. In the example above match_results[1] would contain a pair of iterators denoting the final "ab" of the matching string.
so, can someone help me figure out how to get ALL of the matching occurences of the sub-expression?
thanks in advance
- Roman -
|
|
|
|
|
If you want to match a string with an arbitrary number of letters and commas, you will not succeed I'm afraid.
What you want is a context-free grammar for your input "language". I'm not sure if you are familiar with BNF (Backis-Naur Form), but here's such a grammar notation:
<string> ::= <string> <letter_comma_group>
| (empty)
<letter_comma_group> ::= ['a'-'z'] ','
Regular expressions can only handle languages which follow something called regular grammars. Regular grammars cannot handle self reference - thus you will not be able to do what you want.
Please see Chomskys grammar hierarchy[^] for more information on this topic.
If you want to solve your problem, I suggest you look into writing a recursive descent parser http://www.wikipedia.org/wiki/Recursive_descent_parser[^]. But before you start implementing the grammar I mentioned above, please make sure you rewrite it to be LL(n) compatible. (Left-recursion in an LL(n) grammar is a big no-no! Try it and you'll find out why.
<string> ::= <letter_comma_group> <opt_string>
| (empty)
<opt_string> ::= <letter_comma_group> <opt_string>
| (empty)
<letter_comma_group> ::= ['a'-'z'] ','
Good luck!
--
Please state the nature of your medical emergency.
|
|
|
|
|
There is no easy solution. How i've solved this in the past is to replace the matched pattern with something else, and loop, like this (perl) :-
$p="a,b,c,d,e,f,g,";
$matchcount=0;
while ($p=~s/([a-z],)
print ++$matchcount.": ".$1."\n";
Note that I lose the * from your pattern; you only want to match 1 at a time. =~ is the pattern operator in perl; // are delimeters around a pattern; s/// substitutes the first pattern with the second, ie nothing in this case. $1 is a special var which contains the first stored match.
Incidentally though, if your pattern really is as simple as a comma separated list, you may as well use a Split type function (theres bound to be one in your regexp library. In perl again:-
$p="a,b,c,d,e,f,g,";
@results = split (/,/ ,$p);
foreach $result (@results)
{
print $result."\n";
}
Hope that helps.
Signature space for rent. Apply by email to....
|
|
|
|
|
Hi,
have you ever come across converting a *.wbmp (wireless bitmap) into normal bitmap or *.jpg and vice versa?
Any answer would be highly appreciated!
Thanks
R.
|
|
|
|
|
Exactly what difference is there between a wireless bitmap and a normal bitmap? Please excuse my ignorance.
--
Please state the nature of your medical emergency.
|
|
|
|
|
A wireless bitmap is, like the small brother of a normal bitmap, small, primitive, monochrom, and on top of all it is of different structure than *.bmp because no MS tool (including IE or Paint) is able to show it.
It is used on wireless devices (handy). WAP pages are written in so called WML (Wireless Markup Laguage) and they can only have references to *.wbmp pictures.
I would want to show these pics on IE if I knew how to convert them to human readable format.
R.
|
|
|
|
|
this will do it: http://www.smalleranimals.com/thumb.htm
there's code on the codeproject site, too (i think), if you need that.
-c
bit, n:
A unit of measure applied to color. Twenty-four-bit color refers to expensive $3 color as opposed to the cheaper 25 cent, or two-bit, color that use to be available a few years ago.
|
|
|
|
|
The question came up today in our shop "can I call one constructor from another just like I can in java" and 'out of curiousity' tried to figure out if it can be done...After a few attempts (at what I thought were direct 'and sensible' approaches that only made the compiler whine) I came up with the following....Now, don't get me wrong, I'm not advocating that anyone *should* do this....only that it appears that you can and that it looks like it 'works'....
#include "stdafx.h"
#include "stdlib.h"
int flag;
class CtorTest
{
public:
CtorTest( void )
{
int x = 1;
}
CtorTest( int iFoo )
{
new( this ) CtorTest;
int x = 2;;
}
~CtorTest( void )
{
int x = 1;
}
void operator delete(void* p, CtorTest* poOuter)
{
free( poOuter );
}
void* operator new(size_t s, CtorTest* poOuter )
{
return poOuter;
}
};
int main(int argc, char* argv[])
{
printf("Hello World!\n");
int aNum = 5;
CtorTest x( aNum );
return 0;
}
Just trying to keep the forces of entropy at bay
|
|
|
|
|
okay, thought a little explanation is due here as well.....in main() we get a CtorTest object and the CtorTest::CtorTest(int) constructor gets called. Then we jump into the placement new function that effectively returns 'this'....Then from that point, we jump into the CtorTest::CtorTest(void) function ( invoked right after the return from the local placement new function. After that, control returns to the 'first constructor' call and we return to main. To support the assertion that there is only one CtorTest object created (?), the destructor is only called once......strange...very strange...
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Sure, why not? It's perfectly legal to do replacement new like that. However, I'm sure it would be frowned upon in a programming team.
One way to do it with a more java-like syntax would be:
template <typename T>
class java_lookalike_helper {
protected:
typedef T this_t;
};
#define this_ new (this) this_t
class Class : java_lookalike_helper<Class> {
int x, int y;
public:
Class(int x_) : x(x_) {
}
Class(int x_, int y_) : y(_y) {
this_(x_);
}
};
--
Please state the nature of your medical emergency.
|
|
|
|
|
thanx for that variant of this idea. I'll add that to the 'tool kit' and play around with that as well.....this arcane-chicanery must be what causes some advocates to lean toward the 'managed code' camp...where we likely can't have this kind of 'fun' with the language ;)
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Hey, exploring seamingly nutty ideas may indeed evolve into something really cool. Just look at ATL and WTL - now there are some wild and crazy ideas that have evolved into something cool and useful
And the advocates can bite me and my gotos.
--
Please state the nature of your medical emergency.
|
|
|
|
|
Jörgen Sigvardsson wrote:
And the advocates can bite me and my gotos
I'm with you buddy! I've been known to sprinkle a goto on an as-needed basis (much to the chagrin of some 'religious types')....but only when it does not violate the idea of 'good taste'
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Hi
I have a Dialogbased MFC Application,
on the Dialog there is a "textfield" (CEdit) called m_thing.
m_thing.SetWindowText("something");
changes the "textfield"'s content to "something"
my problem: i need to change the "textfield" when there comes data
on a tcp/ip network socket
now i have a class CMySock derived from CAsyncSocket.
the OnReceive method is overlayed / overwritten by my own method.
in the dialog class i create a CMySocket and connect it
then there comes data
in my Onreceive method there is code to receive this data
(i can give it out with an AfxMessageBox this works fine)
but i need to change the "textfield" on the dialog
but the m_thing is not known in my CMySocket class
my question:
how do i get the data from the Onreceive method to my textfield /
to the dialog class...
i read stuff about messages and ON_COMMAND's and alot more i do not
understand
do i need to create an new class to use the OnReceive??
please help
and please excuse the bad expressions like "textfield"
thanks mb
|
|
|
|
|
Fist override the Onreceive event of ur CMySock class
like as follows
void CClientSocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
AfxGetMainWnd()->PostMessage(WM_APP + 24, 0,0);
CSocket::OnReceive(nErrorCode);
}
Then post a MEssage to the main window from here "AfxGetMainWnd()->PostMessage(WM_APP + 24, 0,0);"
I then dialog catch this message
ON_MESSAGE(SOCK_RCV_MSG, OnReceive)
void CClientDlg::OnReceive()
{
char buff[SEND_BUF_SIZE];
int nBytes;
CString strLog;
nBytes = m_Sock1->Receive(buff, SEND_BUF_SIZE);
if(nBytes == 0)
{
// got disconnected
}
}
Now u can do anything witht he data in the buff
Hope this will help u
|
|
|
|
|
|
Thought some of you might be interested in the following page:
http://msdn.microsoft.com/library/en-us/dnapiover/html/api-overview.asp
It documents some of the APIs that Microsoft has hidden from us to make their programs unique or a step-ahead.
"November 2001, Microsoft, the U.S. Department of Justice, and nine State Attorneys General agreed to a proposed settlement of the government's antitrust case (proposed consent decree). For more information (including a comprehensive archive of documents and transcripts of proceedings) about the proposed consent decree, see the Microsoft Press Pass Settlement Proceedings Web page. For more information about how Microsoft has fulfilled its obligations under the decree, please see the Microsoft Settlement Program Web page.
As part of that settlement, Microsoft agreed to document the interfaces used by "Microsoft Middleware" (as defined in the proposed consent decree) to obtain services from the Microsoft® Windows® 2000 and Windows XP desktop client operating systems. The vast majority of these interfaces were already documented among the thousands of Application Programming Interfaces (APIs) in the Microsoft Platform Software Development Kit (SDK).
Microsoft teams identified a few hundred undocumented Windows interfaces or parameters that were used by one or more of the Microsoft Middleware components. Microsoft's technical writers have documented these interfaces and made them available as APIs in the MSDN Online Library."
Cheers,
uniken
|
|
|
|
|
No big news. Most of this functions are not even correctly documented and few of them are helpful. Calling this an "advantage" is a joke.
The really useful interfaces are still undocumented.
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|