Friday, October 31, 2008

[jQuery] Re: New plugin: jquery.smoothDivScroll-0.5.js

Nice stuff there.  I have been playing around with it I would like to be able to click on the arrows and advance more rapidly through the scrollablearea.  Guess this might be going against what your trying to do.

Perhaps also some class should be added so that certain styling is applied where js is able to run

if some extra options could be specificed when initializing - in some cases it would be nice to be able display the items in sets of 4 (configurable rows  columns) perhaps also being able to initialze to a position (like scrollable plugin see flowplayer example site)

Would be interesting to be able to use this with lazyloading images (preloading two adhead)

2008/11/1 tkahn <tkahn@maaki.com>

Hi!

My name is Thomas Kahn and this is my first post to this list. I'm a
web developer working in Stockholm Sweden and I've just started
developing my my first plugin for jQuery; in fact jQuery is a totally
new experience for me - I started from scratch a week ago.  :-)

All the info, a demo and the current source code can be found here:

http://www.maaki.com/thomas/SmoothDivScrolling/

All the scrolling plugins that I found on the jQuery website where
scrolling in "element steps" and I wanted a plugin that would scroll
smoothly. Since I couldn't find one, I decided to code one myself.

Now I'm releasing somehing that is really a Beta with a big "B". It
wasn't intended to be released in public in the first place, but when
I saw that I would save time by developing a plugin for the project
that I'm currently involved in, I tought I'd share the code hoping
someone else will find it useful.

All improvements and suggestions are welcome!

/Thomas Kahn
Web Developer
Kärnhuset, Sweden

[jQuery] Re: remove() Method Causes Flicker in Firefox

Not sure why you would remove the photo... What happens when you hide
it.

On my G4 mac everything looks good except on the photo of "Little Dave
Thompson". It moves up and down as it comes in. No flicker but it
doesn't look right.

I think your problem is related to different dimension in your images.
When you display "Little Dave Thompson" you are removing an image with
different height dimensions. I'd recommend keep heights and widths the
same on all images. No need to remove images either. Just hide them,
check to see if they are there before you load them. (Easy to do in
JQuery)

The website looks great BTW. I have my own band (http://
RodeoClownsBand.com)

Regards,

-b


On Oct 31, 3:18 pm, Joe <joseph.is...@gmail.com> wrote:
> Go here:
>
> http://www.theshedbbq.com/dev/franchise/events
>
> Click on one of the rows in the table and you'll see the image fade
> out and then flicker.
>
> var livePhoto = $('img#eventImage');
> livePhoto.fadeOut('fast');
> livePhoto.remove();
>
> Not sure what is causing this but I use
> setTimeout( livePhoto.remove(), 50 but it did not work.
>
> Suggestions?

[jQuery] [ tooltip ]

Hi.
Not sure this is a bug, but having text inside diamond brackets, the
text wont show.

for example:

<img src='test.png' title="Hello - this image is called <test>." />

the tooltip will just show "Hello - this image is called "

[jQuery] how disable text box based on "select" setting

Hi

I am new to jQuery - appreciate some help.

I found some code that hides a textbox when a dropdown is set to a
specific value. That works fine.

$(document).ready(function(){
if($('select[name=costType] :selected').val() == 'fr'){
$('input[name=costValue]').disabled();
}
});

What I would like to do is not hide the textbox but disable it. I
would also like text box's contents cleared when it is being
disabled. If the user goes back and selects a different value in the
dropdown, the textbox to be enabled, with no value in it.

The dropdown name is costType and it has 3 possible values. Only one
of them is to trigger disabling the text box.

Thank you for your help
Steve

[jQuery] Re: Advanced jQuery Animation Problem

Thanks! I have been working really hard on creating a site that works like a
flash site, but everything is indexable, loads faster, and is easily
editable for anyone else who would need/want to work on the site. I work
with flash all the time where I have to go and fix something, and of course
no one can seem to find the original fla file.

This is my way sticking it to the man ;-)
Hopefully I can get this ONE thing fixed and I will be able to upload this.
I still need the sky to go through all parts of the day (early morning,
daytime, sunset, night.) and the clouds to repeat.


somid3 wrote:
>
>
> wow, I cant say much about your code, but your page looks awesome.
>
>
>
> On Oct 30, 8:13 pm, OscarGodson <Oscargod...@gmail.com> wrote:
>> This is a fairly advanced jQuery animation I am doing on a site I am
>> doing,
>> but I know it's failing at alert('2'); as you will see it in the
>> comments. I
>> have tried TONS of things and nothing is working, but it's only not
>> working
>> after a user pushes the back button. The entire thing totally tweaks out.
>> I
>> heavily commented it so you know what and why I am doing things.
>>
>> Here is a link to just this part of the sandbox for this. Right now, you
>> will see the splat logo and the info for oscargodson.com no matter what
>> you
>> choose, THIS IS NORMAL
>> . I was doing that for testing. I just want it so a user can choose an
>> image, go back, choose another, go back, etc.
>>
>> http://oscargodson.com/labs/boozker/sites.php
>>
>> P.S. I haven't even looked at this in IE7 yet :wistle:
>> So use Firefox or Safari to see what i see
>>
>> $('.site_thumbs').siblings('div').css({display:'none'});
>>         $('.site_thumbs img').mousedown(function(){
>>                 //Add a class to what was clicked so we can get it again.
>>                 $(this).addClass('clicked');
>>                 //We need the alt text to tell us which DIV to unhide
>> later.
>>                 var clicked_element = $(this).attr('alt');
>>                 //Get Positioning and Height Info so we can save things
>> the way they are
>>                 //when we set it position:absolute which has no height
>> associated with it
>>                 //nor will it stay in place, so get the info and hard
>> code it to the
>> element.
>>                 var position        = $('.clicked').position()
>>                 var positionLeft    = position.left;
>>                 var positionTop     = position.top;
>>                 var containerHeight = $('#content_container').height();
>>
>>                 //Now lets get that clicked element's siblings and
>> animate them out with
>> opacity
>>                 //alert('1');
>>                 $(this).siblings('img').fadeOut(400,function(){
>>                         //alert('2');
>>                         //!!!ERROR!!!
>>                         //Now that we faded out the sibling images let's
>> get rid of them
>>                         //$(this).css({position:'absolute'});
>>                         //Let's get the height we set above and hard code
>> it so it wont collapse
>> on us.
>>                        
>> $('#content_container').css({height:+containerHeight+'px'});
>>                         //OK, get x,y
>> coordinates(positionLeft,positionTop) and hard code them.
>>                         //After that animate to coordinates of the first
>> image (40px,15px)
>>
>> $('.clicked').css({position:'absolute',left:+positionLeft+'px',top:+positionTop+'px'}).animate({left:'40px',top:'15px'},300,'easeInOutBack',function(){
>>                                 //alert('3');
>>                                 //Fade out the thumbnail an get the
>> content ready.
>>                                 $(this).fadeOut(300,function(){
>>                                         //alert('4');
>>                                         //Get the new height of the
>> container with the content in it for later
>> use
>>                                         var bodyCopyHeight =
>> $('.site_'+clicked_element).height();
>>                                         //Change the height to fit the
>> new content plus add some padding on the
>> bottom
>>
>> $('#content_container').animate({height:(bodyCopyHeight+5)+'px'},700,'easeOutBounce');
>>                                         //Show the corresponding div that
>> is hidden
>>                                        
>> $('.site_'+clicked_element).fadeIn(400);
>>                                         //Create the goback function
>>                                         $('.goback').click(function(){
>>                                                 //alert('5');
>>                                                 //Since the .goback span
>> is inside the div you want to hide, we want
>> the span's parent div
>>                                                
>> $(this).parent('div').fadeOut(600,function(){
>>                                                         //After it fades
>> out animate the height change which makes the height
>> back to the
>>                                                         //way it was from
>> the start
>>
>> $('#content_container').animate({height:containerHeight+'px'},500,function(){
>>                                                                 //Make
>> the clicked element positioned back to static so it's back in
>> the same spot again
>>                                                                
>> $('.clicked').css({position:'static'});
>>                                                                 //After
>> the .clicked element is back in place fade in the thumbnails
>> again
>>                                                                
>> $('.site_thumbs img').fadeIn(1000,function(){
>>                                                                        
>> //After they appear take off the clicked class so now everything is
>> back to normal.
>>                                                                        
>> $('#content_container').removeClass('clicked');
>>                                                                 });
>>                                                         });
>>                                                 });
>>                                         });
>>                                 });
>>                         });
>>                 });
>>         });
>> --
>> View this message in
>> context:http://www.nabble.com/Advanced-jQuery-Animation-Problem-tp20259541s27...
>> Sent from the jQuery General Discussion mailing list archive at
>> Nabble.com.
>
>

--
View this message in context: http://www.nabble.com/Advanced-jQuery-Animation-Problem-tp20259541s27240p20269281.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

[jQuery] Re: ThickBox Bug - Back Button in IE

OscarGodson wrote:
>
>
>
> ripcurlksm wrote:
>>
>> I've had some users that accidentally hit back on their browsers when
>> trying to close the thickbox (instead of hitting the Close Button)... is
>> there a way to make it so the user can click back on their browser and
>> it'll close the thickbox, instead of the browser going back to the
>> previous page in the history?
>>
>> Or as an alternative, could I disable the back button while a thickbox is
>> open? This only happens in IE, FF closes out the thickbox, but IE is a
>> problem.
>>
>
> You can in no way disable the back button. This would be a security threat
> if programmers could directly access the browser.
>
> You can make it difficult to leave the current page, but if you want to
> add a function that when you press the back button in IE to call tb_Close
> (thickbox close function) it's not possible as far as I know and I also
> googled it and found nothing as well.
>
> Also, I don't think this is a "bug" isn't this more of usability issue?
> Your users are deciding to go back when its a pop up/module window? Maybe
> I am misunderstanding this entire thing. If a user presses back when a
> ThickBox window is open, no matter what browser, it will go back to the
> page before. ThickBox is simply putting a sem-transparent div and then a
> div over the top of that one on the current page.
>
>

Yes, its just that my boss in particular was having this issue and Ive
noticed that FF will close the modal window when "Back" is hit, but IE
actually goes back to the last page. Its definitely a usability issue,
nothing critical but defiantly an annoyance for traditional users who are
not familiar with it. I have seen others post questions about this same
issue, but no answers. Thanks for your time
--
View this message in context: http://www.nabble.com/ThickBox-Bug---Back-Button-in-IE-tp20254220s27240p20269135.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

[jQuery] Re: Determining what element is clicked

Check out the "Event Delegation" section of this excellent article

