Sunday, January 31, 2010

RE: [jQuery] Browser / AJAX help

Yes its there...just a miss on the copy / paste. No errors reported in FF or
IE using firebug / IE developer bar. Cant find one for chrome. Just weirs
how Opera and Chrome wont save a new bookmark yet if there is a bookmark
saved fromFF or IE theni go to Chrome or Opera they will remove a bookmark,
but wont save one.

Dave

-----Original Message-----
From: Andreas Möller [mailto:localheinz@l8m.de]
Sent: February-01-10 1:39 AM
To: jquery-en@googlegroups.com
Subject: RE: [jQuery] Browser / AJAX help

Have you checked the console to see whether the parameter you pass to your
server side script is empty or not?

The code you pasted lacks a curly bracket, a closing parenthesis and a
semi-colon, but I assume you've got it in your original code, haven't you?


Best regards,

Andreas

RE: [jQuery] Browser / AJAX help

Have you checked the console to see whether the parameter you pass to your server side script is empty or not?

The code you pasted lacks a curly bracket, a closing parenthesis and a semi-colon, but I assume you've got it in your original code, haven't you?


Best regards,

Andreas

comp.lang.c++ - 25 new messages in 7 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* Discount Wholesale Armani Jeans Christian Audigier Jeans ED Hardy Jeans (www.
vipchinatrade.com) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/62cb14b1f5535017?hl=en
* Paypal payment Cheap Wholesale Sneakers Air Force One, Air Max LTD, Max TN,
Nike Shox etc (www.vipchinatrade.com) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/5fcfd51f11a7328a?hl=en
* Safe to use substr? - 7 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/cece8bdad80abdbe?hl=en
* C++0x regex supported by gcc? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/a5e3fb25be9236a9?hl=en
* Escape a string to bytes - 9 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/0ed981f009a7ba73?hl=en
* Again substrings and so on - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/736557e5175db0ba?hl=en
* isspace - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en

==============================================================================
TOPIC: Discount Wholesale Armani Jeans Christian Audigier Jeans ED Hardy Jeans
(www.vipchinatrade.com)
http://groups.google.com/group/comp.lang.c++/t/62cb14b1f5535017?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Jan 31 2010 8:03 am
From: wendy


Cheap Wholesale Shox NZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox OZ <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox R2 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3+R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R5 <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TL <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Torch <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TZ <www.vipchinatrade.com> paypal payment

Cheap Wholesale Nike Air Max 87 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 89 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 97 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max LTD <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max TN <www.vipchinatrade.com> paypal
payment

Air Force one <www.vipchinatrade.com> paypal payment
Cheap Wholesale Air Force One Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One M&W <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Kid <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.vipchinatrade.com>
paypal payment

==============================================================================
TOPIC: Paypal payment Cheap Wholesale Sneakers Air Force One, Air Max LTD, Max
TN, Nike Shox etc (www.vipchinatrade.com)
http://groups.google.com/group/comp.lang.c++/t/5fcfd51f11a7328a?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Jan 31 2010 8:05 am
From: yoyo


Cheap Wholesale Shox NZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox OZ <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox R2 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3+R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R5 <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TL <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Torch <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TZ <www.vipchinatrade.com> paypal payment

Cheap Wholesale Nike Air Max 87 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 89 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 97 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max LTD <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max TN <www.vipchinatrade.com> paypal
payment

Air Force one <www.vipchinatrade.com> paypal payment
Cheap Wholesale Air Force One Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One M&W <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Kid <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.vipchinatrade.com>
paypal payment

==============================================================================
TOPIC: Safe to use substr?
http://groups.google.com/group/comp.lang.c++/t/cece8bdad80abdbe?hl=en
==============================================================================

== 1 of 7 ==
Date: Sun, Jan 31 2010 8:58 am
From: Immortal Nephi


On Jan 31, 2:47 am, Robert Fendt <rob...@fendt.net> wrote:
> And thus spake Immortal Nephi <Immortal_Ne...@hotmail.com>
> Sat, 30 Jan 2010 18:49:34 -0800 (PST):
>
> >    I want to know that size_type returns –1 (minus one) is safe before I
> > extract one string into two substrings.  First example is safe and
> > second example is not sure.
>
> >    const basic_string <char>::size_type npos = -1;
>
> Why don't you just use std::string (which is a typedef of std::basic_string<char>)? It is more readable. Secondly, consider using string::npos instead of redefining it yourself. IIRC, the exact definition of npos is implementation-defined, thus it is dangerous to assume too much about it. It _is_ in fact defined as (size_t)-1 on almost all systems, but strictly speaking that depends on implementation and processor architecture.
>
> > begin_index returns 0 and end_index returns 5.  substr is safe.
>
> Let's just say, it does what you expected it to do.
>
> > Second example:
>
> >    begin_index = data.find_first_not_of( " ", end_index );
> >    end_index = data.find_first_of( " ", begin_index );
> >    token2 = data.substr( begin_index, end_index - begin_index );
> >    length_index = token2.length();
>
> > begin_index returns 6 and end_index returns –1.  Is substr safe for
> > token2 because end_index returns –1 indicates space character is not
> > found.
>
> Yes. The standard specifies that its parameters are of type string::size_type, thus (at least in case of basic_string<char> and basic_string<wchar_t>) they are definitely unsigned. So in fact you are passing a _very_ large number as second parameter. My standard library docs state that if the second parameter points beyond the string, the end of the string is assumed instead (in fact, the default value for the second parameter is string::npos).

find_first_not of() function and find_first_of() function always
return unsigned integer like size_type. The size _type gives you the
information if unsigned integer is valid or not valid.
The minimum size_type is 0 and maximum size_type is 0xFFFFFFFE (on 32
bit machine). Both integer values provide you the information how
many elements do string have. The 0xFFFFFFFF or –1 indicates that
data in the string is not found or is not valid.
Let's discuss substr() function. The substr() function's first
parameter must always have minimum size_type and maximum size_type.
If 0xFFFFFFFF or –1 is detected, then exception will be thrown.
The second parameter always has default 0xFFFFFFFF or –1 if you do
not assign second parameter.

For example

string data( "Hello World!" );
string token = data.substr( 0 );

The data has 11 elements in length. Notice that second parameter in
substr() function is not assigned. The default is –1. How do substr
() function know to count 11 elements correctly? It should always
count all 256 values of character set including '\0'.
If you insert '\0' between Hello and World ( "Hello \0World!" ), then
it will count 12 elements including '\0'. The string object is not
like C string. It does not check null terminator and it always check
number of elements in size with size() function or length() function.

end_token = 5;
begin_token = data.find_first_not_of( " ", end_token + 1 );
end_token = data.find_first_of( " ", begin_token );

string token = data.substr( begin_token, end_token - begin_token );
length_token = token.length();

find_first_of() function returns –1 indicates space is not found.
substr() function cannot guarantee to assume to be 11. Possibly, it
will go beyond 11 elements boundary until it detects '\0' and returns
the wrong end_token value.

I think that my example code above is not a good solution. I will
use iterator loop to test each element instead.


== 2 of 7 ==
Date: Sun, Jan 31 2010 1:19 pm
From: LR


Immortal Nephi wrote:

> find_first_not of() function and find_first_of() function always
> return unsigned integer like size_type. The size _type gives you the
> information if unsigned integer is valid or not valid.
> The minimum size_type is 0 and maximum size_type is 0xFFFFFFFE (on 32
> bit machine). Both integer values provide you the information how
> many elements do string have. The 0xFFFFFFFF or –1 indicates that
> data in the string is not found or is not valid.


> Let's discuss substr() function. The substr() function's first
> parameter must always have minimum size_type and maximum size_type.

I think you mean the argument pos must be between 0 and size().
const std::string s ("Hello World");
const std::string t = s.substr(); // pos == 0
const std::string u = s.substr(0);
const std::string v = s.substr(s.size());

> If 0xFFFFFFFF or –1 is detected, then exception will be thrown.
> The second parameter always has default 0xFFFFFFFF or –1 if you do
> not assign second parameter.
>
> For example
>
> string data( "Hello World!" );
> string token = data.substr( 0 );
>
> The data has 11 elements in length. Notice that second parameter in
> substr() function is not assigned. The default is –1. How do substr
> () function know to count 11 elements correctly?

std::string keeps track of the length or size of the string. It doesn't
use zero termination the way C strings do.

Also, note that a std::string cannot grow to be larger than
std::string::max_size(). In the implementation I use this is
std::numeric_limits<std::string::size_type>::max()-1.

>It should always
> count all 256 values of character set including '\0'.

It will. Try this:

const std::string s =
std::string("Hello") + '\0' + std::string("World");
std::cout << s << std::endl;
std::cout << s.size() << std::endl;

> If you insert '\0' between Hello and World ( "Hello \0World!" ), then
> it will count 12 elements including '\0'. The string object is not
> like C string. It does not check null terminator and it always check
> number of elements in size with size() function or length() function.
>
> end_token = 5;
> begin_token = data.find_first_not_of( " ", end_token + 1 );

You're not looking for the '\0'.

> end_token = data.find_first_of( " ", begin_token );

Same.
>
> string token = data.substr( begin_token, end_token - begin_token );
> length_token = token.length();

I think this will work:

const std::string
data = std::string("Hello ") + '\0' + std::string("World");

const std::string look_for = std::string(" ")+'\0';
const std::string::size_type first = data.find_first_of(look_for);
const std::string::size_type
begin_token = data.find_first_not_of(look_for, first+1);
const std::string::size_type
end_token = data.find_first_of(look_for, begin_token);

const std::string
token = data.substr(begin_token, end_token-begin_token);
const std::string::size_type length_token = token.length();


LR


== 3 of 7 ==
Date: Sun, Jan 31 2010 1:57 pm
From: James Kanze


On 31 Jan, 16:58, Immortal Nephi <Immortal_Ne...@hotmail.com> wrote:
> On Jan 31, 2:47 am, Robert Fendt <rob...@fendt.net> wrote:
> > And thus spake Immortal Nephi <Immortal_Ne...@hotmail.com>
> > Sat, 30 Jan 2010 18:49:34 -0800 (PST):

[...]
> > > Second example:

> > > begin_index = data.find_first_not_of( " ", end_index );
> > > end_index = data.find_first_of( " ", begin_index );
> > > token2 = data.substr( begin_index, end_index - begin_index );
> > > length_index = token2.length();
>
> > > begin_index returns 6 and end_index returns -1. Is substr
> > > safe for token2 because end_index returns -1 indicates
> > > space character is not found.

> > Yes. The standard specifies that its parameters are of type
> > string::size_type, thus (at least in case of
> > basic_string<char> and basic_string<wchar_t>) they are
> > definitely unsigned. So in fact you are passing a _very_
> > large number as second parameter. My standard library docs
> > state that if the second parameter points beyond the string,
> > the end of the string is assumed instead (in fact, the
> > default value for the second parameter is string::npos).

> find_first_not of() function and find_first_of() function
> always return unsigned integer like size_type. The size_type
> gives you the information if unsigned integer is valid or not
> valid.

I'm afraid I don't understand that last sentence. A type can't
give you any information.

> The minimum size_type is 0 and maximum size_type is 0xFFFFFFFE
> (on 32 bit machine). Both integer values provide you the
> information how many elements do string have.