http://www.learningjquery.com/2008/03/working-with-events-part-1

On Oct 31, 12:07 pm, "c.barr" <chris.m.b...@gmail.com> wrote:
> I'm working on a project where we have a table and each row is
> clickable (but only certain columns within that row), but we cannot
> use an <a> tag for other reasons.  Currently I have to attach click
> events to the proper table cells, which works just fine, it's just
> inefficient.
>
> If I have a table with 50 rows, and 3 cells in each row need click
> events, that's 150 events attached! We're also doing ajax pagination,
> so each time we page over that's another 150 events to attach.
>
> So my question is, can I attach a single click event to the entire
> table, and then determine which element was clicked within that?

[jQuery] Determining what element is clicked

I'm working on a project where we have a table and each row is
clickable (but only certain columns within that row), but we cannot
use an <a> tag for other reasons. Currently I have to attach click
events to the proper table cells, which works just fine, it's just
inefficient.

If I have a table with 50 rows, and 3 cells in each row need click
events, that's 150 events attached! We're also doing ajax pagination,
so each time we page over that's another 150 events to attach.

So my question is, can I attach a single click event to the entire
table, and then determine which element was clicked within that?

[jQuery] Re: Block UI bugs in IE/Safari when used in .ready()

Hmmm... what if it takes longer than 200 milliseconds (i know the
common answer would be "wait longer then")....

i dunno, the whole framework/flow of that guys code just seems
unreliable/unstable

On Oct 31, 11:41 am, Mike Alsup <mal...@gmail.com> wrote:
> > Wouldn't a better version of the code be
>
> > $.blockUI();
> > searchLocDep( .... );
> > searchLocArr(  .... );
> > searchLocInt(  ... );
> > setTimeout(function() {
> >     $.unblockUI();
>
> > }, 200);
>
> > That way all the "search" stuff gets run asap?
>
> No.  You need to give the browser a chance to render the DOM updates
> before hitting it with intensive stuff.

[jQuery] Re: Newbie - is there a better way to do this?

> Then my javascript is like this:
>
> function load_progressives() {
>         $(".progressive").each(function(n) {
>                 var wrapset = $(".progressive").slice(n)
>                 wrapset.load(wrapset.attr('href'))
>         });
>
> }

This should work:

function load_progressives() {
$(".progressive").each(function() {
$(this).load(this.href);
});
}

[jQuery] Re: Block UI bugs in IE/Safari when used in .ready()

> Wouldn't a better version of the code be
>
> $.blockUI();
> searchLocDep( .... );
> searchLocArr(  .... );
> searchLocInt(  ... );
> setTimeout(function() {
>     $.unblockUI();
>
> }, 200);
>
> That way all the "search" stuff gets run asap?

No. You need to give the browser a chance to render the DOM updates
before hitting it with intensive stuff.

25 new messages in 14 topics - digest

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

comp.lang.c++@googlegroups.com

Today's topics:

* WORD TO PDF CONVERTER ! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aa74516e119018a7?hl=en
* opening jpeg file in c++ - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/ee4a622091cbf4cb?hl=en
* Electronics - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/14baa777c3867ffa?hl=en
* dynamic array and constructors - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/24c7ef3e322053f1?hl=en
* allocate memory of derived class - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/87fc908ed9682594?hl=en
* Hardware keys - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/562ab6b30cb4fecc?hl=en
* C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression" - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
* const correctness - should C++ prefer const member over non-const? - 2
messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/35cc955f55ea7387?hl=en
* vector<const T(*)> vs. vector<T(*)> - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
* solving circular dependencies with class only delcared in .h - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/652550d4b8a6f0f8?hl=en
* a really simple C++ abstraction around pthread_t... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/44190e3b9ac81a69?hl=en
* dynamically allocate array variable type LPWSTR - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/e158b09860db9247?hl=en
* Insert static array of struct in a vector - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/67f0d0e0bb28dd7a?hl=en
* Singleton and static function - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/dab3d2ac69472a4b?hl=en

==============================================================================
TOPIC: WORD TO PDF CONVERTER !
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aa74516e119018a7?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 5:01 am
From: Kimo1021


Dear all,

that program converts from word to pdf very easy and free


DOWNLOAD HERE FOR FREE

http://www.ziddu.com/download/2418735/Savefromwiordaspdfformat.rar.html


==============================================================================
TOPIC: opening jpeg file in c++
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/ee4a622091cbf4cb?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Oct 31 2008 5:02 am
From: Lionel B


On Fri, 31 Oct 2008 04:20:45 -0700, mohi wrote:

> hello everyone ,
>
> i am trying to read a jpeg image through c++ but is unable to do so ,
> presently i tried it with code in c as i use something like ;
>
> FILE * fp=fopen("./x.jpg","wb");
> int c;
> do{
> read(fp,&c,sizeof(c));

error: invalid conversion from 'FILE*' to 'int'

Note that read (which is not portable, by the way) takes a file
*descriptor*, not a FILE pointer.

[...]

> or what is the best way to read a binary file such as an image ??

A more C++-like style might be something like:

#include <fstream>
#include <iostream>

std::ifstream fs("./x.jpg", std::ios::in|std::ios::binary);
if (!fs) {
// failed to open file - do something about it
}

char c;
while (fs >> c) { // evaluates to false if read fails (e.g. past EOF)
// do something with c
}

fs.close();

--
Lionel B

== 2 of 4 ==
Date: Fri, Oct 31 2008 7:58 am
From: mohi


On Oct 31, 5:02 pm, Lionel B <m...@privacy.net> wrote:
> On Fri, 31 Oct 2008 04:20:45 -0700, mohi wrote:
> > hello everyone ,
>
> > i am trying to read a jpeg image through c++  but is unable to do so ,
> > presently i tried it with code in c as i use something like ;
>
> > FILE * fp=fopen("./x.jpg","wb");
> > int c;
> > do{
> > read(fp,&c,sizeof(c));
>
> error: invalid conversion from 'FILE*' to 'int'
>
> Note that read (which is not portable, by the way) takes a file
> *descriptor*, not a FILE pointer.
>
> [...]
>
> > or what is the best way to read a binary file such as an image ??
>
> A more C++-like style might be something like:
>
> #include <fstream>
> #include <iostream>
>
> std::ifstream fs("./x.jpg", std::ios::in|std::ios::binary);
> if (!fs) {
>   // failed to open file - do something about it--
>
> }
>
> char c;
> while (fs >> c) { // evaluates to false if read fails (e.g. past EOF)
>   // do something with c
>
> }
>
> fs.close();
>
> --
> Lionel B

i am really sorry people - i the real code would be like --


FILE * fp=fopen("./x.jpg","rb");
int c;
do{
fread(fp,&c,sizeof(c));
if( c==(int) 0xFF23){
do.....
do....

}

printf("%x",c);
}

while(c!=EOF);

== 3 of 4 ==
Date: Fri, Oct 31 2008 8:04 am
From: mohi


hello everyone ,

i am trying to read a jpeg image through c++ but is unable to do so ,
presently i tried it with code in c as i use something like ;

FILE * fp=fopen("./x.jpg","rb");
int c;
do{
fread(fp,&c,sizeof(c));
if( c==(int) 0xFF23){
do.....
do....

}

printf("%x",c);

}

while(c!=EOF);

but the problem is the if condition never evalutes to true as i know
that according to the jpeg standard there should be market with value
0xFFD8 and others also .....and also the printf() of integer 'c' as
hex is never displayed it just displays a blank ..

what could be wrong ??

or what is the best way to read a binary file such as an image ??

thanks a lot
mohan gupta

== 4 of 4 ==
Date: Fri, Oct 31 2008 8:14 am
From: Juha Nieminen


Lionel B wrote:
> char c;
> while (fs >> c) { // evaluates to false if read fails (e.g. past EOF)

Since he wants to read raw binary input into an int, he can do exactly
that also with C++ streams:

fs.read((char*)&theInt, sizeof(int));

He can check if the reading succeeded with fs.fail().


==============================================================================
TOPIC: Electronics
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/14baa777c3867ffa?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 5:04 am
From: swapu


Electronics is the field of manipulating electrical currents and
voltages using passive and active components that are connected
together to create circuits. Electronic circuits range from a simple
load resistor that converts a current to a voltage, to computer
central-processing units (CPUs) that can contain more than a million
transistors. The following indices and documents provide a basic
reference for understanding electronic components, circuits, and
applications.

http://electronicstopics.blogspot.com/2008/10/welcome-to-world-of-electronics.html


==============================================================================
TOPIC: dynamic array and constructors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/24c7ef3e322053f1?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 5:05 am
From: James Kanze


On Oct 31, 9:42 am, Urs Thuermann <u...@janus.isnogud.escape.de>
wrote:
> I have some old code I've written several years ago that
> doesn't compile with newer versions of GCC. The code
> allocates an array of objects that need to be initialized by
> calling a constructor with one argument:

> class B;

> class A {
> B *b;

> public:
> A(B *p) : b(p) {}
> };

> class B {
> public:
> void foo() {
> // this declaration is ok
> A a(this);

> // the following causes an error with newer GCC:
> // error: ISO C++ forbids initialization in array new
> A *arr = new A[10](this);
> }
> };

> int main()
> {
> B b;
> }

> This worked with g++ until version 3.3.x, but not since 3.4.x.
> The problem is in the expression new A[10](this), since
> according to GCC, initialization in array new is forbidden.

It's always been forbidden.

> How would I initialize the array elements in ISO C++?

std::vector< A > v( 10, this ) ;

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

== 2 of 2 ==
Date: Fri, Oct 31 2008 8:01 am
From: Juha Nieminen


James Kanze wrote:
>> How would I initialize the array elements in ISO C++?
>
> std::vector< A > v( 10, this ) ;

That is, of course, the best and safest way of doing it.

OTOH, it might be interesting to know how std::vector does this.
(After all, std::vector *does* allocate space for a certain amount of
elements without needing a default constructor for those elements.) It
goes something like this:

// Requires #include <memory>
A* array = std::allocator<A>().allocate(10);
for(int i = 0; i < 10; ++i)
new(array+i) A(this);

Of course I'm not recommending you to do it like this. Use std::vector
instead.


==============================================================================
TOPIC: allocate memory of derived class
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/87fc908ed9682594?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Oct 31 2008 5:22 am
From: James Kanze


On Oct 30, 9:07 pm, Salt_Peter <pj_h...@yahoo.com> wrote:
> On Oct 30, 1:23 pm, Steven Powers <StevenAPow...@gmail.com> wrote:
> > Imagine the following setup

> > class Parent
> > {
> > virtual void doStuff();
> > } ;

> > class Child : public Parent
> > {
> > virtual void doStuff();
> > } ;

> > and this function

> > bool foo(Parent *p)
> > {
> > if(!p)
> > p = new Parent();
> > p->doStuff();
> > }

> > I would like foo() to take a pointer and if it is null
> > allocate the memory for the class I pass in.

> > For example

> > Child * c = NULL;
> > foo(c);

> > would result in a Child() constructor and Child::doStuff()
> > being called. The way it is now Parent() and
> > Parent::doStuff() will get called.

> > How can this be done while keeping foo defined as foo(Parent
> > *p) ????

> > I've thought of using templates like this:
> > template<class T>
> > bool foo(Parent* p)
> > {
> > if(!p) p = new T();
> > p->doStuff();
> > }

> > but I am unable to get the correct type from a second
> > templated class that has been passed T = Child* as its
> > template type.

> > As a follow up can I get a template value T = Child* and
> > somehow pass foo T=Child ???

> Pay attention, you will learn something today.

> You said you don't want to change the function's signature

Which is, in some ways, a contradiction in terms. He wants the
function to depend on the type passed in, without passing in the
type. The obvious solution for the function to depend on the
type is to pass in the type, e.g.:

template< typename T >
bool foo( T* p ) ...

Of course, this doesn't solve the general problem: what to do if
he wants to call the function with "foo( NULL )".

> so this would work dandy except for a few problems, i'll try
> and point out those to you below:

> template<class T>
> void foo(Parent* p)
> {
> if(!p) p = new T();
> p->doStuff();
> }

> and you call it like so:

> foo< Child >(pc);
> or
> foo< Parent >(pc);

> Now, the important parts. In this language its bad news to
> distribute allocation and deallocation,

Which is simply false. The rule is almost the opposite: if you
don't distribute allocation and deallocation, you shouldn't be
using dynamic allocation to begin with. The most important
single reason for using dynamic allocation is because you need
explicit deallocation, elsewhere in the program.

His case is fairly special (so special that I've never seen it
in 20 years of C++). (But I suspect that he's not described his
problem in enough detail.)

> the above code is the perfect example why that rule is so
> important. When you pass pointers like so:

> Child* pc = 0;
> foo< Child >(pc);

> the pointer pc never gets modified in main, only its copy in
> foo does, so once foo returns you've got a memory leak.

> And to compound the issue, foo's Parent* p is no more and we
> can no longer release your allocated Child. So if you were to:

> if(!pc)
> delete pc;

> you are in fact deleting nothing. Hence:

> template<class T>
> void foo(Parent* p)
> {
> if(!p) p = new T();
> p->doStuff();
> delete p; // required
> }

Which will wreck havoc if he calls the function with a pointer
allocated elsewhere (or pointing to a local object). What he
needs is some sort of manager class:

template< typename T >
class PtrManager
{
public:
PtrManager( Parent* p )
: myPtr( p == NULL ? new T : p )
, myIsOwned( p == NULL )
{
}

~PtrManager()
{
if ( myIsOwned ) {
delete p ;
}
}

Parent* operator->() const
{
return myPtr ;
}

private:
Parent* myPtr ;
bool myIsOwned ;
} ;

This will also save him if p->doStuff() throws.

> Which then brings up another issue. virtual destructors.
> Whenever you store derived allocations using a pointer to
> base, you must declare you base d~tor virtual or you'll end up
> only deallocating a portion of your objects.

No, you'll end up with undefined behavior, which is worse. It
may work, it may seem to work, but leak memory, it may crash
immediately, it may corrupt the free space arena, causing a
crash in some totally unrelated code, or it may do just about
anything else.

> class Parent
> {
> public:
> virtual ~Parent()
> {
> std::cout << "~Parent()\n";
> }
> virtual void doStuff()
> {
> std::cout << "Parent::doStuff()\n";
> }
> };

> test it, try the d~tor without 'virtual' and delete Parent* p
> = new Child.

> To solve the original problem [...]

We have to know what the original problem really was:-). (I
wonder, for example, if he didn't think that his allocation
actually did modify the original pointer.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

== 2 of 3 ==
Date: Fri, Oct 31 2008 5:25 am
From: James Kanze


On Oct 31, 10:51 am, Maxim Yegorushkin <maxim.yegorush...@gmail.com>
wrote:
> On Oct 30, 11:43 pm, Pete Becker <p...@versatilecoding.com> wrote:

> > On 2008-10-30 18:00:18 -0400, Salt_Peter <pj_h...@yahoo.com> said:

> > >> template<class T>

> > > should really be:
> > > template< typename T >

> > I guess I'll have to go through the C++ standard and change
> > every template declaration to use "typename" instead of
> > "class".

> > This is a style thing. Some people prefer "typename" for
> > unfathomable reasons, and right-thinking programmers use
> > "class".

> I agree with you. "class" is preferable for pragmatic reasons:
> easier to type,

Funny, I don't find either easier to type than the other.

> occupies less real estate in the source files

Which means?

> and means the very same thing in this context.

To the compiler. To the human reader, perhaps not.

I use typename here, because it says what I mean. Literally,
both to the human reader and to the compiler.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

== 3 of 3 ==
Date: Fri, Oct 31 2008 6:58 am
From: Hendrik Schober


James Kanze wrote:
> On Oct 31, 10:51 am, Maxim Yegorushkin <maxim.yegorush...@gmail.com> wrote:
>> On Oct 30, 11:43 pm, Pete Becker <p...@versatilecoding.com> wrote:
>>> On 2008-10-30 18:00:18 -0400, Salt_Peter <pj_h...@yahoo.com> said:
>
>>>>> template<class T>
>
>>>> should really be:
>>>> template< typename T >
>
> [...]
>>> This is a style thing. Some people prefer "typename" for
>>> unfathomable reasons, and right-thinking programmers use
>>> "class".
>
>> I agree with you. "class" is preferable for pragmatic reasons:
>> easier to type,
>
> [...]
>
> I use typename here, because it says what I mean. Literally,
> both to the human reader and to the compiler.

And then there's the camp that uses 'class' when a template
requires a class and 'typename' otherwise.

Schobi
(yes, I'm a member of that one)


==============================================================================
TOPIC: Hardware keys
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/562ab6b30cb4fecc?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Oct 31 2008 5:32 am
From: Rune Allnor


Hi all.

I consider to let a client have a test version of some of
my software. If the software turns out to do what it is
supposed to do, I would like to protect it from being
distributed, e.g. by using hardware keys. The software
in question is written in C++.

1) How does one use hardware keys to protect programs?
That is, what voodoo is involved from the programming POV.
2) Where can I find vendors of hardware keys?

Thanks in advance,

Rune

== 2 of 3 ==
Date: Fri, Oct 31 2008 6:05 am
From: Michael DOUBEZ


Rune Allnor a écrit :
> I consider to let a client have a test version of some of
> my software. If the software turns out to do what it is
> supposed to do, I would like to protect it from being
> distributed, e.g. by using hardware keys. The software
> in question is written in C++.
>
> 1) How does one use hardware keys to protect programs?
> That is, what voodoo is involved from the programming POV.

A hardware key and a dev kit to exploit it.

> 2) Where can I find vendors of hardware keys?

Google it. I think Microcosm has also Internet key solutions.
This question is best suited for a professional network (LinkedIn ?)

--
Michael

== 3 of 3 ==
Date: Fri, Oct 31 2008 8:04 am
From: "osmium"


"Rune Allnor" wrote:

> I consider to let a client have a test version of some of
> my software. If the software turns out to do what it is
> supposed to do, I would like to protect it from being
> distributed, e.g. by using hardware keys. The software
> in question is written in C++.
>
> 1) How does one use hardware keys to protect programs?
> That is, what voodoo is involved from the programming POV.
> 2) Where can I find vendors of hardware keys?

Mybe you want the word "dongle".



==============================================================================
TOPIC: C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression"
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 6:40 am
From: Keith Thompson


Hendrik Schober <spamtrap@gmx.de> writes:
> Keith Thompson wrote:
>> Hendrik Schober <spamtrap@gmx.de> writes:
>>> Keith Thompson wrote:
[...]
>>>> Then programmers will inevitably write
>>>> case 'A' ... 'Z':
>>>> which is non-portable (under EBCDIC it matches '\' and '}').
>>> And why exactly would that be worse than an 'if'-'else' chain
>>> relying on ASCII?
>> It wouldn't. [...]
>
> Then I don't see how your above argument is valid.

Since you snipped my argument, I have no idea why you disagree with
it.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

== 2 of 2 ==
Date: Fri, Oct 31 2008 6:53 am
From: Hendrik Schober


Keith Thompson wrote:
> Hendrik Schober <spamtrap@gmx.de> writes:
>> Keith Thompson wrote:
>>> Hendrik Schober <spamtrap@gmx.de> writes:
>>>> Keith Thompson wrote:
> [...]
>>>>> Then programmers will inevitably write
>>>>> case 'A' ... 'Z':
>>>>> which is non-portable (under EBCDIC it matches '\' and '}').
>>>> And why exactly would that be worse than an 'if'-'else' chain
>>>> relying on ASCII?
>>> It wouldn't. [...]
>> Then I don't see how your above argument is valid.
>
> Since you snipped my argument, I have no idea why you disagree with
> it.

Funny. My newsreader still shows it.

Schobi


==============================================================================
TOPIC: const correctness - should C++ prefer const member over non-const?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/35cc955f55ea7387?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 6:55 am
From: Hendrik Schober


SG wrote:
> On 30 Okt., 10:59, fungus <openglMYSO...@artlum.com> wrote:
>> Bummer. I've got an object which triggers quite
>> a big internal rebuild when you call the non-const
>> version and I just noticed it's doing a lot of
>> rebuilding because of this assumption.
>
> You can explicitly convert your object to a const version if you don't
> want the non-const member function to be called in some cases:
>
> const foo& myConstFoo = myFoo;
> int blah = myConstFoo[42];
>
> or something like that. static_cast<foo const&>(myFoo)[42] should also
> work as far as I can tell. Though, these kinds of casts are still a
> bit of a mystery to me.

While I do remember this feeling, this case is rather simple:
You modify 'const', so a 'const_cast' would be what you should
use.

> Cheers,
> SG

Schobi

== 2 of 2 ==
Date: Fri, Oct 31 2008 6:56 am
From: Hendrik Schober