What do you mean by "both" here? A zero value designates the
first character of the string, or indicates that the length of
the string is 0. The maximum value is used as a sentinal:
std::string::size will never return it. The only functions
which do return it are those which look for something, and they
use it as a special value, to indicate that they didn't find
what they were looking for.

> The 0xFFFFFFFF or -1 indicates that data in the string is not
> found or is not valid.

(Just a nit, but 0xFFFFFFFF is *not* -1. They're two different
values.)

> Let's discuss substr() function. The substr() function's
> first parameter must always have minimum size_type and maximum
> size_type.

The first argument must be in the range [0...s.size()], where s
is the string you're concerned with. It specifies the index of
the first character in the substring you want.

> If 0xFFFFFFFF or -1 is detected, then exception will be
> thrown.

(Again, -1 cannot be detected, because it cannot be represented
on the type of the argument.)

> The second parameter always has default 0xFFFFFFFF or -1 if
> you do not assign second parameter.

> For example

> string data( "Hello World!" );
> string token = data.substr( 0 );

> The data has 11 elements in length. Notice that second
> parameter in substr() function is not assigned. The default
> is -1.

The default is std::string::npos, not -1.

> How do substr () function know to count 11 elements
> correctly?

It's a member function. It knows the length of the string.
(How do you think std::string::size works?)

> It should always count all 256 values of character set
> including '\0'.

It doesn't count anything.

> If you insert '\0' between Hello and World ( "Hello \0World!"
> ), then it will count 12 elements including '\0'. The string
> object is not like C string. It does not check null
> terminator and it always check number of elements in size with
> size() function or length() function.

> end_token = 5;
> begin_token = data.find_first_not_of( " ", end_token + 1 );
> end_token = data.find_first_of( " ", begin_token );

> string token = data.substr( begin_token, end_token - begin_token );
> length_token = token.length();

> find_first_of() function returns -1 indicates space is not found.

It returns std::string::npos (which is *not* -1) to indicate
that it didn't find any character in the list given.

> substr() function cannot guarantee to assume to be 11.
> Possibly, it will go beyond 11 elements boundary until it
> detects '\0' and returns the wrong end_token value.

Why on earth would it do a thing like that? An std::string
knows its length, and unless the standard specifically states
otherwise, it uses this length. No member function ever looks
for '\0'.

> I think that my example code above is not a good solution. I
> will use iterator loop to test each element instead.

I think you still have a lot to learn about the standard
library. (And also expressing yourself clearly---which is a
prerequisite to good programming. I don't know how much of this
is due to English not being your native language, however.)

--
James Kanze


== 4 of 7 ==
Date: Sun, Jan 31 2010 2:00 pm
From: James Kanze


On 31 Jan, 21:19, LR <lr...@superlink.net> wrote:
> Immortal Nephi wrote:

[...]
> I think this will work:

> const std::string
> data = std::string("Hello ") + '\0' + std::string("World");

An even simpler solution might be:
std::string const data( "Hello \0World", 12 );

--
James Kanze


== 5 of 7 ==
Date: Sun, Jan 31 2010 2:14 pm
From: "Leigh Johnston"


>
>> If 0xFFFFFFFF or -1 is detected, then exception will be
>> thrown.
>
> (Again, -1 cannot be detected, because it cannot be represented
> on the type of the argument.)
>

assert(static_cast<unsigned int>(-1) == -1);

:)

/Leigh


== 6 of 7 ==
Date: Sun, Jan 31 2010 4:52 pm
From: Öö Tiib


On Feb 1, 12:14 am, "Leigh Johnston" <le...@i42.co.uk> wrote:
> >> If 0xFFFFFFFF or -1 is detected, then exception will be
> >> thrown.
>
> > (Again, -1 cannot be detected, because it cannot be represented
> > on the type of the argument.)
>
> assert(static_cast<unsigned int>(-1) == -1);
>
> :)
>
> /Leigh

Anyway you get diagnostic warnings for it from most compilers. If
'static_cast<unsigned int>(-1)' is needed then '~0U' is perhaps
shortest form that makes all compilers happy with it.


== 7 of 7 ==
Date: Sun, Jan 31 2010 5:35 pm
From: "Leigh Johnston"


"�� Tiib" <ootiib@hot.ee> wrote in message
news:14afcc94-19e6-4024-a8d6-425716d430d4@o28g2000yqh.googlegroups.com...
> On Feb 1, 12:14 am, "Leigh Johnston" <le...@i42.co.uk> wrote:
>> >> If 0xFFFFFFFF or -1 is detected, then exception will be
>> >> thrown.
>>
>> > (Again, -1 cannot be detected, because it cannot be represented
>> > on the type of the argument.)
>>
>> assert(static_cast<unsigned int>(-1) == -1);
>>
>> :)
>>
>> /Leigh
>
> Anyway you get diagnostic warnings for it from most compilers. If
> 'static_cast<unsigned int>(-1)' is needed then '~0U' is perhaps
> shortest form that makes all compilers happy with it.

Neither VC++ nor g++ complain, two of the most popular compilers.

/Leigh


==============================================================================
TOPIC: C++0x regex supported by gcc?
http://groups.google.com/group/comp.lang.c++/t/a5e3fb25be9236a9?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Jan 31 2010 9:08 am
From: mattia


Hi all, do you know if gcc supports the regex library defined in the C+
+0x draft? If so, which version? Can you provide a simple snippet?

Thanks, Mattia


== 2 of 2 ==
Date: Sun, Jan 31 2010 9:43 am
From: Robert Fendt

> Hi all, do you know if gcc supports the regex library defined in the C+
> +0x draft? If so, which version? Can you provide a simple snippet?

As far as I know, GCC does not support regular expressions as defined in TR1 as part of its standard library (yet). However, to use 0x features already before standardisation would be a portability nightmare (not to speak of stability issues to be expected in the early implementations).

If you want to stay at least semi-portable and need a solid regex library for C++, just use boost::regex for now. The TR1 specification is based upon it anyway. Or, if you are concerned about code changes after the compilers have caught up with the standard, you can use boost::tr1.

http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/html/index.html
http://www.boost.org/doc/libs/1_41_0/doc/html/boost_tr1.html

Regards,
Robert


==============================================================================
TOPIC: Escape a string to bytes
http://groups.google.com/group/comp.lang.c++/t/0ed981f009a7ba73?hl=en
==============================================================================

== 1 of 9 ==
Date: Sun, Jan 31 2010 10:32 am
From: Philliam Auriemma


Hey guys,

I have a problem. I am building a program that needs to take a string
like "\x20\x21" or something (just the fact that it's hex is
significant) and turn it into a string that has those sequences turned
into 'bytes' or whatever. So, In the previous example, it would take
the string "\x20\x21" and turn it into " !". The source from which I
am getting this string does not provide any way to do this, so I need
the source to pass a C++ dll a string, C++ works on it, and returns
the proper string. The format in which it must be is not \xblah, it
can just be numbers separated by a space, or whatever would be
easiest, like "20 21" etc.
Thanks for any help.


== 2 of 9 ==
Date: Sun, Jan 31 2010 10:54 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


Philliam Auriemma <phil.auriemma@gmail.com> writes:
>the string "\x20\x21" and turn it into " !". The source from which I

The following prints » !«, but I wrote it in C, not C++,
maybe you can translate it to C++.

#include <stdio.h> /* putchar */
#include <ctype.h> /* isxdigit */

void append( unsigned int const value ){ putchar(( int )value ); }

void terminate( void ){ putchar( '\n' ); }

int main( void )
{ const char * const source = "\\x20 21";
for( const char * p = source; *p; )
{ while( !isxdigit( *p ) && *p )++p;
if( *p )
{ unsigned int value; sscanf( p, "%x", &value );
append( value );
while( isxdigit( *p ) && *p )++p; }}
terminate(); }

== 3 of 9 ==
Date: Sun, Jan 31 2010 11:02 am
From: Philliam Auriemma


On Jan 31, 10:54 am, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> Philliam Auriemma <phil.aurie...@gmail.com> writes:
> >the string "\x20\x21" and turn it into " !". The source from which I
>
>   The following prints » !«, but I wrote it in C, not C++,
>   maybe you can translate it to C++.
>
> #include <stdio.h> /* putchar  */
> #include <ctype.h> /* isxdigit */
>
> void append( unsigned int const value ){ putchar(( int )value ); }
>
> void terminate( void ){ putchar( '\n' ); }
>
> int main( void )
> { const char * const source = "\\x20 21";
>   for( const char * p = source; *p; )
>   { while( !isxdigit( *p ) && *p )++p;
>     if( *p )
>     { unsigned int value; sscanf( p, "%x", &value );
>       append( value );
>       while( isxdigit( *p ) && *p )++p; }}
>   terminate(); }

Thanks, I'll try it out right away.


== 4 of 9 ==
Date: Sun, Jan 31 2010 11:49 am
From: Victor Bazarov


Philliam Auriemma wrote:
> I have a problem. I am building a program that needs to take a string
> like "\x20\x21" or something (just the fact that it's hex is
> significant) and turn it into a string that has those sequences turned
> into 'bytes' or whatever. So, In the previous example, it would take
> the string "\x20\x21" and turn it into " !". The source from which I
> am getting this string does not provide any way to do this, so I need
> the source to pass a C++ dll a string, C++ works on it, and returns
> the proper string. The format in which it must be is not \xblah, it
> can just be numbers separated by a space, or whatever would be
> easiest, like "20 21" etc.

I honestly don't understand what the problem is.

std::string space_bang_ascii("\x20\x21");

Perhaps you need to specify it a bit clearer... Try pseudocode.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 5 of 9 ==
Date: Sun, Jan 31 2010 12:13 pm
From: Daniel Giaimo


On 1/31/2010 2:49 PM, Victor Bazarov wrote:
> Philliam Auriemma wrote:
>> I have a problem. I am building a program that needs to take a string
>> like "\x20\x21" or something (just the fact that it's hex is
>> significant) and turn it into a string that has those sequences turned
>> into 'bytes' or whatever. So, In the previous example, it would take
>> the string "\x20\x21" and turn it into " !". The source from which I
>> am getting this string does not provide any way to do this, so I need
>> the source to pass a C++ dll a string, C++ works on it, and returns
>> the proper string. The format in which it must be is not \xblah, it
>> can just be numbers separated by a space, or whatever would be
>> easiest, like "20 21" etc.
>
> I honestly don't understand what the problem is.
>
> std::string space_bang_ascii("\x20\x21");
>
> Perhaps you need to specify it a bit clearer... Try pseudocode.

I think he meant that he is reading the string in from somewhere else
and it is known to consist of sequences like "\\x20\\x21", (doubled '\'
to clarify that the string itself contains a '\'), and he wants to
parse the string.

--
Dan G


== 6 of 9 ==
Date: Sun, Jan 31 2010 12:43 pm
From: Philliam Auriemma


On Jan 31, 12:13 pm, Daniel Giaimo <dgia...@gmail.com> wrote:
> On 1/31/2010 2:49 PM, Victor Bazarov wrote:
>
>
>
> > Philliam Auriemma wrote:
> >> I have a problem. I am building a program that needs to take a string
> >> like "\x20\x21" or something (just the fact that it's hex is
> >> significant) and turn it into a string that has those sequences turned
> >> into 'bytes' or whatever. So, In the previous example, it would take
> >> the string "\x20\x21" and turn it into " !". The source from which I
> >> am getting this string does not provide any way to do this, so I need
> >> the source to pass a C++ dll a string, C++ works on it, and returns
> >> the proper string. The format in which it must be is not \xblah, it
> >> can just be numbers separated by a space, or whatever would be
> >> easiest, like "20 21" etc.
>
> > I honestly don't understand what the problem is.
>
> > std::string space_bang_ascii("\x20\x21");
>
> > Perhaps you need to specify it a bit clearer... Try pseudocode.
>
> I think he meant that he is reading the string in from somewhere else
> and it is known to consist of sequences like "\\x20\\x21", (doubled '\'
> to clarify that the string itself contains a '\'), and he wants to
> parse the string.
>
> --
> Dan G

Yeah, actually I am getting them from Lua which does not support
putting hex characters or whatever you call them in strings, so I
would make a DLL to load from Lua that would pass "40 39 20" for
example (since doing "\x40\x39\x20" would do absolutely nothing, and
would probably be an unknown escape sequence), and then the DLL would
return whatever that would equal if you had done "\x40\x39\x20" in C++.


== 7 of 9 ==
Date: Sun, Jan 31 2010 2:45 pm
From: ram@zedat.fu-berlin.de (Stefan Ram)


Philliam Auriemma <phil.auriemma@gmail.com> writes:
>the string "\x20\x21" and turn it into " !". The source from which I

Now, a C++ version:

#include <iostream> /* ::std::cout */
#include <ostream> /* << */
#include <sstream> /* ::std::stringstream */
#include <ios> /* ::std::hex */

int main()
{ char const * const source_ = "\\x20 21";
::std::stringstream source( source_ ), target;
int val; while( !source.eof() )
{ source >> ::std::hex >> val;
if( source.fail() ){ source.clear(); char d; source.get( d ); }
else target <<( char )val; }
::std::cout << target.str() << '\n'; }

== 8 of 9 ==
Date: Sun, Jan 31 2010 7:03 pm
From: Philliam Auriemma


On Jan 31, 2:45 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
> Philliam Auriemma <phil.aurie...@gmail.com> writes:
> >the string "\x20\x21" and turn it into " !". The source from which I
>
>   Now, a C++ version:
>
> #include <iostream> /* ::std::cout         */
> #include <ostream>  /* <<                  */
> #include <sstream>  /* ::std::stringstream */
> #include <ios>      /* ::std::hex          */
>
> int main()
> { char const * const source_ = "\\x20 21";
>   ::std::stringstream source( source_ ), target;
>   int val; while( !source.eof() )
>   { source >> ::std::hex >> val;
>     if( source.fail() ){ source.clear(); char d; source.get( d ); }
>     else target <<( char )val; }
>   ::std::cout << target.str() << '\n'; }

Any idea how I could make it into a 'string' that could contain null
characters?


== 9 of 9 ==
Date: Sun, Jan 31 2010 7:23 pm
From: ram@zedat.fu-berlin.de (Stefan Ram)


Philliam Auriemma <phil.auriemma@gmail.com> writes:
>Any idea how I could make it into a 'string' that could contain null
>characters?

This is already possible with the version you just quoted.


==============================================================================
TOPIC: Again substrings and so on
http://groups.google.com/group/comp.lang.c++/t/736557e5175db0ba?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Jan 31 2010 2:08 pm
From: Paavo Helde


Vicent Giner-Bosch <vginer@gmail.com> wrote in news:61baf361-09b9-4ae1-
9cdd-f619901b3ed6@u41g2000yqe.googlegroups.com:

> My question is this: Is Boost string library too "heavy" to include? I
> mean, if I only use it "for a while", if I am not going to use it "a
> lot", is it worthy to use it? I DO think so, but I would like to read
> more opinions...

If you have any plans to continue to write code in C++ in the future, then
I would suggest to make use of Boost libraries as much as possible. It
might take some effort to learn how to use them, but the benefits are that
the Boost libraries are generally of much higher quality than a C++
beginner would be able to code by himself, and the code will be easier to
grok for another programmer.

Paavo

==============================================================================
TOPIC: isspace
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en
==============================================================================

== 1 of 4 ==
Date: Sun, Jan 31 2010 2:27 pm
From: gervaz


On Jan 31, 2:17 pm, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> gervaz <ger...@gmail.com> wrote innews:a5a4ece2-5b9d-4846-a818-9de61c130654@r24g2000yqd.googlegroups.com:
>
>
>
> > On Jan 31, 10:39 am, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> >> Paavo Helde <myfirstn...@osa.pri.ee> wrote
> >> innews:Xns9D116950C4paavo256@2
> > 16.196.109.131:
>
> >> > gervaz <ger...@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
> >> > 6dec26dab...@o28g2000yqh.googlegroups.com:
>
> >> >> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
> >> >>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>
> >> >>> > James Kanze <james.ka...@gmail.com> writes:
> >> >>> > >There are no standard names for locales
> >> >>> >   AFAIK, C90 defines a locale by the name of "C",
> >> >>> >   which should also be visible from C++.
>
> >> >>> And Posix defines "POSIX".  Neither of which are really useful
> >> >>> for anything.
>
> >> >>> --
> >> >>> James Kanze
>
> >> >> Ok, so I think that I will open my file specifying to use UTF-8
> >> >> encoding, but how can I do it in C++?
>
> >> > You can open it as a narrow stream and read in as binary UTF-8, or
> >> > (maybe) you can open it as a wide stream and get an automatic
> >> > translation from UTF-8 to wchar_t. The following example assumes
> >> > that you have a file test1.utf containing valid UTF-8 text. It
> >> > reads the file in as a wide stream and prints out the numeric
> >> > values of all wchar_t characters.
>
> >> > #include <iostream>
> >> > #include <fstream>
> >> > #include <locale>
> >> > #include <string>
>
> >> > int main() {
> >> >     std::wifstream is;
> >> >     const std::locale filelocale("en_US.UTF8");
> >> >     is.imbue(filelocale);
> >> >     is.open("test1.utf8");
>
> >> >     std::wstring s;
> >> >     while(std::getline(is, s)) {
> >> >         for (std::wstring::size_type j=0; j<s.length(); ++j)
> > {
> >> >             std::cout << s[j] << " ";
> >> >         }
> >> >         std::cout << "\n";
> >> >     }
> >> > }
>
> >> > (Tested on Linux with a recent gcc, I am not too sure if this works
> >> > on Windows. First, wchar_t in MSVC is too narrow for real Unicode,
> >> > at best one might get UTF-16 as a result.)
>
> >> For curiosity, I tested this also on Windows with MSVC9, and as
> >> expected it did not work, the locale construction immediately threw
> >> an exception (bad locale name). Neither did any alterations work
> >> ("english.UTF8", ".UTF8", ".utf-8", ".65001").
>
> >> Thus, if one wants any portability it seems the best approach
> >> currently is still to read in binary UTF-8 and perform any needed
> >> conversions by hand.
>
> >> Paavo
>
> > Under Windows, you have to use const std::locale filelocale
> > ("English_Australia.1252") according to
> >http://docs.moodle.org/en/Table_of_locales, I've tested it in VC++08
> > and it works. Any suggestion in how to handle the dualism?
>
> Did you actually test the results? It seems this is reading UTF-8 in
> unaltered, so there is no point to use a wide stream in the first place.
>
> Paavo

Well, yeah, although using an example file like
http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt and using
plain std::string, std::ifstream and std::cout everything works fine,
if I put the 'w' in front of all this types the sysout fails
producing:

UTF-8 encoded sample plain-text file
Γ

Why??


== 2 of 4 ==
Date: Sun, Jan 31 2010 4:02 pm
From: Öö Tiib


On Feb 1, 12:27 am, gervaz <ger...@gmail.com> wrote:
> On Jan 31, 2:17 pm, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
>
>
>
>
>
> > gervaz <ger...@gmail.com> wrote innews:a5a4ece2-5b9d-4846-a818-9de61c130654@r24g2000yqd.googlegroups.com:
>
> > > On Jan 31, 10:39 am, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> > >> Paavo Helde <myfirstn...@osa.pri.ee> wrote
> > >> innews:Xns9D116950C4paavo256@2
> > > 16.196.109.131:
>
> > >> > gervaz <ger...@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
> > >> > 6dec26dab...@o28g2000yqh.googlegroups.com:
>
> > >> >> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
> > >> >>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>
> > >> >>> > James Kanze <james.ka...@gmail.com> writes:
> > >> >>> > >There are no standard names for locales
> > >> >>> >   AFAIK, C90 defines a locale by the name of "C",
> > >> >>> >   which should also be visible from C++.
>
> > >> >>> And Posix defines "POSIX".  Neither of which are really useful
> > >> >>> for anything.
>
> > >> >>> --
> > >> >>> James Kanze
>
> > >> >> Ok, so I think that I will open my file specifying to use UTF-8
> > >> >> encoding, but how can I do it in C++?
>
> > >> > You can open it as a narrow stream and read in as binary UTF-8, or
> > >> > (maybe) you can open it as a wide stream and get an automatic
> > >> > translation from UTF-8 to wchar_t. The following example assumes
> > >> > that you have a file test1.utf containing valid UTF-8 text. It
> > >> > reads the file in as a wide stream and prints out the numeric
> > >> > values of all wchar_t characters.
>
> > >> > #include <iostream>
> > >> > #include <fstream>
> > >> > #include <locale>
> > >> > #include <string>
>
> > >> > int main() {
> > >> >     std::wifstream is;
> > >> >     const std::locale filelocale("en_US.UTF8");
> > >> >     is.imbue(filelocale);
> > >> >     is.open("test1.utf8");
>
> > >> >     std::wstring s;
> > >> >     while(std::getline(is, s)) {
> > >> >         for (std::wstring::size_type j=0; j<s.length(); ++j)
> > > {
> > >> >             std::cout << s[j] << " ";
> > >> >         }
> > >> >         std::cout << "\n";
> > >> >     }
> > >> > }
>
> > >> > (Tested on Linux with a recent gcc, I am not too sure if this works
> > >> > on Windows. First, wchar_t in MSVC is too narrow for real Unicode,
> > >> > at best one might get UTF-16 as a result.)
>
> > >> For curiosity, I tested this also on Windows with MSVC9, and as
> > >> expected it did not work, the locale construction immediately threw
> > >> an exception (bad locale name). Neither did any alterations work
> > >> ("english.UTF8", ".UTF8", ".utf-8", ".65001").
>
> > >> Thus, if one wants any portability it seems the best approach
> > >> currently is still to read in binary UTF-8 and perform any needed
> > >> conversions by hand.
>
> > >> Paavo
>
> > > Under Windows, you have to use const std::locale filelocale
> > > ("English_Australia.1252") according to
> > >http://docs.moodle.org/en/Table_of_locales, I've tested it in VC++08
> > > and it works. Any suggestion in how to handle the dualism?
>
> > Did you actually test the results? It seems this is reading UTF-8 in
> > unaltered, so there is no point to use a wide stream in the first place.
>
> > Paavo
>
> Well, yeah, although using an example file likehttp://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txtand using
> plain std::string, std::ifstream and std::cout everything works fine,
> if I put the 'w' in front of all this types the sysout fails
> producing:
>
> UTF-8 encoded sample plain-text file
> Γ
>
> Why??

Because C++ does not convert from UTF-8 to UTF-16 just like that.
UTF-8 fits into std::string. std::wstring is UTF-16 when sizeof
(wchar_t) is 2 and UTF-32 when sizeof(wchar_t) is 4. The support for
character portability is weak in STL, not sure why. Also POSIX
functions do not help much since most implementations were made before
Unicode was defined.

If you really want to convert then use platforms support. Most
platforms support Unicode (for example MultiByteToWideChar() in
Windows). If you want portable solution then use library that is
capable to provide conversions like ICU. http://site.icu-project.org/


== 3 of 4 ==
Date: Sun, Jan 31 2010 5:31 pm
From: "Leigh Johnston"


>
> The functions in <locale> are pretty useless, since they only
> handle single byte characters. The "approved" solution is to
> read into a wstring using wifstream (embedded with the
> appropriate locale), and use isspace (again with the appropriate
> locale) on the wchar_t in the wstring.
>
> --
> James Kanze

You might want to use a custom codecvt facet with that otherwise you are
just reading bytes and converting them to wchar_t which is not what you want
I don't think.

/Leigh

== 4 of 4 ==
Date: Sun, Jan 31 2010 6:29 pm
From: "Leigh Johnston"


"Leigh Johnston" <leigh@i42.co.uk> wrote in message
news:PdmdneKVNOF6s_vWnZ2dnUVZ7tydnZ2d@giganews.com...
>>
>> The functions in <locale> are pretty useless, since they only
>> handle single byte characters. The "approved" solution is to
>> read into a wstring using wifstream (embedded with the
>> appropriate locale), and use isspace (again with the appropriate
>> locale) on the wchar_t in the wstring.
>>
>> --
>> James Kanze
>
> You might want to use a custom codecvt facet with that otherwise you are
> just reading bytes and converting them to wchar_t which is not what you
> want I don't think.
>

Never mind, if the locale is correct it should do multibyte conversion
correctly.

==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

[jQuery] Browser / AJAX help

I have a "star" click to bookmark type feature. It works in FF, IE but not Opera or Chrome.
 
Filled star = page book marked
Empty star  = not bookmarked
 
In FF and IE first click changes the star from empty to filled, click filled star turns back to empty (info saved in db successfully).
 
In Opera and Chrome clicking the stars fills them and 2nd click will return it back to empty but it never saves to the db. If i bookmark 20 pages in FF, go to Chrome or Opera and un-select the bookmarked selections it saves (deletes the bookmark) but it never saves any new bookmarks.
 
My js looks like this:
 
$("a.bookmarked").live('click', function(){
   var url_id = $(this).attr('id').split('_');
   var status = $(this).attr('class');
   
   $(this).toggleClass("not");
 

     
   $.ajax({
     type: "POST",
     cache:false,
     url: '/bookmark/'+url_id[1],
     });
   return false;
   });
 
Any ideas?
 
Dave

Re: [jQuery] Re: Autocomplete plugin compatability with jQuery 1.4?

Yes, and yes.

On Sun, Jan 31, 2010 at 3:41 PM, Jose <jmalv04@gmail.com> wrote:
On Fri, Jan 29, 2010 at 1:38 AM, Richard D. Worth <rdworth@gmail.com> wrote:
> The latest version is jQuery UI Autocomplete, and it is compatible with
> jQuery 1.4. You can find it in jQuery UI 1.8rc1:
>
> http://blog.jqueryui.com/2010/01/jquery-ui-1-8rc1/

Is the UI autocomplete based on Jörn's autocomplete ? If seems a huge
refactoring!

regards

Re: [jQuery] Re: Autocomplete plugin compatability with jQuery 1.4?

On Fri, Jan 29, 2010 at 1:38 AM, Richard D. Worth <rdworth@gmail.com> wrote:
> The latest version is jQuery UI Autocomplete, and it is compatible with
> jQuery 1.4. You can find it in jQuery UI 1.8rc1:
>
> http://blog.jqueryui.com/2010/01/jquery-ui-1-8rc1/

Is the UI autocomplete based on Jörn's autocomplete ? If seems a huge
refactoring!

regards

[jQuery] How to add 'selected' to option of dynamically set Select input?

I've been using the following to display the statename in my dropdown:

$('#State option[value="' + LocationObject.State + '"]').attr('selected',
'selected');

LocationObject is a json object that I am using. The problem with this is
that it does not add 'selected' to the option tage of the dropdown so when
the user submits the form the value of the dropdown is incorrect. How can I
add 'selected' to the option. Seems easy but I've not foind a solution to
this in any posts.

btw: I've also tried these 2 without luck either:

$("#State").val(LocationObject.State).attr('selected', 'selected');
$("#State").val(LocationObject.State);

thanks!
--
View this message in context: http://old.nabble.com/How-to-add-%27selected%27-to-option-of-dynamically-set-Select-input--tp27394631s27240p27394631.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Re: [jQuery] jquery.form.js, Opera and file uploads.

I used to suffer from the problem in Opera  when using ajaxfileupload.js


error occur sometime  due to the following piece of code
 xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;

as
io.contentWindow.document.body is null ;


my solution is add a javasciprt settimeout funciton (about 200ms),
the timeout function runs until
io.contentWindow.document.body value is not null

I used to add a counter in the loop of the timeout function and alert the value of counter of at the end of the loop
the value is between 50k to 70k.


I think my situation is similar to yours and hope that it can shed some light on ur problem


2010/1/30 Marc Worrell <marc@worrell.nl>
Hi,

I was fixing a problem where file uploads with the jquery.form.js
didn't work.
I found the fix in the newer release where using a timer the dom is
checked 50 times to see if the upload finished.
After some investigation I suspect that the problem is not timing but
that Opera triggers the 'load' event on receiving the 100 continue
from the server.

This means that the solution is not retrying 50 times, but just
waiting for the second load event.

Any opinions?

- Marc

Re: [jQuery] (validate) Validation following server-side submit

You might consider using the "remote" option:

http://jquery.bassistance.de/validate/demo/captcha/

Or, have onSubmit submit the form asynchronously and redirect if the
submit is successful.

In both cases you'll want to re-validate the submittal but if it's not
successful, who cares if you handle someone being an ass in a graceful
manner? :)

Nathan

comp.lang.c++ - 25 new messages in 10 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* ===Welcome to comp.lang.c++! Read this first. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8359863cfafcc5aa?hl=en
* isspace - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en
* calling base class method from derive class object without virtual - 4
messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/44c777f6059b8071?hl=en
* Safe to use substr? - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/cece8bdad80abdbe?hl=en
* Avoiding pointers to member functions - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/91122aae5ea3693a?hl=en
* Discount Wholesale Armani Jeans Christian Audigier Jeans ED Hardy Jeans (www.
vipchinatrade.com) - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/62cb14b1f5535017?hl=en
* templates + RTTI + shared library = impossible? - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/7cdc437c782232bc?hl=en
* Another strange linux kernel change - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e05a4158a9750a03?hl=en
* Link error in using queue class - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/dff9655ccbceda85?hl=en
* Looking for C++ IDE,... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e8a1db0949215858?hl=en

==============================================================================
TOPIC: ===Welcome to comp.lang.c++! Read this first.
http://groups.google.com/group/comp.lang.c++/t/8359863cfafcc5aa?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 30 2010 9:30 pm
From: Shiva


Welcome to comp.lang.c++! Read this first.

This post is intended to give the new reader an introduction to reading
and posting in this newsgroup. We respectfully request that you read
all the way through this post, as it helps make for a more pleasant
and useful group for everyone.

First of all, please keep in mind that comp.lang.c++ is a group for discussion
of general issues of the C++ programming language, as defined by the ANSI/ISO
language standard. If you have a problem that is specific to a particular system
or compiler, you are much more likely to get complete and accurate answers in a
group that specializes in your platform. A listing of some newsgroups is given
at the end of this post.

The FAQ (Frequently Asked Question) list has a wealth of information for
both the new and veteran C++ programmer. No matter what your experience
level, you are encouraged to read the entire list, if only to familiarize
yourself with what answers are available to minimize redundant replies.
The comp.lang.c++ FAQ is available at http://www.parashift.com/c++-faq-lite/

If the FAQ list does not help, then many regular readers of this group
are happy to assist with problems of standard C++. We have only a few
requests that we ask be adhered to, for the benefit of all:

* Please put a short summary in the subject line. Descriptions such as
"HELP!!!!!!" are not helpful, and many regular posters ignore such
requests. A good example is, "Problem with Virtual Functions."

* State the question or the problem clearly and concisely. Describe what
you are trying to do, and the problem you are running into. Include all
relevant error messages.

* Include the smallest, complete and compilable program that exhibits your
problem. As a rule, posters in comp.lang.c++ will not do homework, but will
give helpful hints if you have shown some willingness to try a solution.

* comp.lang.c++ is forum for discussion, and as such some regular posters do
not give E-mail replies. Very often follow-ups to postings have corrections,
so plan on taking part in the discussion if you post a question. If you
do receive e-mail replies, it is considered polite to post a summary.

* Don't post in HTML format. Many readers of this newsgroup don't use
newsreaders which can handle HTML postings.

* If you have to include source code in your post, include the
source in the message body. Don't use attachments. A lot
of contributors to this newsgroup won't even notice the existence
of attachments or won't open them. You try to get any help
you can get, don't you?

Some netiquette topics which frequently crop up on comp.lang.c++ are
also answered in the FAQ.

* Should I post job advertisements and/or resumes on comp.lang.c++?
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.10

* What if I really need a job; should I post my resume on comp.lang.c++?
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.11

* What should I do to someone who posts something off-topic?
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.12

A note on comp.lang.c++ etiquette: Accuracy is valued very highly in this
newsgroup; therefore posts are frequently corrected, sometimes perhaps
too harshly, and often to the annoyance of new posters who consider the
correction trivial. Do not take it personally; the best way to fit in
with comp.lang.c++ is to express gratitude for the correction, move on,
and be more careful next time.

This is a very busy group, so these requests are designed to make it as
pleasant and efficient an experience as possible. We hope it proves
a valuable commodity to you.

A list of some Newsgroups :
Languages and Programming
-------------------------
comp.lang.c The C Programming Language
comp.lang.asm.x86 x86 assembly language programming
comp.programming Non-language specific programming
comp.graphics.algorithms Issues of computer graphics

Operating Systems
-----------------
comp.os.msdos.programmer DOS, BIOS, Memory Models, interrupts,
screen handling, hardware
comp.os.ms-windows.programmer.win32 MS/Windows: Mice, DLLs, hardware
comp.os.os2.programmer.misc OS/2 Programming
comp.sys.mac.programmer.misc Macintosh Programming
comp.unix.programmer General Unix: processes, pipes, POSIX,
curses, sockets
comp.unix.[vendor] Various Unix vendors

Microsoft VC++
-------------
microsoft.public.vc.language VC++ issues
microsoft.public.vc.mfc MFC Issues
microsoft.public.dotnet.languages.vc C++/CLR Issues
microsoft.public.dotnet.framework .Net Framework


Borland C++ Builder
-------------------
borland.public.cppbuilder.language Borland C++ Builder
borland.public.cpp.language
borland.public.cppbuilder

-Shiva
http://www.slack.net/~shiva/welcome.txt


Sun Jan 31 00:30:00 EST 2010


==============================================================================
TOPIC: isspace
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en
==============================================================================

== 1 of 5 ==
Date: Sun, Jan 31 2010 12:20 am
From: Paavo Helde


gervaz <gervaz@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
6dec26dab285@o28g2000yqh.googlegroups.com:

> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>>
>> > James Kanze <james.ka...@gmail.com> writes:
>> > >There are no standard names for locales
>> >   AFAIK, C90 defines a locale by the name of "C",
>> >   which should also be visible from C++.
>>
>> And Posix defines "POSIX".  Neither of which are really useful
>> for anything.
>>
>> --
>> James Kanze
>
> Ok, so I think that I will open my file specifying to use UTF-8
> encoding, but how can I do it in C++?

You can open it as a narrow stream and read in as binary UTF-8, or
(maybe) you can open it as a wide stream and get an automatic translation
from UTF-8 to wchar_t. The following example assumes that you have a file
test1.utf containing valid UTF-8 text. It reads the file in as a wide
stream and prints out the numeric values of all wchar_t characters.

#include <iostream>
#include <fstream>
#include <locale>
#include <string>

int main() {
std::wifstream is;
const std::locale filelocale("en_US.UTF8");
is.imbue(filelocale);
is.open("test1.utf8");

std::wstring s;
while(std::getline(is, s)) {
for (std::wstring::size_type j=0; j<s.length(); ++j) {
std::cout << s[j] << " ";
}
std::cout << "\n";
}
}

(Tested on Linux with a recent gcc, I am not too sure if this works on
Windows. First, wchar_t in MSVC is too narrow for real Unicode, at best
one might get UTF-16 as a result.)

hth
Paavo


== 2 of 5 ==
Date: Sun, Jan 31 2010 1:39 am
From: Paavo Helde


Paavo Helde <myfirstname@osa.pri.ee> wrote in
news:Xns9D116950C4paavo256@216.196.109.131:

> gervaz <gervaz@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
> 6dec26dab285@o28g2000yqh.googlegroups.com:
>
>> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
>>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>>>
>>> > James Kanze <james.ka...@gmail.com> writes:
>>> > >There are no standard names for locales
>>> >   AFAIK, C90 defines a locale by the name of "C",
>>> >   which should also be visible from C++.
>>>
>>> And Posix defines "POSIX".  Neither of which are really useful
>>> for anything.
>>>
>>> --
>>> James Kanze
>>
>> Ok, so I think that I will open my file specifying to use UTF-8
>> encoding, but how can I do it in C++?
>
> You can open it as a narrow stream and read in as binary UTF-8, or
> (maybe) you can open it as a wide stream and get an automatic
> translation from UTF-8 to wchar_t. The following example assumes that
> you have a file test1.utf containing valid UTF-8 text. It reads the
> file in as a wide stream and prints out the numeric values of all
> wchar_t characters.
>
> #include <iostream>
> #include <fstream>
> #include <locale>
> #include <string>
>
> int main() {
> std::wifstream is;
> const std::locale filelocale("en_US.UTF8");
> is.imbue(filelocale);
> is.open("test1.utf8");
>
> std::wstring s;
> while(std::getline(is, s)) {
> for (std::wstring::size_type j=0; j<s.length(); ++j) {
> std::cout << s[j] << " ";
> }
> std::cout << "\n";
> }
> }
>
> (Tested on Linux with a recent gcc, I am not too sure if this works on
> Windows. First, wchar_t in MSVC is too narrow for real Unicode, at
> best one might get UTF-16 as a result.)

For curiosity, I tested this also on Windows with MSVC9, and as expected
it did not work, the locale construction immediately threw an exception
(bad locale name). Neither did any alterations work ("english.UTF8",
".UTF8", ".utf-8", ".65001").

Thus, if one wants any portability it seems the best approach currently
is still to read in binary UTF-8 and perform any needed conversions by
hand.

Paavo


== 3 of 5 ==
Date: Sun, Jan 31 2010 3:30 am
From: gervaz


On Jan 31, 10:39 am, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> Paavo Helde <myfirstn...@osa.pri.ee> wrote innews:Xns9D116950C4paavo256@216.196.109.131:
>
>
>
> > gervaz <ger...@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
> > 6dec26dab...@o28g2000yqh.googlegroups.com:
>
> >> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
> >>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>
> >>> > James Kanze <james.ka...@gmail.com> writes:
> >>> > >There are no standard names for locales
> >>> >   AFAIK, C90 defines a locale by the name of "C",
> >>> >   which should also be visible from C++.
>
> >>> And Posix defines "POSIX".  Neither of which are really useful
> >>> for anything.
>
> >>> --
> >>> James Kanze
>
> >> Ok, so I think that I will open my file specifying to use UTF-8
> >> encoding, but how can I do it in C++?
>
> > You can open it as a narrow stream and read in as binary UTF-8, or
> > (maybe) you can open it as a wide stream and get an automatic
> > translation from UTF-8 to wchar_t. The following example assumes that
> > you have a file test1.utf containing valid UTF-8 text. It reads the
> > file in as a wide stream and prints out the numeric values of all
> > wchar_t characters.
>
> > #include <iostream>
> > #include <fstream>
> > #include <locale>
> > #include <string>
>
> > int main() {
> >     std::wifstream is;
> >     const std::locale filelocale("en_US.UTF8");
> >     is.imbue(filelocale);
> >     is.open("test1.utf8");
>
> >     std::wstring s;
> >     while(std::getline(is, s)) {
> >         for (std::wstring::size_type j=0; j<s.length(); ++j) {
> >             std::cout << s[j] << " ";
> >         }
> >         std::cout << "\n";
> >     }
> > }
>
> > (Tested on Linux with a recent gcc, I am not too sure if this works on
> > Windows. First, wchar_t in MSVC is too narrow for real Unicode, at
> > best one might get UTF-16 as a result.)
>
> For curiosity, I tested this also on Windows with MSVC9, and as expected
> it did not work, the locale construction immediately threw an exception
> (bad locale name). Neither did any alterations work ("english.UTF8",
> ".UTF8", ".utf-8", ".65001").
>
> Thus, if one wants any portability it seems the best approach currently
> is still to read in binary UTF-8 and perform any needed conversions by
> hand.
>
> Paavo

Under Windows, you have to use const std::locale filelocale
("English_Australia.1252") according to http://docs.moodle.org/en/Table_of_locales,
I've tested it in VC++08 and it works. Any suggestion in how to handle
the dualism?

Thanks, Mattia


== 4 of 5 ==
Date: Sun, Jan 31 2010 4:58 am
From: James Kanze


On Jan 31, 9:39 am, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> Paavo Helde <myfirstn...@osa.pri.ee> wrote
> innews:Xns9D116950C4paavo256@216.196.109.131:

[...]
> >> Ok, so I think that I will open my file specifying to use UTF-8
> >> encoding, but how can I do it in C++?

> > You can open it as a narrow stream and read in as binary
> > UTF-8, or (maybe) you can open it as a wide stream and get
> > an automatic translation from UTF-8 to wchar_t. The
> > following example assumes that you have a file test1.utf
> > containing valid UTF-8 text. It reads the file in as a wide
> > stream and prints out the numeric values of all wchar_t
> > characters.

> > #include <iostream>
> > #include <fstream>
> > #include <locale>
> > #include <string>

> > int main() {
> > std::wifstream is;
> > const std::locale filelocale("en_US.UTF8");

The above line supposes 1) that you're on a Unix platform
(because it uses the Unix conventions for naming locales), and
2) that the "en_US.UTF8" locale has been installed---under that
name. (I've worked on a lot of systems where this was not the
case.)