anon wrote:
> fungus wrote:
>> I define this class:
>>
>>
>> class foo {
>> std::vector<int>data;
>> public:
>>
>> int operator[](int n) {
>> return data[n];
>
> Changing this line to this:
> return data.at(n);
> is much safer

I'd be annoyed if I had to use such a 'foo'.
If I want the safe (and slower) variant, I'd want a
'foo::at()' to cal.

> [...]

Schobi


==============================================================================
TOPIC: vector<const T(*)> vs. vector<T(*)>
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 6:56 am
From: eiji.anonremail@googlemail.com


Thank you all.

I guess my initial post was somewhat missleading.
I only wanted to say that, when you want to have a vector of const
objects, you have to use pointers!

The "assignable & copyable" rule is the point.
"const T" would be copyable, but not assignable.

I thought it should be possible to allow the creation of a vector of
"const T" because at creation there is no need for an assignment. Or
am I missing something?

== 2 of 2 ==
Date: Fri, Oct 31 2008 7:42 am
From: Juha Nieminen


xdotx wrote:
> That seems dangerous. To remove an element would imply destruction,
> which is non-const.

Incorrect.

void deleteFoo(const Foo* const foo)
{
delete foo; // Compiles and works just fine.
}

> You can still get const-only access to elements
> via const_iterator or const&, or std::set essentially functions like
> this.

Even if you *can* get const access with the current system, that
doesn't mean it wouldn't be nice if there was a way to *ensure* that the
values of the elements are never modified by accident.


==============================================================================
TOPIC: solving circular dependencies with class only delcared in .h
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/652550d4b8a6f0f8?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 7:36 am
From: Juha Nieminen


Marcel Müller wrote:
> If you have a cyclic dependancy of the /declaration/ of your classes
> e.g. because of the use of certain smart pointers like intrusive_ptr,
> then you have a serious problem. If only the implementaions depend on
> each other you have no problem.

Actually if you have a circular reference with reference-counting
smart pointers, you do have a problem already.


==============================================================================
TOPIC: a really simple C++ abstraction around pthread_t...
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/44190e3b9ac81a69?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 7:40 am
From: "Adem"


"Chris M. Thomasson" wrote
> "Chris M. Thomasson" wrote
>
> >I use the following technique in all of my C++ projects; here is the
> >example code with error checking omitted for brevity:
>
> [...]
>
> > Any suggestions on how I can improve this construct?
>
> One addition I forgot to add would be creating an explict `guard' helper
> object within the `active' helper object so that one can create objects and
> intervene between its ctor and when it actually gets ran... Here is full
> example code showing this moment:
> _________________________________________________________________
> /* Simple Thread Object
> ______________________________________________________________*/
> #include <pthread.h>
>
>
> extern "C" void* thread_entry(void*);
>
> class thread_base {
> pthread_t m_tid;
> friend void* thread_entry(void*);
> virtual void on_active() = 0;
>
> public:
> virtual ~thread_base() = 0;
>
> void active_run() {
> pthread_create(&m_tid, NULL, thread_entry, this);
> }
>
> void active_join() {
> pthread_join(m_tid, NULL);
> }
> };
>
> thread_base::~thread_base() {}
>
> void* thread_entry(void* state) {
> reinterpret_cast<thread_base*>(state)->on_active();
> return 0;
> }
>
>
> template<typename T>
> struct active : public T {
> struct guard {
> T& m_object;
>
> guard(T& object) : m_object(object) {
> m_object.active_run();
> }
>
> ~guard() {
> m_object.active_join();
> }
> };
>
> active() : T() {
> this->active_run();
> }
<snip>

Hmm. is it ok to stay within the ctor for the whole
duration of the lifetime of the object?
IMO the ctor should be used only for initializing the object,
but not for executing or calling the "main loop" of the object
because the object is fully created only after the ctor has finished,
isn't it?


==============================================================================
TOPIC: dynamically allocate array variable type LPWSTR
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/e158b09860db9247?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 8:03 am
From: "Samant.Trupti@gmail.com"


HI,

I want to dynamically allocate array variable of type LPWSTR.
Code looks like this...

main() {
LPWSTR *wstr;
int count = Foo (wstr);
for (int i = 0; i < count; i++)
//print each element;
}

int Foo(LPWSTR *wstr)
{
int count = 0;
while (!done){
//Here I need to allocate "wstr" one element by one element. How
to do that?
// I don't know the count
count ++;
}

Where should I do delete?

Thanks
Trupti


==============================================================================
TOPIC: Insert static array of struct in a vector
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/67f0d0e0bb28dd7a?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 8:05 am
From: Juha Nieminen


Maxim Yegorushkin wrote:
> There is also vector::insert() which accepts iterators. It is
> perfectly fine to append to an empty vector as well:
>
> viewList.insert(
> viewList.end()
> , g_ViewInfo
> , g_ViewInfo + _countof(g_ViewInfo)
> );

It's easier to use the assign() member function rather than insert().
assign() works in the same way as the constructor taking an iterator
range, and thus it's simpler to use.

(Also assign() might be more efficient if there already were some
elements in the data structure. Ok, maybe not with std::vector, but I
know in most implementation of std::list an assign() call will be more
efficient than clear()+insert(), if there were already some elements in
the list.)


==============================================================================
TOPIC: Singleton and static function
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/dab3d2ac69472a4b?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 8:27 am
From: John Doe


Hi,

I have a singleton class defined like this :

class UIManager : public CSingleton<UIManager>,
public CObject
{
protected:
DECLARE_DYNAMIC(UIManager)
friend class CSingleton<UIManager>;

UIManager();
virtual ~UIManager();

public:
...
};

and I was using this code like this :

A)
UIManager* l_pUiMgr = UIManager::GetInstance();
ASSERT (l_pUiMgr != NULL);
l_pUiMgr->GetResText( a_ResId, bStripHtml);


But I was fed up with always typing this so I have declared below my
UIManager class a static function :

static inline UIManager& UIManager() { return *(UIManager::GetInstance()); }


and I wanted to be able to call it like that :

UIManager().GetResText( a_ResId, bStripHtml);

The problem is I get some compilations errors with the code in A)

5>c:\wce_v42\inc\BaseView.h(227) : error C2065: 'l_pUiMgr' : undeclared
identifier

Why I cannot write UIManager* now ?

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

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] Re: mcdropdown mouseout problems



On Thu, Oct 30, 2008 at 2:10 PM, Ken Gregg <ken.gregg@rwre.com> wrote:

No joy. I removed the anchors and fixed a problem with a duplicate id
and still experience the same problem.

I've never seen that behavior again. I've been in meetings for the past couple of days, but I'll try to look into the issue more indepth in the next few days.

-Dan

[jQuery] Newbie - is there a better way to do this?

I hope someone can help a newbie out here...

I've put some jQuery together to load part of my pages after my page
is ready. It works fine, but I'm wondering if there is a better way.

In my HTML I've got something like:

<div class='progressive' href='my uri path to load something'></div>

Then my javascript is like this:

function load_progressives() {
$(".progressive").each(function(n) {
var wrapset = $(".progressive").slice(n)
wrapset.load(wrapset.attr('href'))
});
}

$(function() {
load_progressives();
});

I would have thought I could do this as a one-liner, but this is the
best a newbie can figure out.

[jQuery] Re: Script like this site: http://ringvemedia.com/

That's an awesome way to do a slideshow..... it would be slick to wrap
that up in a jQuery plugin (like the cool numeric stepper)


*Blech* to pollution in China..... it really is that bad, i got to
experience Beijing and Shanghai first hand back in May..... but i
digress :-)


On Oct 31, 10:02 am, "Andy Matthews" <li...@commadelimited.com> wrote:
> I don't think you need Javascript for that. If you put an image as a
> background, then tell it to scale to 100%, you should be good.
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com] On
>
> Behalf Of Gabriel Tadeu
> Sent: Thursday, October 30, 2008 5:06 PM
> To: jQuery (English)
> Subject: [jQuery] Script like this site:http://ringvemedia.com/
>
> I visited this site and really like the image resizing...
>
> the original pic is big, resizing with bigger resolutions (like 1440x900).
>
> BUT the actual script is in moo tools, how create the same effect using
> jQuery?
>
> thanks!

[jQuery] Re: Script like this site: http://ringvemedia.com/

I don't think you need Javascript for that. If you put an image as a
background, then tell it to scale to 100%, you should be good.

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com] On
Behalf Of Gabriel Tadeu
Sent: Thursday, October 30, 2008 5:06 PM
To: jQuery (English)
Subject: [jQuery] Script like this site: http://ringvemedia.com/


I visited this site and really like the image resizing...

the original pic is big, resizing with bigger resolutions (like 1440x900).

BUT the actual script is in moo tools, how create the same effect using
jQuery?

thanks!

[jQuery] Re: Block UI bugs in IE/Safari when used in .ready()

Wouldn't a better version of the code be

$.blockUI();
searchLocDep( .... );
searchLocArr( .... );
searchLocInt( ... );
setTimeout(function() {
$.unblockUI();
}, 200);

That way all the "search" stuff gets run asap?


On Oct 30, 7:13 pm, Mike Alsup <mal...@gmail.com> wrote:
> > What was wrong actually ? Why my version with setTimeout didn't work ?
> > Seems pretty basic, block UI, execute some isntructions, unblock.
>
> The point of using setTImeout is the give the browser a chance to
> render the new DOM updates before diving into process-intensive work.
> So you block first, then set a timeout to give the browse a chance to
> catch its breath, then hit it with your other functions.
>
> Mike

[jQuery] ui.slider with dynamic minimum range

I am trying to implement a slider that can have one or two handles
determined dynamically. If there are two handles they have to have a
minimum range and if one handle gets close to the other handle, the
other handle should move away in order to keep the minimum range. I
found the following problems:

1. When I use $('#sliderId').data('slider').options.range = true/
false to dynamically set/unset the range if there are two or one
handle respectively, the range = true does get set in the options, but
ui.range = undefined. Also, the transparent fade doesn't get
dynamically added in between the handles. I don't really care about
this problem as much as I can calculate the range using $
('#sliderId').slider('value', $('#otherHandleId')) - $
('#sliderId').slider('value', $('#oneHandleId')) but it would be nice
to have the fade added/removed from in between the handles dynamically
without me having to .show()/.hide() it.

2. I use the above method to compute the range between to handles (if
there are two) and if the range is less than the minimum range, I use $
('#sliderId').slider('moveTo', ui.value +/- minimum Range, $
('#otherHandleId'), true) to move the other slider farther away from
the current slider. The problems is, the moveTo triggers the
otherHandld to become the ui.handle even though the mouse events do
not target the otherHandle. This cause the two handles to just bounce
back and forth as one handle tries to move the other handle away, then
the other handle tries to move the one handle away and so on.