> > is.imbue(filelocale);
> > is.open("test1.utf8");

> > std::wstring s;
> > while(std::getline(is, s)) {
> > for (std::wstring::size_type j=0; j<s.length(); ++j) {
> > std::cout << s[j] << " ";
> > }
> > std::cout << "\n";
> > }
> > }

> > (Tested on Linux with a recent gcc, I am not too sure if
> > this works on Windows. First, wchar_t in MSVC is too narrow
> > for real Unicode, at best one might get UTF-16 as a result.)

UTF-16 is "real Unicode". Just like UTF-8.

> For curiosity, I tested this also on Windows with MSVC9, and
> as expected it did not work, the locale construction
> immediately threw an exception (bad locale name). Neither did
> any alterations work ("english.UTF8", ".UTF8", ".utf-8",
> ".65001").

That's because Windows uses different conventions for naming
locales. (Windows Vista and later clames that names conforming
to RFC 4646 are used, see
http://msdn.microsoft.com/en-us/library/dd373814%28VS.85%29.aspx.
Except that RFC 4646 doesn't seem to contain information
concerning the character encoding. I'm guessing that Windows
would use the code page for this---65001 for UTF-8. But I don't
know how it has to be added to the "en-US".)

> Thus, if one wants any portability it seems the best approach
> currently is still to read in binary UTF-8 and perform any
> needed conversions by hand.

It should be sufficient to find out how the different locales are
named for each system, and read this information in from some
sort of configuration file.

--
James Kanze


== 5 of 5 ==
Date: Sun, Jan 31 2010 5:17 am
From: Paavo Helde


gervaz <gervaz@gmail.com> wrote in
news:a5a4ece2-5b9d-4846-a818-9de61c130654@r24g2000yqd.googlegroups.com:

> On Jan 31, 10:39 am, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
>> Paavo Helde <myfirstn...@osa.pri.ee> wrote
>> innews:Xns9D116950C4paavo256@2
> 16.196.109.131:
>>
>>
>>
>> > gervaz <ger...@gmail.com> wrote in news:f9eec1c9-5570-461a-bdec-
>> > 6dec26dab...@o28g2000yqh.googlegroups.com:
>>
>> >> On Jan 30, 1:15 pm, James Kanze <james.ka...@gmail.com> wrote:
>> >>> On Jan 30, 12:05 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>>
>> >>> > James Kanze <james.ka...@gmail.com> writes:
>> >>> > >There are no standard names for locales
>> >>> >   AFAIK, C90 defines a locale by the name of "C",
>> >>> >   which should also be visible from C++.
>>
>> >>> And Posix defines "POSIX".  Neither of which are really useful
>> >>> for anything.
>>
>> >>> --
>> >>> James Kanze
>>
>> >> Ok, so I think that I will open my file specifying to use UTF-8
>> >> encoding, but how can I do it in C++?
>>
>> > You can open it as a narrow stream and read in as binary UTF-8, or
>> > (maybe) you can open it as a wide stream and get an automatic
>> > translation from UTF-8 to wchar_t. The following example assumes
>> > that you have a file test1.utf containing valid UTF-8 text. It
>> > reads the file in as a wide stream and prints out the numeric
>> > values of all wchar_t characters.
>>
>> > #include <iostream>
>> > #include <fstream>
>> > #include <locale>
>> > #include <string>
>>
>> > int main() {
>> >     std::wifstream is;
>> >     const std::locale filelocale("en_US.UTF8");
>> >     is.imbue(filelocale);
>> >     is.open("test1.utf8");
>>
>> >     std::wstring s;
>> >     while(std::getline(is, s)) {
>> >         for (std::wstring::size_type j=0; j<s.length(); ++j)
> {
>> >             std::cout << s[j] << " ";
>> >         }
>> >         std::cout << "\n";
>> >     }
>> > }
>>
>> > (Tested on Linux with a recent gcc, I am not too sure if this works
>> > on Windows. First, wchar_t in MSVC is too narrow for real Unicode,
>> > at best one might get UTF-16 as a result.)
>>
>> For curiosity, I tested this also on Windows with MSVC9, and as
>> expected it did not work, the locale construction immediately threw
>> an exception (bad locale name). Neither did any alterations work
>> ("english.UTF8", ".UTF8", ".utf-8", ".65001").
>>
>> Thus, if one wants any portability it seems the best approach
>> currently is still to read in binary UTF-8 and perform any needed
>> conversions by hand.
>>
>> Paavo
>
> Under Windows, you have to use const std::locale filelocale
> ("English_Australia.1252") according to
> http://docs.moodle.org/en/Table_of_locales, I've tested it in VC++08
> and it works. Any suggestion in how to handle the dualism?