So, is there a way to use moveTo without firing the start, slide,
change callbacks, which seems to be the case? Shouldn't the ui.handle
be tied to the mousedown/mousmove event, and not switch when moveTo is
called?

Any assistance would be greatly appreciated.

[jQuery] jQuery object with variable id name. Is is possible?

Hi,
is it possible to passed the jQuery object a variable with the the js
functions for example?
I'm having problems with jQuery. I have an img that on click it runs
this function however nothing gets hidden or shown.

I have the following in my page header


Code:
function hide_Show(RegionID)
var $jQuery = jQuery.noConflict();
//Icon that is clicked
var objectClickedID = '#' + RegionID + '_img';
//Region to hide
var objectID = '#' + RegionID;
$jQuery(document).ready(function(){
$jQuery(objectClickedID).click(function() {
if ($x(objectID).style.display =='none') {
$jQuery(objectID).show('slow');
}
else{
$jQuery(objectID).hide('slow');
}
});
}
and my img is as following


Code:
<img id="show_hide_img" onClick ="hide_Show('show_hide'):" alt="Click
here to expand/collapse this section" style="cursor: pointer;"
src"plus.gif" />and my region that I want to hide is
Code:
<div id="show_hide">Hide this</div>I know you might say that I could
just hard code the div ID though I have a lot of divs and they img's
need to hide specifc divs.


Thanks for your support.

[jQuery] Re: jquery ui tabs - screen jumps to top when clicked

Well, you copied that stuff into the wrong place producing a syntax
error, thus the tabs don't work at all. Just append what I posted to
the end of the ui.tabs.js file or paste it into a separate file and
include it after the ui.tabs.js.

You should use Firebug - or at least the error console - to get
informed of such JavaScript errors.

--Klaus


On 31 Okt., 10:11, Nicky <69hay...@gmail.com> wrote:
> Thanks Klaus!
>
> It didn't fix the problem for me, my example still jumps to the top:http://www.sandstream.se/tabs_test3.html
>
> As you say one solution might be to make the tabs the same hight by
> putting content of the same size in them.
>
> If you find another solution please let me know.
>
> //Sandstream

[jQuery] Re: jQuery Uploader Flash player 10 fix

p.s. at this time, IE seems a bit buggy, have to fix that before i
release any code.
I am also using some PNG files right now, which i have to change into
transparent gifs (IE).

On Oct 31, 2:08 pm, "Gilles (Webunity)" <gilles0...@gmail.com> wrote:
> Expect something in the next couple of days. I want to have the api
> docs setup good this time.
>
> On Oct 30, 1:41 pm, "Olivier Percebois-Garve" <perceb...@gmail.com>
> wrote:
>
>
>
> > Hi
>
> > any chance to see the work in progress ? demo, (even partially buggy) ? svn
> > ?
>
> > Olivier
>
> > On Tue, Oct 28, 2008 at 10:25 AM, Crazy-Achmet
> > <planetli...@googlemail.com>wrote:
>
> > > I'm really lookin forward to the new version!!!
>
> > > It's awesome that you're still workin' on it! ;)- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

[jQuery] simple rollover on a tag show or hide div tag in jQuery

I am creating a profile update page using jQuery. The content of the
profile is loaded dynamically into a div tag on the page.

$(document).ready(function() {

// Your code goes here
$("div#notifications").load("supportscripts/writeoutprofile.asp");

});

So this loads the profile into the nofifications div tag. This will
load a series of div tags which look similar to this:

<div class="profileLine"><div class="profileTitle"><a href="#"
id="a_ep1">Name</a><div class="editProfile" id="ep1">Edit Profile</
div></div><div class="profileText">Graham&nbsp;Cole</div></div>

All the <A> tags are dynamically named a_ep1 through a_ep6 and all the
<DIV> tags are dynamically named ep1 through ep6. So I would like to
have this set up so that when I rollover the <A> tag the <DIV> tag
shows and when I rollout it hides. I had this running using several
lines of code and an event handler on each <A> tag but apparently it
is much easier in jQuery. For some reason though the code I am using
does not appear to work:

$("#a_ep1").hover(
function () {
$("#ep1").show();
},
function () {
$("#ep1").hide();
return false;
}
);

does anybody have any suggestions on what I might be missing. My
initial thoughts are because the <A> and <DIV> tags do not exist in
the source code but are loaded dynamically that jQuery cannot find
them, but I am only guessing.

Any help greatly appreciated?
Graham

[jQuery] Re: jQuery Uploader Flash player 10 fix

Expect something in the next couple of days. I want to have the api
docs setup good this time.

On Oct 30, 1:41 pm, "Olivier Percebois-Garve" <perceb...@gmail.com>
wrote:
> Hi
>
> any chance to see the work in progress ? demo, (even partially buggy) ? svn
> ?
>
> Olivier
>
> On Tue, Oct 28, 2008 at 10:25 AM, Crazy-Achmet
> <planetli...@googlemail.com>wrote:
>
>
>
>
>
> > I'm really lookin forward to the new version!!!
>
> > It's awesome that you're still workin' on it! ;)- Hide quoted text -
>
> - Show quoted text -

[jQuery] Re: Advanced jQuery Animation Problem

hi,

it seems like it doesn't remove the 'clicked' class.
if i remove the class manually it works again.

what about:
$('#content_container img').removeClass('clicked');

or:
$('.site_thumbs').children('img').removeClass('clicked');
or:
$('.clicked').removeClass('clicked');

don't know. something like that.

-weidc

On 31 Okt., 07:13, Omid S <som...@gmail.com> wrote:
> wow, I cant say much about your code, but your page looks awesome.
>
> On Oct 30, 8:13 pm, OscarGodson <Oscargod...@gmail.com> wrote:
>
> > This is a fairly advanced jQuery animation I am doing on a site I am doing,
> > but I know it's failing at alert('2'); as you will see it in the comments. I
> > have tried TONS of things and nothing is working, but it's only not working
> > after a user pushes the back button. The entire thing totally tweaks out. I
> > heavily commented it so you know what and why I am doing things.
>
> > Here is a link to just this part of the sandbox for this. Right now, you
> > will see the splat logo and the info for oscargodson.com no matter what you
> > choose, THIS IS NORMAL
> > . I was doing that for testing. I just want it so a user can choose an
> > image, go back, choose another, go back, etc.
>
> >http://oscargodson.com/labs/boozker/sites.php
>
> > P.S. I haven't even looked at this in IE7 yet :wistle:
> > So use Firefox or Safari to see what i see
>
> > $('.site_thumbs').siblings('div').css({display:'none'});
> >         $('.site_thumbs img').mousedown(function(){
> >                 //Add a class to what was clicked so we can get it again.
> >                 $(this).addClass('clicked');
> >                 //We need the alt text to tell us which DIV to unhide later.
> >                 var clicked_element = $(this).attr('alt');
> >                 //Get Positioning and Height Info so we can save things the way they are
> >                 //when we set it position:absolute which has no height associated with it
> >                 //nor will it stay in place, so get the info and hard code it to the
> > element.
> >                 var position        = $('.clicked').position()
> >                 var positionLeft    = position.left;
> >                 var positionTop     = position.top;
> >                 var containerHeight = $('#content_container').height();
>
> >                 //Now lets get that clicked element's siblings and animate them out with
> > opacity
> >                 //alert('1');
> >                 $(this).siblings('img').fadeOut(400,function(){
> >                         //alert('2');
> >                         //!!!ERROR!!!
> >                         //Now that we faded out the sibling images let's get rid of them
> >                         //$(this).css({position:'absolute'});
> >                         //Let's get the height we set above and hard code it so it wont collapse
> > on us.
> >                         $('#content_container').css({height:+containerHeight+'px'});
> >                         //OK, get x,y coordinates(positionLeft,positionTop) and hard code them.
> >                         //After that animate to coordinates of the first image (40px,15px)
>
> > $('.clicked').css({position:'absolute',left:+positionLeft+'px',top:+positionTop+'px'}).animate({left:'40px',top:'15px'},300,'easeInOutBack',function(){
> >                                 //alert('3');
> >                                 //Fade out the thumbnail an get the content ready.
> >                                 $(this).fadeOut(300,function(){
> >                                         //alert('4');
> >                                         //Get the new height of the container with the content in it for later
> > use
> >                                         var bodyCopyHeight = $('.site_'+clicked_element).height();
> >                                         //Change the height to fit the new content plus add some padding on the
> > bottom
>
> > $('#content_container').animate({height:(bodyCopyHeight+5)+'px'},700,'easeOutBounce');
> >                                         //Show the corresponding div that is hidden
> >                                         $('.site_'+clicked_element).fadeIn(400);
> >                                         //Create the goback function
> >                                         $('.goback').click(function(){
> >                                                 //alert('5');
> >                                                 //Since the .goback span is inside the div you want to hide, we want
> > the span's parent div
> >                                                 $(this).parent('div').fadeOut(600,function(){
> >                                                         //After it fades out animate the height change which makes the height
> > back to the
> >                                                         //way it was from the start
>
> > $('#content_container').animate({height:containerHeight+'px'},500,function(){
> >                                                                 //Make the clicked element positioned back to static so it's back in
> > the same spot again
> >                                                                 $('.clicked').css({position:'static'});
> >                                                                 //After the .clicked element is back in place fade in the thumbnails
> > again
> >                                                                 $('.site_thumbs img').fadeIn(1000,function(){
> >                                                                         //After they appear take off the clicked class so now everything is
> > back to normal.
> >                                                                         $('#content_container').removeClass('clicked');
> >                                                                 });
> >                                                         });
> >                                                 });
> >                                         });
> >                                 });
> >                         });
> >                 });
> >         });
> > --
> > View this message in context:http://www.nabble.com/Advanced-jQuery-Animation-Problem-tp20259541s27...
> > Sent from the jQuery General Discussion mailing list archive at Nabble.com.

[jQuery] Re: Is it impossible to popup a PDF print dialog?

I'm not sure what your question has *anything at all* to do with
jQuery, but anyways

It's definitely possible, as the US Post Office's website does this
exact functionality when you create shipping labels online


On Oct 31, 2:30 am, Girish Venkatachalam
<girishvenkatacha...@gmail.com> wrote:
> Dear all,
>
> I know this is not directly related to jQuery but I wish to accomplish
> this task.
>
> My googling suggests that window.print() only prints the currently
> displayed html page.
>
> I wish to print the PDF that is linked to.
>
> How do I do that? I think opening an iframe can do it.
>
> If possible how to do with jQuery code?
>
> Thanks and have a nice day!
>
> -Girish

[jQuery] Re: Best site for catching fast with jQuery

Also to add

Karl Swedberg's site, which is aptly named:

http://www.learningjquery.com/

There's filters for your level of expertise and lots of sample code


On Oct 31, 5:18 am, shah <sjn0...@gmail.com> wrote:
> Hi! all i'm new bee to this magic(jQuery), can anybody tell from which
> site to study?
> which must have lots of examples in it.
> Thanks in advance
> shahjahan

[jQuery] Re: Best site for catching fast with jQuery

This site is a good start

http://15daysofjquery.com/quicker/4/

See the right hand pane with the "15 days" links (the above link is
day 1)

On Oct 31, 5:18 am, shah <sjn0...@gmail.com> wrote:
> Hi! all i'm new bee to this magic(jQuery), can anybody tell from which
> site to study?
> which must have lots of examples in it.
> Thanks in advance
> shahjahan

26 new messages in 16 topics - digest

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

comp.lang.c++@googlegroups.com

Today's topics:

* cast/assignement operators - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/00280114b34902eb?hl=en
* Strooustrup - Hello World exercise - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/082118a58f35476a?hl=en
* C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression" - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
* dynamic array and constructors - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/24c7ef3e322053f1?hl=en
* solving circular dependencies with class only delcared in .h - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/652550d4b8a6f0f8?hl=en
* looking for elegant C++ abstraction around pthread_key_t... - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/92098dc36b54f96a?hl=en
* How to write a binder3 tempalte function? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/216f4e8937bbbf4a?hl=en
* allocate memory of derived class - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/87fc908ed9682594?hl=en
* Variable Block Text File - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c53528aeee514123?hl=en
* Insert static array of struct in a vector - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/67f0d0e0bb28dd7a?hl=en
* Question about creating a struct of flags in c++ - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aded373b78039bdf?hl=en
* List erase iterator outside range - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/25a39eff0031f895?hl=en
* vector<const T(*)> vs. vector<T(*)> - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
* opening jpeg file in c++ - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/ee4a622091cbf4cb?hl=en
* Is c++ only better c ? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/38527e42967dc124?hl=en
* WORD TO PDF CONVERTER ! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aa74516e119018a7?hl=en

==============================================================================
TOPIC: cast/assignement operators
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/00280114b34902eb?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Oct 30 2008 11:48 pm
From: Paavo Helde


John Doe <mosfet@anonymous.org> kirjutas:

> .rhavin grobert wrote:
>> On 30 Okt., 12:06, Sam <s...@email-scan.com> wrote:
>>> Having said all this, after going through something similar myself,
>>> converting a bunch of code that used MS's gawdawful CString,
>>
>> just curious: what's wrong with CString?
> Have you ever tried to write code on multiplatform ?
> Windows, Windows CE, Symbian, iPhone, ...

Been there, done that. Most cumbersome was to wrap CTime and CFile.
Concerning CString, however, I second Sam in that it should just be
replaced by std::string and all compile errors fixed. The missing methods
(what they might be? OemToAnsi()? Right()?) should be just replaced by free
functions.

> I think you have you answer.
> and the raw std::string is really limited compared to CString that's why
> I am using CStdString.

Nah, from my viewpoint it is CString what is rather limited ;-) It even
does not have find_first_not_of()!