Did you actually test the results? It seems this is reading UTF-8 in
unaltered, so there is no point to use a wide stream in the first place.

Paavo

==============================================================================
TOPIC: calling base class method from derive class object without virtual
http://groups.google.com/group/comp.lang.c++/t/44c777f6059b8071?hl=en
==============================================================================

== 1 of 4 ==
Date: Sun, Jan 31 2010 12:39 am
From: Tinku


Hi

#include<iostream>


class base
{
public:
int get();
int put();
};
class Derive: public base
{
public:
int get();
int put();
};

int base::get()
{
int x = 5;
return x;
}
int base::put()
{
int y = 10;
return y;
}
int Derive::get()

{
int a = 9;
return a;
}
int Derive::put()
{
int b = 20;
return b;
}

int main()
{
Derive d;
d.get(); // this line will return 9 according to class how can I
get 5 from here (base class method get();)

return 0;
}

How can I call base class method from derive class object without
using virtual.


== 2 of 4 ==
Date: Sun, Jan 31 2010 12:55 am
From: Robert Fendt


And thus spake Tinku <sumit15nov@gmail.com>
Sun, 31 Jan 2010 00:39:53 -0800 (PST):

> int main()
> {
> Derive d;
> d.get(); // this line will return 9 according to class how can I
> get 5 from here (base class method get();)
>
> return 0;
> }
>
> How can I call base class method from derive class object without
> using virtual.

Actually, virtual functions and polymorphy work precisely the other way round.

To answer your question, you can do two things: (1) specify the function by "d.Base::get()" (that _should_ work, though I hardly use that syntax); (2) get a pointer to 'd', cast that to a base pointer, and then call get() on it.

Regards,
Robert

== 3 of 4 ==
Date: Sun, Jan 31 2010 6:28 am
From: Saeed Amrollahi


On Jan 31, 11:39 am, Tinku <sumit15...@gmail.com> wrote:
> Hi
>
> #include<iostream>
>
> class base
> {
> public:
>         int get();
>         int put();};
>
> class Derive: public base
> {
> public:
>         int get();
>         int put();
>
> };
>
> int base::get()
> {
>         int x = 5;
>         return x;}
>
> int base::put()
> {
>         int y = 10;
>         return y;}
>
> int Derive::get()
>
> {
>         int a = 9;
> return a;}
>
> int Derive::put()
> {
>         int b = 20;
>         return b;
>
> }
>
> int main()
> {
>    Derive d;
>    d.get(); // this line will return 9 according to class how can I
> get 5 from here (base class method get();)
>
>    return 0;
>
> }
>
> How can I call base class method from derive class object without
> using virtual.

Actually, virtual functions are used to enable polymorphism and
calling
member functions of derived class object via base class objects
(pointers and references). If you want to call base class member
functions
through derived class object use something like this:

class Base {
public:
int get() { cout << "I am in base\n"; return 9; }
};

class Derived : public Base {
public:
int get() { return Base::get(); } // call base class members
};

int main()
{
Derived d;
d.get();
return 0;
}


== 4 of 4 ==
Date: Sun, Jan 31 2010 6:40 am
From: "Alf P. Steinbach"


* Tinku:
>
> int main()
> {
> Derive d;
> d.get(); // this line will return 9 according to class how can I
> get 5 from here (base class method get();)
>
> return 0;
> }
>
> How can I call base class method from derive class object

d.base::get();


> without using virtual.

I think you may have misunderstood 'virtual'; it sort of goes the other way.


Cheers & hth.,

- Alf

==============================================================================
TOPIC: Safe to use substr?
http://groups.google.com/group/comp.lang.c++/t/cece8bdad80abdbe?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Jan 31 2010 12:47 am
From: Robert Fendt


And thus spake Immortal Nephi <Immortal_Nephi@hotmail.com>
Sat, 30 Jan 2010 18:49:34 -0800 (PST):

> I want to know that size_type returns –1 (minus one) is safe before I
> extract one string into two substrings. First example is safe and
> second example is not sure.
>
> const basic_string <char>::size_type npos = -1;

Why don't you just use std::string (which is a typedef of std::basic_string<char>)? It is more readable. Secondly, consider using string::npos instead of redefining it yourself. IIRC, the exact definition of npos is implementation-defined, thus it is dangerous to assume too much about it. It _is_ in fact defined as (size_t)-1 on almost all systems, but strictly speaking that depends on implementation and processor architecture.

> begin_index returns 0 and end_index returns 5. substr is safe.

Let's just say, it does what you expected it to do.

> Second example:
>
> begin_index = data.find_first_not_of( " ", end_index );
> end_index = data.find_first_of( " ", begin_index );
> token2 = data.substr( begin_index, end_index - begin_index );
> length_index = token2.length();
>
> begin_index returns 6 and end_index returns –1. Is substr safe for
> token2 because end_index returns –1 indicates space character is not
> found.

Yes. The standard specifies that its parameters are of type string::size_type, thus (at least in case of basic_string<char> and basic_string<wchar_t>) they are definitely unsigned. So in fact you are passing a _very_ large number as second parameter. My standard library docs state that if the second parameter points beyond the string, the end of the string is assumed instead (in fact, the default value for the second parameter is string::npos).

> Another question—is size_type the same as size_t? They are always
> unsigned maximum integer. Can I always copy variable from size_type
> to signed integer or unsigned integer?

First question: yes, and no. size_type gets into string via traits class templates. If you are not familiar with that technique, I suggest you read up on it, since it is used extensively throughout the STL. The point being that you can adapt basic_string to just about any type of underlying data, thus it does not assume that every length is of type size_t but rather gets its definition via a traits template.

That said, it _is_ true that basic_string<char> and basic_string<wchar_t> (i.e., string and wstring) do use a definition of size_type that is identical to size_t.

Second question: no. You cannot assume that size_t is the same size as "int". It might, or it might not (in fact, e.g. on newer MSVC++ in 64bit mode, it is not!). Secondly, while it is safe to cast an unsigned value to signed and back (the resulting value being IIRC guaranteed to be identical to the original), the semantics of interpreting an unsigned value as signed if it is 'too large' are unspecified.

On most systems, casting a large unsigned number to signed yields a negative number, since that is how signed values are usually implemented. However, I don't think the standard actually specifies that casting numeric_limits<max>(unsigned) to int actually yields "-1".

Regards,
Robert

== 2 of 3 ==
Date: Sun, Jan 31 2010 4:24 am
From: James Kanze


On Jan 31, 2:49 am, Immortal Nephi <Immortal_Ne...@hotmail.com> wrote:
> I want to know that size_type returns -1 (minus one)

size_type never contains -1. It can't, since it is an unsigned
type. (Also, variables and types don't "return" anything. Only
functions return things.)

> is safe before I extract one string into two substrings.
> First example is safe and second example is not sure.

> const basic_string <char>::size_type npos = -1;

Which results in an implicit conversion, according to the rules
of conversion of signed to unsigned. Basically, npos will be
the largest possible value of size_type.

But why are you defining this? (And why are you using
basic_string< char > instead of the typedef std::string?) If,
for convenience, you want a local constant variable (to be able
to write npos, rather than std::string::npos), then:

std::string::size_type const npos = std::string::npos;

is the simplest solution.

> basic_string< char >::size_type begin_index, end_index, length_index;

Just a general rule (good practice, not a language requirement):
don't define variables until you can initialize them.

> end_index = 0;

> string data = "Hello World!!", token1, token2;

> First example:

> begin_index = data.find_first_not_of( " ", end_index );
> end_index = data.find_first_of( " ", begin_index );
> token1 = data.substr( begin_index, end_index - begin_index );
> length_index = token1.length();

> begin_index returns 0 and end_index returns 5. substr is safe.

> Second example:

> begin_index = data.find_first_not_of( " ", end_index );
> end_index = data.find_first_of( " ", begin_index );
> token2 = data.substr( begin_index, end_index - begin_index );
> length_index = token2.length();

> begin_index returns 6 and end_index returns -1.

Again, end_index doesn't return anything; data.substring returns
std::string::npos. Which is the largest possible value which
can be held in an std::string::size_type.

> Is substr safe for token2 because end_index returns -1
> indicates space character is not found.

What does the documentation for substr say? What is the meaning
of the second argument? (I don't have my copy of the standard
handy to quote exactly, but what it says is something along the
lines of "the second argument specifies the maximum length of
the returned string", and that the return value is something
like "std::string( s.begin() + position, s.begin() + position +
std::min(length, s.size() - position))".)

> Another question---is size_type the same as size_t?

For std::string and std::wstring, yes. If you instantiate
std::basic_string with a non-standard allocator, not
necessarily.

> They are always unsigned maximum integer.

No. size_t is an unsigned integer large enough that the size of
the largest possible object can be represented in it. I've used
machines where size_t was 16 bits, for example.

> Can I always copy variable from size_type to signed integer or
> unsigned integer?

There are several possible answers to that question. If you
mean copy without loss of value, the answer is no; a lot of
modern machines have a 64 bit size_type, but a 32 bit integer
type, and there's no way you can convert a 64 bit type into a 32
bit type without loss of value.

Formally, of course, you can convert to the unsigned
integer---the results of converting to the signed integer are
implementation defined, but on most implementations, the
conversion is well defined as well. But if the value doesn't
fit, you'll get some other value.

Finally, in practice, it's likely that practical constraints
mean that you won't have strings larger than what can be
represented in an int. In which case, there's no problem.

> const basic_string <char>::size_type npos = -1;

> signed int sNpos = npos;

The results here are implementation defined. It's very likely
that sNpos will end up -1, but it's not guaranteed by the
standard. (And if sNpos does end up -1, then the conversion
back to size_t is guaranteed, so comparison with a size_t will
work.)

> unsigned int uNpos = npos;

Perfectly legal, but uNpos will not compare equal to npos on
most 64 bit machines.