Paavo


==============================================================================
TOPIC: Strooustrup - Hello World exercise
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/082118a58f35476a?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Oct 31 2008 1:52 am
From: Juan Antonio Zaratiegui Vallecillo


Eberhard Schefold wrote:
> Juan Antonio Zaratiegui Vallecillo wrote:
>
>> * What does std::cout mean or represent?
>> * What does << mean or represent?
>> * Whta does std::endl mean or represent?
>>
>> Once you have answered those questions, you will know the answer to
>> your problem.
>
> I'm not sure whether you've really noticed the "Do not change main() in
> any way" part.

Oh sorry, you are right. I thought I had seen the usual homework question

== 2 of 4 ==
Date: Thurs, Oct 30 2008 1:38 pm
From: arnuld


> On Fri, 31 Oct 2008 09:52:36 +0100, Juan Antonio Zaratiegui Vallecillo

> Oh sorry, you are right. I thought I had seen the usual homework question


I don't get homework . I am no longer a kid ;)


--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups a.k.a "Spammer's Paradise" is Blocked.

== 3 of 4 ==
Date: Thurs, Oct 30 2008 1:41 pm
From: arnuld


> On Thu, 30 Oct 2008 11:51:24 -0500, A. Bolmarcich wrote:

> In your opening post to this thread you mentioned "Section 10.6,
> Exercise 15". Because chapter 10 is about Classes you need to know
> how to write classes to be able to do the exercises for that chapter.

Actually, I wanted to start my abandoned learning of C++ and my
friend's Stroustrup was lying in front of me on my office desk. My
experience has taught me I can not learn programming my following a book
from cover to cover. So I opened the book at some random place and tried
to solve the exercise that came in front of me.


> Informataion needed to do the exercise is in the subsection on
> Construction and Destruction.

How about this:


#include <iostream>


class Useless
{
public:
Useless() { std::cout << "Initialize" << std::endl; }
~Useless() { std::cout << "Clean up" << std::endl; }
};


Useless obj_of_useless;


int main()
{
std::cout << "Hello World!" << std::endl;

return 0;
}

=========================== OUTPUT ====================================
[arnuld@dune cpp]$ g++ -ansi -pedantic -Wall -Wextra 10-6_15.cpp
[arnuld@dune cpp]$ ./a.out
Initialize
Hello World!
Clean up
[arnuld@dune cpp]$

--
www.lispmachine.wordpress.com
my email is @ the above blog.
Google Groups a.k.a "Spammer's Paradise" is Blocked.

== 4 of 4 ==
Date: Fri, Oct 31 2008 2:27 am
From: Juan Antonio Zaratiegui Vallecillo


arnuld wrote:
>> On Fri, 31 Oct 2008 09:52:36 +0100, Juan Antonio Zaratiegui Vallecillo
>
>> Oh sorry, you are right. I thought I had seen the usual homework question
>
>
> I don't get homework . I am no longer a kid ;)
>
>
Lucky you! I am 45 and I do get full loads of homework. I work at home ;-)


==============================================================================
TOPIC: C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression"
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 1:56 am
From: Hendrik Schober


Keith Thompson wrote:
> Hendrik Schober <spamtrap@gmx.de> writes:
>> Keith Thompson wrote:
>>> "robertwessel2@yahoo.com" <robertwessel2@yahoo.com> writes:
>>>> On Oct 28, 7:42 pm, JoelKatz <dav...@webmaster.com> wrote:
>>>>> What will be next? "case >=7:"?
>>>> Frankly I think ranges on the case constant expressions would be a
>>>> more useful addition while staying with the basic philosophy of the C
>>>> switch statement. IOW, "case 2...5:", or something along those
>>>> lines. But still not something I'm loosing sleep over...
>>> Then programmers will inevitably write
>>> case 'A' ... 'Z':
>>> which is non-portable (under EBCDIC it matches '\' and '}').
>> And why exactly would that be worse than an 'if'-'else' chain
>> relying on ASCII?
>
> It wouldn't. [...]

Then I don't see how your above argument is valid.

Schobi


==============================================================================
TOPIC: dynamic array and constructors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/24c7ef3e322053f1?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 1:42 am
From: Urs Thuermann


I have some old code I've written several years ago that doesn't
compile with newer versions of GCC. The code allocates an array of
objects that need to be initialized by calling a constructor with one
argument:

class B;

class A {
B *b;

public:
A(B *p) : b(p) {}
};

class B {

public:
void foo() {
// this declaration is ok
A a(this);

// the following causes an error with newer GCC:
// error: ISO C++ forbids initialization in array new
A *arr = new A[10](this);
}
};

int main()
{
B b;
}

This worked with g++ until version 3.3.x, but not since 3.4.x. The
problem is in the expression new A[10](this), since according to GCC,
initialization in array new is forbidden.

How would I initialize the array elements in ISO C++?


urs

== 2 of 2 ==
Date: Fri, Oct 31 2008 2:34 am
From: Maxim Yegorushkin


On Oct 31, 8:42 am, Urs Thuermann <u...@janus.isnogud.escape.de>
wrote:
> I have some old code I've written several years ago that doesn't
> compile with newer versions of GCC.  The code allocates an array of
> objects that need to be initialized by calling a constructor with one
> argument:
>
>     class B;
>
>     class A {
>         B *b;
>
>     public:
>         A(B *p) : b(p) {}
>     };
>
>     class B {
>
>     public:
>         void foo() {
>             // this declaration is ok
>             A a(this);
>
>             // the following causes an error with newer GCC:
>             // error: ISO C++ forbids initialization in array new
>             A *arr = new A[10](this);
>         }
>     };
>
>     int main()
>     {
>         B b;
>     }
>
> This worked with g++ until version 3.3.x, but not since 3.4.x.  The
> problem is in the expression new A[10](this), since according to GCC,
> initialization in array new is forbidden.
>
> How would I initialize the array elements in ISO C++?

There is no way to specify constructor arguments when using the array
version of new. The default constructor must be available.

Please see the older thread
http://groups.google.co.uk/group/comp.lang.c++.moderated/browse_frm/thread/18f1c9313d32d315
for more information.

--
Max


==============================================================================
TOPIC: solving circular dependencies with class only delcared in .h
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/652550d4b8a6f0f8?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 2:21 am
From: Marcel Müller


Mosfet schrieb:
> IS there another way to solve this and to keep implementation only in .h ?

Why do you want to have the implementation in .h. This requires at least
that all of your functions are declared inline (implicitely or
explicitely). If the compiler cares about that is another question, but
at least it blows up the compile time of your project significantly.

If you have a cyclic dependancy of the /declaration/ of your classes
e.g. because of the use of certain smart pointers like intrusive_ptr,
then you have a serious problem. If only the implementaions depend on
each other you have no problem.


Marcel


==============================================================================
TOPIC: looking for elegant C++ abstraction around pthread_key_t...
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/92098dc36b54f96a?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 2:25 am
From: Maxim Yegorushkin


On Oct 30, 11:48 pm, "Chris M. Thomasson" <n...@spam.invalid> wrote:
> Here is what I am playing around with now:

[]

Have you looked at http://www.boost.org/doc/libs/1_36_0/doc/html/thread/thread_local_storage.html
?

--
Max


==============================================================================
TOPIC: How to write a binder3 tempalte function?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/216f4e8937bbbf4a?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 2:44 am
From: Maxim Yegorushkin


On Oct 31, 2:39 am, Hill <zhubi...@gmail.com> wrote:
> This is an exercise on TCPL:
> Write a b i n d e r 3 () that binds the second and third arguments of
> a threeargument function to produce a unary predicate. Give an example
> where b i n d e r 3 () is a useful function.
> And i got a solution from << C++ solutions>>:
>
> template<typename FO>
> struct binder2_3
> {
>     typedef typename FO::result_type result_type;
>     typedef typename FO::first_argument first_argument;
>     binder2_3(const FO& fo,
>               typename FO::second_argument& a2,
>               typename FO::third_argument& a3)
>         :fo_(fo), a2_(a2), a3_(a3){}
>     result_type operator()(first_argument a1){
>         return fo_(a1, a2_, a3_);
>     }
> private:
>     FO fo_;
>     const typename FO::second_argument a2_;
>     const typename FO::third_argument a3_;};
>
> template<typename FO, typename P2, typename P3> inline
> binder2_3<FO> binder3(const FO& fo, const P2& a2, const P3& a3){
>     return binder2_3<FO>(fo, a2, a3);
>
> }
>
> I can't understand the followingn sentence:
> typedef typename FO::result_type result_type;
> It require FO has a member named result_type ?

It requires FO to have a type member named result_type: typedef,
struct, class or union.

> This is a too restrict rule.
> Could someone give an explaination?

This is because your binder object wraps the call to the underlying
functor. The binder has to return the result of the functor call,
therefore to be able to declare the type of the return value of
binder::operator() it needs to know the type of the return value of
the underlying functor.

--
Max


==============================================================================
TOPIC: allocate memory of derived class
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/87fc908ed9682594?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 2:51 am
From: Maxim Yegorushkin


On Oct 30, 11:43 pm, Pete Becker <p...@versatilecoding.com> wrote:
> On 2008-10-30 18:00:18 -0400, Salt_Peter <pj_h...@yahoo.com> said:
>
>
>
> >> template<class T>
>
> > should really be:
> > template< typename T >
>
> I guess I'll have to go through the C++ standard and change every
> template declaration to use "typename" instead of "class".
>
> This is a style thing. Some people prefer "typename" for unfathomable
> reasons, and right-thinking programmers use "class".

I agree with you. "class" is preferable for pragmatic reasons: easier
to type, occupies less real estate in the source files and means the
very same thing in this context.

--
Max


==============================================================================
TOPIC: Variable Block Text File
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c53528aeee514123?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 3:33 am
From: James Kanze


On Oct 30, 8:14 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> Richard Herring wrote:
> > A value is just a value, it isn't "binary" any more than it
> > is "hexadecimal".

> True, but it's difficult to talk about values and their
> storage when the terminology is so confusing.

> "Hexadecimal" refers quite unambiguously to the (usually
> ascii) representation of a numerical value (in base 16). The
> term "binary" is more complicated.

> In theory when you say "the number is stored in binary" it
> might refer to one of two things:

> 1) It's stored in base-2 representation. That is, the number
> is stored by writing a combination of the two characters '0'
> and '1'.

That is, actually, what is required by the C++ standard.

Of course, since only two characters are involved, a character
encoding using just one bit (rather than the usual 7, 8 or more)
is sufficient, and used by all of the implementations I've ever
encountered.

(Sort of a half :-). Just thought I'd add to the confusion, for
the fun of it.)

> 2) It's stored in the same way as it's stored in memory, in
> other words, as a series of octets. In other words, it's
> stored in "raw" format, without any conversion or
> representation in ascii.

I like the word "raw". Or "machine" or "hardware" representation.

The C++ standard requires this to be a pure binary
representation (and I don't think the intent is to require
ASCII).

Of course, all of the standard requirements are "as if"; an
implementation can use base 10, as long as it implements &, |, ^
and ~ in a manner that they behave "as if" the representation
were base 2.

> Thus the term "binary" is used with two different meanings: In
> some contexts it talks about base-2 (ascii) representation, in
> other contexts it talks about raw, unconverted byte values
> (eg. when saying "open the file in binary mode). These two
> things have basically nothing to do with each other, except
> that they share the name "binary".

And that they are both demonstrably base 2. (Consider the
behavior of |, &, ^ and ~.)

> Maybe this is the reason why it seems that some people get
> even more confused and think "hexadecimal" refers to what
> usually is meant with "binary" (in the second meaning).

Since most modern machines are byte oriented, maybe we should
call machine format base 256.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


==============================================================================
TOPIC: Insert static array of struct in a vector
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/67f0d0e0bb28dd7a?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Oct 31 2008 3:37 am
From: John Doe


Hi,

I have a static array of struct defined like this :

CViewMgr::ViewInfo g_ViewInfo[] =
{
{ EMainView, ECreateOnce, IDR_MAINFRAME, RUNTIME_CLASS(CMainView),
NULL,0, 0 },
{ EWelcomeView, ECreateAndDestroy, IDR_MENU_OKCANCEL,
RUNTIME_CLASS(CWelcomeView), NULL,0, 0 },
};

I would like to put all these declarations in a vector how can I do it ?
typedef std::vector<ViewInfo> ViewList;
ViewList viewList;

soemthing like :

for (int i = 0; i < _countof(g_ViewInfo); i++)
viewList.push_back(g_ViewInfo[i]);

But I am sure there is an easier way, maybe I should call reserve before ?

== 2 of 4 ==
Date: Fri, Oct 31 2008 3:40 am
From: Maxim Yegorushkin


On Oct 31, 10:37 am, John Doe <mos...@anonymous.org> wrote:
> Hi,
>
> I have a static array of struct defined like this :
>
> CViewMgr::ViewInfo g_ViewInfo[] =
> {
>         { EMainView,            ECreateOnce,            IDR_MAINFRAME,          RUNTIME_CLASS(CMainView),
> NULL,0, 0 },
>         { EWelcomeView,         ECreateAndDestroy,      IDR_MENU_OKCANCEL,
> RUNTIME_CLASS(CWelcomeView), NULL,0, 0 },
>
> };
>
> I would like to put all these declarations in a vector how can I do it ?
> typedef std::vector<ViewInfo> ViewList;
> ViewList viewList;
>
> soemthing like :
>
> for (int i = 0; i < _countof(g_ViewInfo); i++)
> viewList.push_back(g_ViewInfo[i]);
>
> But I am sure there is an easier way, maybe I should call reserve before ?

Try this:

ViewList viewList(
g_ViewInfo
, g_ViewInfo + sizeof g_ViewInfo / sizeof *g_ViewInfo
);

--
Max

== 3 of 4 ==
Date: Fri, Oct 31 2008 3:52 am
From: John Doe


Maxim Yegorushkin wrote:
> On Oct 31, 10:37 am, John Doe <mos...@anonymous.org> wrote:
>> Hi,
>>
>> I have a static array of struct defined like this :
>>
>> CViewMgr::ViewInfo g_ViewInfo[] =
>> {
>> { EMainView, ECreateOnce, IDR_MAINFRAME, RUNTIME_CLASS(CMainView),
>> NULL,0, 0 },
>> { EWelcomeView, ECreateAndDestroy, IDR_MENU_OKCANCEL,
>> RUNTIME_CLASS(CWelcomeView), NULL,0, 0 },
>>
>> };
>>
>> I would like to put all these declarations in a vector how can I do it ?
>> typedef std::vector<ViewInfo> ViewList;
>> ViewList viewList;
>>
>> soemthing like :
>>
>> for (int i = 0; i < _countof(g_ViewInfo); i++)
>> viewList.push_back(g_ViewInfo[i]);
>>
>> But I am sure there is an easier way, maybe I should call reserve before ?
>
> Try this:
>
> ViewList viewList(
> g_ViewInfo
> , g_ViewInfo + sizeof g_ViewInfo / sizeof *g_ViewInfo
> );
>
> --
> Max
>
>
>
So I suppose it means I have to put init in constructor because my list
is a variable member.

CViewMgr::CViewMgr():
m_viewList(g_ViewInfo, g_ViewInfo + _countof(g_ViewInfo))
{

}

== 4 of 4 ==
Date: Fri, Oct 31 2008 4:13 am
From: Maxim Yegorushkin


On Oct 31, 10:52 am, John Doe <mos...@anonymous.org> wrote:
> Maxim Yegorushkin wrote:
> > On Oct 31, 10:37 am, John Doe <mos...@anonymous.org> wrote:
> >> Hi,
>
> >> I have a static array of struct defined like this :
>
> >> CViewMgr::ViewInfo g_ViewInfo[] =
> >> {
> >>         { EMainView,            ECreateOnce,            IDR_MAINFRAME,          RUNTIME_CLASS(CMainView),
> >> NULL,0, 0 },
> >>         { EWelcomeView,         ECreateAndDestroy,      IDR_MENU_OKCANCEL,
> >> RUNTIME_CLASS(CWelcomeView), NULL,0, 0 },
>
> >> };
>
> >> I would like to put all these declarations in a vector how can I do it ?
> >> typedef std::vector<ViewInfo> ViewList;
> >> ViewList viewList;
>
> >> soemthing like :
>
> >> for (int i = 0; i < _countof(g_ViewInfo); i++)
> >> viewList.push_back(g_ViewInfo[i]);
>
> >> But I am sure there is an easier way, maybe I should call reserve before ?
>
> > Try this:
>
> >     ViewList viewList(
> >           g_ViewInfo
> >         , g_ViewInfo + sizeof g_ViewInfo / sizeof *g_ViewInfo
> >         );
>
> > --
> > Max
>
> So I suppose it means I have to put init in constructor because my list
> is a variable member.
>
> CViewMgr::CViewMgr():
> m_viewList(g_ViewInfo, g_ViewInfo + _countof(g_ViewInfo))
> {
>
> }

This syntax invokes the constructor of the vector which accepts two
iterators.

There is also vector::insert() which accepts iterators. It is
perfectly fine to append to an empty vector as well:

viewList.insert(
viewList.end()
, g_ViewInfo
, g_ViewInfo + _countof(g_ViewInfo)
);

--
Max


--
Max


==============================================================================
TOPIC: Question about creating a struct of flags in c++
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aded373b78039bdf?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Oct 31 2008 3:42 am
From: James Kanze


On Oct 30, 4:03 pm, "Plisske...@gmail.com" <Plisske...@gmail.com>
wrote:
> On Oct 30, 9:22 am, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> > Plisske...@gmail.com wrote:
> > > [..] If I create a class like this:
> > > class myMask {
> > > public:
> > > bool flag1:1;
> > > bool flag2:1;
> > > bool flag3:1;
> > > bool flag4:1;
> > > bool flag5:1;
> > > bool flag6:1;
> > > bool flag7:1;
> > > bool flag8:1;
> > > bool flag9:1;
> > > bool flag10:1;
> > > bool flag11:1;
> > > bool flag12:1;
> > > bool flag13:1;
> > > };

> > > Can I set all the flag to 0 by doing this:

> > > myMask mask;

> > That will leave them undefined. Consider defining the
> > default constructor and the comparison operator.

> > > memset(&mask, '\0', sizeof(myMask));

> > > And can I compare if 2 masks are the same by doing this:

> > > myMask mask1;
> > > myMask mask2;

> > > memcmp(&mask1, &mask2, sizeof(myMask));

> > It is better to have the overloaded operator== in your class.

> In my case, I have this class which only have
> ~200 boolean flags. I am thinking if there is a faster way to
> * initialize all of them to false

Faster than what? I'd expect the compiler to use the fastest
means available on the target hardware for myMask().

> * compare if 2 classes have the same values (the same set of flags are
> set)

Regretfully, there's not real way to compare the values other
than one by one. The compiler is free to introduce padding
where ever it wants. In practice, if you arrange for the total
number of bits to be a multiple of your machine's word size
(with an unsigned pad:n at the end, where n is whatever is
needed), and ensure that the added field is always 0, memcmp
will almost certainly work, even if the standard doesn't
guarantee it.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

== 2 of 3 ==
Date: Fri, Oct 31 2008 3:52 am
From: James Kanze


On Oct 30, 4:03 pm, ".rhavin grobert" <cl...@yahoo.de> wrote:
> On 30 Okt., 06:50, "Plisske...@gmail.com" <Plisske...@gmail.com>
> wrote:

[...]
> > And can I compare if 2 masks are the same by doing this:

> > myMask mask1;
> > myMask mask2;

> > memcmp(&mask1, &mask2, sizeof(myMask));

> try this:

> struct myMask {
> union {
> unsigned int nMask;
> struct {
> bool flag1:1;
> bool flag2:1;
> bool flag3:1;
> bool flag4:1;
> bool flag5:1;
> bool flag6:1;
> bool flag7:1;
> bool flag8:1;
> bool flag9:1;
> bool flag10:1;
> bool flag11:1;
> bool flag12:1;
> bool flag13:1;
> };
> };
> };

> inline bool operator==(myMask const& rm, myMask const& lm)
> {return rm.nMask == lm.nMask;};

Lot's of problems with that.

-- It's not legal C++. Only unions can be anonymous, not
structs.

-- You'll almost certainly end up with undefined behavior using
it; you can't access the nMask element unless it was the
last one written to.

-- If you've written to the flags structure (which you haven't
named), the padding bits may take on any arbitrary values.
Which mean that two equal myMask may have unequald nMask.