I'm not too clear as to what your goal is. First, for better or
for worse, std::string uses an unsigned size_t for all of its
indexing and positionning. Mixing signed and unsigned in C++
often gives surprising results, and should be avoided. (Using
unsigned for numeric values should generally be avoided as well,
but the rule about not mixing is more critical, and trumps this
rule---if an external library uses unsigned, you should stick
with whatever type it uses.)

Also, and this is really just a question of personal preference,
but I prefer by far using the algorithms in <algorithm> to the
special member functions in std::string. Once you're used to
the standard library, it just seems more comfortable working
with iterators than with indexes. And it avoids all of the
issues related to unsigned types in C++. Given that any time
you're going to be processing text, you're going to be using
functions like isalpha, isspace, etc. a lot, the first thing to
do is to defined predicate object types for each of the
functions and its complement. (Macros make this fairly easy.)
Then you use them with std::find_if. So your initial example
becomes:

typedef std::string::const_iterator text_iterator;
std::string const data( "Hello, world!" );
text_iterator begin_token = std::find_if(data.begin(), data.end(),
is_not_space());
text_iterator end_token = std::find_if(begin_token, data.end(),
is_space());
// or is_not_alnum(), or whatever...
std::string const first_token( begin_token, end_token );

(As I say, this is a personal preference, not any established
rule. But IMHO, it fits in better with the philosophy of the
standard library.)

--
James Kanze


== 3 of 3 ==
Date: Sun, Jan 31 2010 4:29 am
From: James Kanze


On Jan 31, 8:47 am, Robert Fendt <rob...@fendt.net> wrote:
> And thus spake Immortal Nephi <Immortal_Ne...@hotmail.com>
> Sat, 30 Jan 2010 18:49:34 -0800 (PST):

> > I want to know that size_type returns -1 (minus one) is safe
> > before I extract one string into two substrings. First
> > example is safe and second example is not sure.

> > const basic_string <char>::size_type npos = -1;

> Why don't you just use std::string (which is a typedef of
> std::basic_string<char>)? It is more readable. Secondly,
> consider using string::npos instead of redefining it yourself.
> IIRC, the exact definition of npos is implementation-defined,
> thus it is dangerous to assume too much about it. It _is_ in
> fact defined as (size_t)-1 on almost all systems, but strictly
> speaking that depends on implementation and processor
> architecture.

The standard requires it to be defined as
static_cast< size_type >( -1 )
The implemenation and process architecture dependencies are in
the definition of size_type (which must be size_t in the default
allocator). The actual numeric value will vary, but it is well
defined, and used correctly as a sentinal value, there should be
no portability problems.

--
James Kanze

==============================================================================
TOPIC: Avoiding pointers to member functions
http://groups.google.com/group/comp.lang.c++/t/91122aae5ea3693a?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Jan 31 2010 12:55 am
From: Marcel Müller


Hi!

Robert Fendt wrote:
> I am trying to find the best way to make part of a class's behaviour configurable during runtime, yet with as little overhead as possible. Maybe someone here has an idea? So far I have come up with 3 alternatives, all of which I do not really like for different reasons.

> (1) The 'simple' solution would be to implement various alternatives of the (private) member function in question, and use a "pointer to member function" to access it. Runtime configuration can be achieved by changing the pointer value, and a function pointer should be at least as efficient as a single vtable lookup. However, I loathe function pointer syntax, and they are clumsy to use (and they IMHO hide semantics by their convoluted syntax).

Function pointers are a solution if and only if the number of possible
cases is known at the design time of your class.
Nowadays there is no much performance impact compared to switch case. If
the number of cases is larger it can be considerably faster, unless the
behavior is switched many times, because you store the (partial) result
of a decision rather than taking the decision every time anew.

> (2) So, what about a functor class. It would have to be a member or friend of the outer class, and it cannot directly access the latters internals (even with 'friend' I would still have to give it a pointer to the current instance). I am also concerned about performance, since there is an additional level of indirection involved at several points when using this model.

Functors are something like user exits. They will not basically switch
functionality between a fixed number of cases. But they provide
extensibility to the user of a class instance. Of, course this is
restricted to the users permissions.

Functors have no explicit runtime overhead, since everything is done at
compile time unless you explicitly have run time code, e.g. in the
constructor. So you can control the overhead very well.
Because of this functors are often suitable in conjunction with templates.

> (3) Last but not least: strict OO design, make a base class and several differently behaving child classes, and use a factory pattern to achieve at least some level of runtime flexibility. This is less flexible, so I do not really like that possibility either. Also there is the risk of duplicate code.

Inheritance is a solution if and only if the behavior of existing
objects never changes over their lifetime. The performance is comparable
to the function pointers, because the vtable calls are similar to
function pointers.

But if your behavior is constant over object lifetime there is another
solution. As cr88192 already said you can combine 2 and 3. And if you
use a template base class which takes the functors as template arguments
you will end up with no runtime overhead.

However, the same will happen with an optimizing compiler, if you pass
an enumeration type as template argument to your class to switch the
behavior and use switch/case again. If you do not like the resulting
long type names, feel free to use typedefs and end up with the same type
names as with (3). Of course, the additional restriction of limited
cases applies here.


Marcel


== 2 of 3 ==
Date: Sun, Jan 31 2010 12:58 am
From: KjellKod


On Jan 30, 8:00 pm, Robert Fendt <rob...@fendt.net> wrote:
> Hi all,
>
> I am trying to find the best way to make part of a class's behaviour configurable during runtime, yet with as little overhead as possible. Maybe someone here has an idea? So far I have come up with 3 alternatives, all of which I do not really like for different reasons.
>
> (1) The 'simple' solution would be to implement various alternatives of the (private) member function in question, and use a "pointer to member function" to access it. Runtime configuration can be achieved by changing the pointer value, and a function pointer should be at least as efficient as a single vtable lookup. However, I loathe function pointer syntax, and they are clumsy to use (and they IMHO hide semantics by their convoluted syntax).
>
> (2) So, what about a functor class. It would have to be a member or friend of the outer class, and it cannot directly access the latters internals (even with 'friend' I would still have to give it a pointer to the current instance). I am also concerned about performance, since there is an additional level of indirection involved at several points when using this model.
>
> (3) Last but not least: strict OO design, make a base class and several differently behaving child classes, and use a factory pattern to achieve at least some level of runtime flexibility. This is less flexible, so I do not really like that possibility either. Also there is the risk of duplicate code.
>
> So, would someone please tell which obvious clear, flexible and efficient solution I am missing?
>
> Regards,
> Robert

Instead of functor class why not use the same functionality but
through recognized good software solutions? I'm thinking of the
different "signal and slots" implementations that are out there.
Boost, Qt (the original signal-and-slot), libsig++. Just google and
you'll find a few more.

Regards
Kjell


== 3 of 3 ==
Date: Sun, Jan 31 2010 4:35 am
From: James Kanze


On Jan 30, 7:00 pm, Robert Fendt <rob...@fendt.net> wrote:

> I am trying to find the best way to make part of a class's
> behaviour configurable during runtime, yet with as little
> overhead as possible. Maybe someone here has an idea? So far I
> have come up with 3 alternatives, all of which I do not really
> like for different reasons.

> (1) The 'simple' solution would be to implement various
> alternatives of the (private) member function in question, and
> use a "pointer to member function" to access it. Runtime
> configuration can be achieved by changing the pointer value,
> and a function pointer should be at least as efficient as a
> single vtable lookup. However, I loathe function pointer
> syntax, and they are clumsy to use (and they IMHO hide
> semantics by their convoluted syntax).

Also, they tend to be much less efficient than calling a virtual
function.

But the real arguments against them are those you raised, along
with the fact that you cannot associate data with them. (You
don't say what sort of configuration you're dealing with, but
it's easy to imagine configurations with parameters, e.g.
scaling or translations.)

> (2) So, what about a functor class. It would have to be a
> member or friend of the outer class, and it cannot directly
> access the latters internals (even with 'friend' I would still
> have to give it a pointer to the current instance). I am also
> concerned about performance, since there is an additional
> level of indirection involved at several points when using
> this model.

I doubt that the performance issues will be relevant. It's a
possible solution.

> (3) Last but not least: strict OO design, make a base class
> and several differently behaving child classes, and use a
> factory pattern to achieve at least some level of runtime
> flexibility. This is less flexible, so I do not really like
> that possibility either. Also there is the risk of duplicate
> code.

I'm not too sure where you see the code duplication; the derived
class can always call functions in the base class for common
funtionality.

What you describe is basically the template method pattern. It
has the drawback that you can't change the configuration once
the class has been instantiated.

> So, would someone please tell which obvious clear, flexible
> and efficient solution I am missing?

It sounds to me that you're looking for the strategy pattern,
but it's hard to say without more details.

--
James Kanze

==============================================================================
TOPIC: Discount Wholesale Armani Jeans Christian Audigier Jeans ED Hardy Jeans
(www.vipchinatrade.com)
http://groups.google.com/group/comp.lang.c++/t/62cb14b1f5535017?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Jan 31 2010 1:47 am
From: yoyo


@@@@Free shipping Cheap True Religion Jeans ARMANI jeans belts
Wholesale paypal payment <www.vipchinatrade.com>

Discount Wholesale Affliction Jeans <free shipping paypal payment>
Discount Wholesale AK Jeans ( www.vipchinatrade.com )
Discount Wholesale Armani Jeans
Discount Wholesale Artful Dodger Jeans <free shipping paypal payment>
Discount Wholesale BAPE Jeans
Discount Wholesale BBC Jeans ( www.vipchinatrade.com )
Discount Wholesale Black Label Jeans
Discount Wholesale Cavalli Jeans
Discount Wholesale Christian Audigier Jeans
Discount Wholesale Coogi Jeans
Discount Wholesale Crown Holder Jeans ( www.vipchinatrade.com )
Discount Wholesale D&G Jeans
Discount Wholesale Diesel Jeans
Discount Wholesale ECKO Jeans ( www.vipchinatrade.com )
Discount Wholesale ED Hardy Jeans
Discount Wholesale Evisu Jeans
Discount Wholesale G-STAR Jeans <free shipping paypal payment>
Discount Wholesale GUCCI Jeans
Discount Wholesale Iceberg Jeans
Discount Wholesale Kanji Jeans ( www.vipchinatrade.com )
Discount Wholesale Laguna Beach Jeans
Discount Wholesale Levi s Jeans
Discount Wholesale LRG Jeans <free shipping paypal payment>
Discount Wholesale LV Jeans
Discount Wholesale Prada Jeans ( www.vipchinatrade.com )
Discount Wholesale RMC Jeans
Discount Wholesale Roca Wear Jeans <free shipping paypal payment>
Discount Wholesale Rock&Republic Jeans
Discount Wholesale True Religion Jeans <free shipping paypal payment>
Discount Wholesale Versace Jeans
Discount Wholesale ZEN Jeans ( www.vipchinatrade.com )