-- For up to 16 flags, you're OK, but for more, the unsigned
may be smaller than the struct.

> the union will force your compiler to put all the bits into
> one int.

Not really.

> you can the set the int to 0 to clear all bits and compare the
> ints to compare the masks.

If the int is large enough, this will probably work *IF* he
makes sure that any unused bits in the struct are always 0.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

== 3 of 3 ==
Date: Fri, Oct 31 2008 4:44 am
From: Hendrik Schober


Victor Bazarov wrote:
> Plissken.s@gmail.com wrote:
>> On Oct 30, 9:22 am, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
>>> Plisske...@gmail.com wrote:
>>>> [..] If I create a class like this:
>>>> class myMask {
>>>> public:
>>>> bool flag1:1;
>>>> bool flag2:1;
>>>> bool flag3:1;
>>>> bool flag4:1;
>>>> bool flag5:1;
>>>> bool flag6:1;
>>>> bool flag7:1;
>>>> bool flag8:1;
>>>> bool flag9:1;
>>>> bool flag10:1;
>>>> bool flag11:1;
>>>> bool flag12:1;
>>>> bool flag13:1;
>>>> };
>>>> Can I set all the flag to 0 by doing this:
>>>> myMask mask;
>>> That will leave them undefined. Consider defining the default
>>> constructor and the comparison operator.
>>>
>>>
>>>
>>>> memset(&mask, '\0', sizeof(myMask));
>>>> And can I compare if 2 masks are the same by doing this:
>>>> myMask mask1;
>>>> myMask mask2;
>>>> memcmp(&mask1, &mask2, sizeof(myMask));
>>> It is better to have the overloaded operator== in your class.
>>>
>>> V
>>> --
>>> Please remove capital 'A's when replying by e-mail
>>> I do not respond to top-posted replies, please don't ask
>> Thank you for all the help.
>>
>> In my case, I have this class which only have
>> ~200 boolean flags. I am thinking if there is a faster way to
>> * initialize all of them to false
>> * compare if 2 classes have the same values (the same set of flags are
>> set)
>>
>> Thank you again.
>
> What you could do is have a static object of the same class that you'll
> use as the prototype for initialising, and have the proper padding to
> ensure that all data members are initialised:
>
> struct myLargeClass {
> bool blah : 1; // 1st bit
> bool clah : 1; // 2nd bit
> ...
> bool zlah : 1; // 25th bit
> unsigned padding : 7; // to bring it to 32 bits total
>
> static myLargeClass prototype;
> myLargeClass() {
> if (this != &prototype)
> memset(this, &prototype, sizeof *this);
> }
> };
>
> Statics are always zero-initialised, so 'prototype' is going to contain
> all zeros. Then you can always compare objects using 'memcmp' since
> there will be no uninitialised bits.
>
> Don't forget to define 'prototype' somewhere in your implementation file.

While this works, I wonder what's wrong with 'std::bitset'
that you prefer to do it manually? (I have never used it,
so I don't know what its disadvantages are.)

> V

Schobi


==============================================================================
TOPIC: List erase iterator outside range
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/25a39eff0031f895?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 3:57 am
From: Hendrik Schober


Krice wrote:
> On 29 loka, 15:31, Marcel Müller <news.5.ma...@spamgourmet.com> wrote:
>> Approximately here I get the first bunch of compiler errors.
>
> Wow, what a surprise!
>
>> So please either post resonable C++ code
>
> Fuck you.

Wow. Someone really needs help here.

Schobi


==============================================================================
TOPIC: vector<const T(*)> vs. vector<T(*)>
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 4:01 am
From: James Kanze


On Oct 30, 12:04 pm, eiji.anonrem...@googlemail.com wrote:

> I'm facing some uncertainty with const template arguments.
> Maybe someone could explain the general strategy.

> #include <vector>

> int main(int arc, char** argv)
> {
> std::vector<const int> vec;

This is illegal---undefined behavior according to the standard.
It doesn't compile with my compiler (g++, with the usual
options). And whatever happens if it does compile, you can't
count on it.

> const int i = 5;
> vec.push_back(i);
> vec[0] = 4; //const has gone away

Maybe. Or maybe it core dumps. Or maybe just about anything
else. (I would generally expect it not to compile, but the
standard doesn't require an error message.

> std::vector<const int*> pvec;
> const int* pi = new int(5);
> pvec.push_back(pi);
> *(pvec[0]) = 4; // not possible because const, compile error

> return 0;
> }

> From the first impression, it is not possible to create a
> vector of const ints. But you can do it with pointers.

What's in the vector cannot be const. You can create a vector
of non-const pointers to const (which is what you did), but not
of const pointers to anything. (You're probably being confused
by a widespread abuse of language. int const* is not a const
pointer, but a pointer to const. A const pointer would be int*
const or int const* const. More generally, just remember that
the const applies to whatever precedes it.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


==============================================================================
TOPIC: opening jpeg file in c++
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/ee4a622091cbf4cb?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Oct 31 2008 4:20 am
From: mohi


hello everyone ,

i am trying to read a jpeg image through c++ but is unable to do so ,
presently i tried it with code in c as i use something like ;

FILE * fp=fopen("./x.jpg","wb");
int c;
do{
read(fp,&c,sizeof(c));
if( c==(int) 0xFF23){
do.....
do....
}

printf("%x",c);
}
while(c!=EOF);

but the problem is the if condition never evalutes to true as i know
that according to the jpeg standard there should be market with value
0xFFD8 and others also .....and also the printf() of integer 'c' as
hex is never displayed it just displays a blank ..

what could be wrong ??

or what is the best way to read a binary file such as an image ??

thanks a lot
mohan gupta

== 2 of 2 ==
Date: Fri, Oct 31 2008 4:36 am
From: Maxim Yegorushkin


On Oct 31, 11:20 am, mohi <mohangupt...@gmail.com> wrote:
> hello everyone ,
>
> i am trying to read a jpeg image through c++  but is unable to do so ,
> presently i tried it with code in c as i use something like ;
>
> FILE * fp=fopen("./x.jpg","wb");

This opens the file for writing. If a file with the same name already
exists its content is erased and the file is treated as a new empty
file.

--
Max


==============================================================================
TOPIC: Is c++ only better c ?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/38527e42967dc124?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 5:01 am
From: James Kanze


On Oct 30, 7:55 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> James Kanze wrote:
> >> The LaTeX equation syntax is *by far* simpler to read and
> >> write by a human.

> > The point is that neither are designed to be read by a
> > human; they are designed to be read my a machine in order to
> > generate output which is read by a human.

> That's like saying that the text you just wrote is not
> designed to be read by a human but by a machine (for the sole
> reason that you are writing it with a machine rather than pen
> and paper).

Yes and no.

Yes in the sense that what you are reading is NOT what I
actually typed. (I only typed a line break between paragraphs,
for example. My editor ensures that the line with is no more
than 64.)

Yes also in the sense that what I typed resulted in a sequence
of bytes, which you read through a program which renders them as
text on the screen. And what you read depends on that renderer;
if it interprets those bytes as EBCDIC, what I've written will
be pretty unreadable.

No, however, in the more important sense that what you are
reading is a very direct, one to one rendering of the bytes in
the file; each byte (or each character) in the file corresponds
to a single text character rendered on your screen or printer.
This is not the case for LaTeX or MathML or XHTML or other
markup languages. More importantly, with the possible exception
of LaTeX, you wouldn't actually type the character sequence
being transmitted, or even necessarily see it. Even with LaTeX,
I suspect that most people will use something like LyX, and
rarely look at or worry about the actual "program" that they've
written.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


==============================================================================
TOPIC: WORD TO PDF CONVERTER !
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/aa74516e119018a7?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Oct 31 2008 5:01 am
From: Kimo1021


Dear all,

that program converts from word to pdf very easy and free


DOWNLOAD HERE FOR FREE

http://www.ziddu.com/download/2418735/Savefromwiordaspdfformat.rar.html

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

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