Discount Wholesale Affliction Jeans <free shipping paypal payment>
Discount Wholesale AK Jeans ( www.vipchinatrade.com )
Discount Wholesale Armani Jeans
Discount Wholesale Artful Dodger Jeans <free shipping paypal payment>
Discount Wholesale BAPE Jeans
Discount Wholesale BBC Jeans ( www.vipchinatrade.com )
Discount Wholesale Black Label Jeans
Discount Wholesale Cavalli Jeans
Discount Wholesale Christian Audigier Jeans
Discount Wholesale Coogi Jeans
Discount Wholesale Crown Holder Jeans ( www.vipchinatrade.com )
Discount Wholesale D&G Jeans
Discount Wholesale Diesel Jeans
Discount Wholesale ECKO Jeans ( www.vipchinatrade.com )
Discount Wholesale ED Hardy Jeans
Discount Wholesale Evisu Jeans
Discount Wholesale G-STAR Jeans <free shipping paypal payment>
Discount Wholesale GUCCI Jeans
Discount Wholesale Iceberg Jeans
Discount Wholesale Kanji Jeans ( www.vipchinatrade.com )
Discount Wholesale Laguna Beach Jeans
Discount Wholesale Levi s Jeans
Discount Wholesale LRG Jeans <free shipping paypal payment>
Discount Wholesale LV Jeans
Discount Wholesale Prada Jeans ( www.vipchinatrade.com )
Discount Wholesale RMC Jeans
Discount Wholesale Roca Wear Jeans <free shipping paypal payment>
Discount Wholesale Rock&Republic Jeans
Discount Wholesale True Religion Jeans <free shipping paypal payment>
Discount Wholesale Versace Jeans
Discount Wholesale ZEN Jeans ( www.vipchinatrade.com )


== 2 of 3 ==
Date: Sun, Jan 31 2010 7:52 am
From: wendy


Cheap Wholesale Shox NZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox OZ <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox R2 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3+R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R5 <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TL <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Torch <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TZ <www.vipchinatrade.com> paypal payment

Cheap Wholesale Nike Air Max 87 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 89 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 97 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max LTD <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max TN <www.vipchinatrade.com> paypal
payment

Air Force one <www.vipchinatrade.com> paypal payment
Cheap Wholesale Air Force One Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One M&W <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Kid <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.vipchinatrade.com>
paypal payment


== 3 of 3 ==
Date: Sun, Jan 31 2010 8:03 am
From: wendy


Cheap Wholesale Shox NZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox OZ <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox R2 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R3+R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R4 <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox R5 <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TL <www.vipchinatrade.com> free shipping
Cheap Wholesale Shox Torch <www.vipchinatrade.com> paypal payment
Cheap Wholesale Shox TZ <www.vipchinatrade.com> paypal payment

Cheap Wholesale Nike Air Max 87 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 89 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.vipchinatrade.com> free shipping
Cheap Wholesale Nike Air Max 97 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max LTD <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.vipchinatrade.com> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Nike Air Max TN <www.vipchinatrade.com> paypal
payment

Air Force one <www.vipchinatrade.com> paypal payment
Cheap Wholesale Air Force One Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One M&W <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force One Kid <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.vipchinatrade.com> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.vipchinatrade.com>
paypal payment

==============================================================================
TOPIC: templates + RTTI + shared library = impossible?
http://groups.google.com/group/comp.lang.c++/t/7cdc437c782232bc?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Jan 31 2010 3:29 am
From: James Kanze


On Jan 30, 6:31 pm, legalize+jee...@mail.xmission.com (Richard) wrote:
> James Kanze <james.ka...@gmail.com> spake the secret code
> <bf3a79e7-9307-44eb-8b60-4897105cd...@c4g2000yqa.googlegroups.com> thusly:

> >On Jan 29, 12:27 am, "BGB / cr88192" <cr88...@hotmail.com> wrote:
> >> "Dan Caugherty" <dan.caughe...@gmail.com> wrote in message

> >> similar issues can also manifest in other ways as well:
> >> malloc/free not working between DLL's [...]

> >This is a purely Windows problem, present probably because
> >Windows doesn't bundle the CRT DLL's with the OS (I think). [...]

> The issue is that each module (DLL or EXE) has its own Win32
> heap. Memory allocated by a module will be allocated from
> that module's heap and must be freed by code in that module to
> be freed from the corect heap.

That's not really an issue for C++ programs, at least those that
are using new, and not the Windows API directly, to allocate
memory. C++ programs don't allocate memory from Windows, they
call the operator new function, which in turn calls malloc.
And malloc is in the CRT library. If the CRT library is in a
distinct DLL, all Windows allocations will be from that DLL, and
will use that DLL's heap. If you statically link a separate
instance of the CRT with each DLL, then each DLL will have a
separate instance of the operator new function and malloc, and
will use its own heap.

The arrangement of using separate system heaps for each DLL
seems like a very poor design decision to me (supposing you're
right---the Windows documentation says that "Each *process* has
a default heap*---, but it doesn't really matter here. Even
with one common system heap, each instance of malloc/free will
use a different set of static variables to manage this heap, and
memory returned by a call to HeapAlloc in one instance of malloc
will not be known in any other instance.

As I said, the motivation for statically linking the CRT is that
it isn't bundled with the OS. If you link with it dynamically,
you either have to require that all systems on which you run
have it installed, in addition to the standard system stuff, or
that you bundle it into your deployment package. (The Microsoft
site has extensive documentation about these issues. I'd
suggest that anyone deploying code written for Windows which
uses DLL's wade through it. I'd also suggest avoiding DLL's in
your own application, if possible, since they do make deployment
more complicated.)

--
James Kanze


== 2 of 2 ==
Date: Sun, Jan 31 2010 3:34 am
From: James Kanze


On Jan 30, 9:32 pm, "BGB / cr88192" <cr88...@hotmail.com> wrote:
> "Richard" <legalize+jee...@mail.xmission.com> wrote in message
> news:hk1tta$jrg$1@news.xmission.com...
> > James Kanze <james.ka...@gmail.com> spake the secret code
> > <bf3a79e7-9307-44eb-8b60-4897105cd...@c4g2000yqa.googlegroups.com> thusly:

> >>On Jan 29, 12:27 am, "BGB / cr88192" <cr88...@hotmail.com> wrote:
> >>> "Dan Caugherty" <dan.caughe...@gmail.com> wrote in message

> >>> similar issues can also manifest in other ways as well:
> >>> malloc/free not working between DLL's [...]

> >>This is a purely Windows problem, present probably because
> >>Windows doesn't bundle the CRT DLL's with the OS (I think). [...]

> > The issue is that each module (DLL or EXE) has its own Win32
> > heap. Memory allocated by a module will be allocated from
> > that module's heap and must be freed by code in that module
> > to be freed from the corect heap.

> yeah.

No.

> partial solution: don't pass memory ownership across DLL boundaries...

It's not a problem if you link your modules correctly.

> but, yeah, DLL's do have at least the major good point of
> avoiding lots of 10 or 20 MB EXE's (instead, one gets maybe
> 10-20 1 MB DLL's...), and a bunch of smaller EXE's...

So how is this a good point? You still end up with 10 or 20 MB
used on the disk, and you've made deployment significantly more
complicated, and introduced yet another way things can go wrong:
mixing versions of the DLL's. And of course, DLL's and
templates don't mix very well.

> another good point, is that one need only remember to link in
> those they need, and any others "come along for the ride",
> which improves on the static-lib case, of having to remember
> to link in every static lib referenced both directly and
> indirectly, which can itself become a non-trivial problem.

Sorry, I don't understand this one. Are you using static libs,
or dynamically linked objects? What you (generally) want to
avoid is using a static library for something that will be used
from several different DLL's---that's what causes problems.

> as well as simplifying dynamically-loadable components, ...

> ...

> so, in general, they are a good tradeoff for their costs
> (sometimes questionable linkage semantics, having to annotate
> declarations, having to worry about moving around a small army
> of DLL's and keeping them visible from the current directory,
> ...).

DLL's are an added complication. You use them when you need
them, but you should avoid them otherwise.

--
James Kanze

==============================================================================
TOPIC: Another strange linux kernel change
http://groups.google.com/group/comp.lang.c++/t/e05a4158a9750a03?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Jan 31 2010 4:04 am
From: "Man-wai Chang to The Door (24000bps)"


> Maybe you know more about the pre-conditions satisfied when this
> particular piece of code is run, but from reading just what you posted
> j is used on the very next line, so I would assume it matters whether
> it starts at i or i+1.

If that line was critical, it should have caused a kernel error in the
very beginning... :)

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7
^ ^ 20:04:01 up 1 day 4:10 1 user load average: 1.21 1.11 1.09
不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa

==============================================================================
TOPIC: Link error in using queue class
http://groups.google.com/group/comp.lang.c++/t/dff9655ccbceda85?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Jan 31 2010 4:47 am
From: Saeed Amrollahi


Dear all
Hi

I am working on a program and I use queue of wstring:
It compiles properly but at link error, I get the following Link
error:

DBBroker.obj : error LNK2005: "public: static int const
std::deque<class std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class
std::allocator<class std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> > >
>::_EEM_DS" (?_EEM_DS@?$deque@V?$basic_string@_WU?
$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?
$basic_string@_WU?$char_traits@_W@std@@V?
$allocator@_W@2@@std@@@2@@std@@$$Q2HB) already defined in
TSPipingNetworkMapSys.obj

I traced _EEM_DS in deque header file and it has the following
definition:
static const int _EEM_DS = _DEQUESIZ;
and _DEQUESIZ is a macro.
May be some implementation leakage was occurred .

FYI, DBBroker.cpp is one source file and TSPipingNetworkMapSys.cpp is
the main
cpp file which contains the main function. I use Visual Studio 2008.

Thanks in advance for your help
-- Saeed Amrollahi


== 2 of 2 ==
Date: Sun, Jan 31 2010 4:47 am
From: Saeed Amrollahi


Dear all
Hi

I am working on a program and I use queue of wstring:
It compiles properly but at link error, I get the following Link
error:

DBBroker.obj : error LNK2005: "public: static int const
std::deque<class std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class
std::allocator<class std::basic_string<wchar_t,struct
std::char_traits<wchar_t>,class std::allocator<wchar_t> > >
>::_EEM_DS" (?_EEM_DS@?$deque@V?$basic_string@_WU?
$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?
$basic_string@_WU?$char_traits@_W@std@@V?
$allocator@_W@2@@std@@@2@@std@@$$Q2HB) already defined in
TSPipingNetworkMapSys.obj

I traced _EEM_DS in deque header file and it has the following
definition:
static const int _EEM_DS = _DEQUESIZ;
and _DEQUESIZ is a macro.
May be some implementation leakage was occurred .

FYI, DBBroker.cpp is one source file and TSPipingNetworkMapSys.cpp is
the main
cpp file which contains the main function. I use Visual Studio 2008.

Thanks in advance for your help
-- Saeed Amrollahi

==============================================================================
TOPIC: Looking for C++ IDE,...
http://groups.google.com/group/comp.lang.c++/t/e8a1db0949215858?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Jan 31 2010 8:02 am
From: Branimir Maksimovic


Kerem Gümrükcü wrote:
> Hi,
>
> i am looking fo a (free, non-microsoft!) C++ IDE for windows, that
> can do most of the MSVC++ stuff (resources, projects, etc.)

I used code blocks, but vc express is better anyway, and pretty
good. For resource editing and things missing in free version of vc ide,
you can find free substitutes.
Besides that my main c++ ide is
http://joe-editor.sourceforge.net/index.html

Greets


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en