http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* c++ as scripting language - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/8b6a860779bd7319?hl=en
* Constructor problem - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/d528665531d6d939?hl=en
* map vs list performance - 5 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/f0b7f86d78b91416?hl=en
* Learning C++ - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/4ccf5387f1787434?hl=en
* Possible workaround for dlsym() and cast from/to void* - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.c++/t/c0644c95757da3b1?hl=en
* Writing good articles that have much better chance to be seen by others - 5
messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/ddbe20a354342370?hl=en
* Final Call for Participation - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/9de9a68d30363972?hl=en
* Which C++ books are recommended? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/3b718e059a7036ac?hl=en
* String not printing data on next line despite \n in the string - 1 messages,
1 author
http://groups.google.com/group/comp.lang.c++/t/35658d761ffe5130?hl=en
* Saving a binary file into a string - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ddc89ddf30293133?hl=en
==============================================================================
TOPIC: c++ as scripting language
http://groups.google.com/group/comp.lang.c++/t/8b6a860779bd7319?hl=en
==============================================================================
== 1 of 4 ==
Date: Thurs, Dec 31 2009 12:11 am
From: balajee
Hi,
Thanks for deep discussion. I am trying to move this thread towards
closing my needs. My requirement is - We have standard automation
framework which runs on TCL. These automation scripts connect to test
devices(our own platforms), execute few commands, fetch the output and
compare with standrd format to cross check everything is perfect. I
just want to know whether same thing can be done using C or C++.
Because of some internal reasons, we decided to not to use TCL or
PERL. We are just evaluating other options. Any suggessions are
welcome. Thanks in advance.
Thanks,
Balajee
== 2 of 4 ==
Date: Thurs, Dec 31 2009 12:49 am
From: "BGB / cr88192"
"Rolf Magnus" <ramagnus@t-online.de> wrote in message
news:hhfjak$jh4$00$1@news.t-online.com...
> BGB / cr88192 wrote:
>
>> for example, what does it matter that much, if for example, "foo.bar" and
>> "foo->bar" are equivalent, ...
>
> How does it know if you want to access a member of an object or use its
> operator->, e.g. when using std::auto_ptr?
>
dunno, I have not looked into CINT that much personally...
>> what if say, 95% of the time, things work, but in those 5% of edge cases,
>> fails miserably?...
>
> If it's supposed to be useful as a C++ interpreter, it must work with most
> existing code (libraries) without the need to heavily modify it first. Is
> that the case?
>
I can't say personally, but presumably it works "well enough" otherwise most
would have not have concluded that it "works" to begin with...
typically though, for something like this, it is passable if most things at
least parse quietly enough, even if not everything works right, as one could
use precompiled libraries and gloss over the rest?...
granted, I can't say I have personally used it, so I don't really know how
well it works in practice.
>> it would be like, say, if you had someone who was not very good with
>> English, but most of the time were understood and understood what was
>> being said, but every so often would have notable grammer errors, not
>> make
>> sense, or fail to understand well-formed statements.
>>
>> do we say then that they can't speak English?... no, we usually just say
>> it isn't very good at it.
>
> Spoken languages and programming languages can't really be compared that
> way.
>
I have heard "all or nothing" complaints enough in the past, but in my
experience it rarely is as drastic as people tend to make it out to be.
it is much like buggy code:
one would think it "all or nothing" if code contained bugs;
possibly it does, but if no one steps on them, then they don't pose a
problem.
granted, maybe one does step on one, and it is a grenade that blows their
leg off...
well, it is a bug, but if it works most of the time, well then, it works
most of the time.
approximate implementations very often work, approximately.
there is a lot that can be glossed over.
for example, I have an x86 interpreter which works well enough in my tests
even though:
many parts of the ISA are either not faked entirely, or are absent;
many core parts of the interpreter are drastically different than its
real-life CPU counterpart...
thing doesn't even have correctly working segmentation support, or at this
point, even paged memory (it instead uses "spans-based" memory, which is
made to "sort of resemble" paged memory).
as well, many flags in "eflags" don't work, many instructions are missing,
...
yet, the simulated processes don't seem to notice (me generally running code
compiled with GCC on the thing), as none have stepped on any of these
landmines (I would do, as most of these edge cases are rigged up to generate
an immediate simulated #UD or #GP if encountered...).
(oh yes, and this is the same x86 interpreter which I noted elsewhere, has
some of the logic in several places driven by string-processing magic, such
as the main instruction decoder...).
so, who knows...
== 3 of 4 ==
Date: Thurs, Dec 31 2009 1:00 am
From: nick
On Dec 31, 3:11 am, balajee <balaj...@gmail.com> wrote:
> Hi,
> Thanks for deep discussion. I am trying to move this thread towards
> closing my needs. My requirement is - We have standard automation
> framework which runs on TCL. These automation scripts connect to test
> devices(our own platforms), execute few commands, fetch the output and
> compare with standrd format to cross check everything is perfect. I
> just want to know whether same thing can be done using C or C++.
> Because of some internal reasons, we decided to not to use TCL or
> PERL. We are just evaluating other options. Any suggessions are
> welcome. Thanks in advance.
>
> Thanks,
> Balajee
So you want your program to run other programs, interpret the output
and do stuff based on that, right? Yes, it can be done - take a look
at the 'system' function from cstdlib, or check out the first two
posts in this thread of OS-specific implementations: http://www.gidforums.com/t-3369.html
You're probably better off sticking with a scripting language for this
kind of thing, though. As long as you are exploring options, maybe try
using a batch or shell script or a different scripting language. If
TCL and perl are out, lua might be worth consideration.
-- Nick
== 4 of 4 ==
Date: Thurs, Dec 31 2009 1:22 am
From: "BGB / cr88192"
"James Kanze" <james.kanze@gmail.com> wrote in message
news:cdd087da-6709-4d0e-8f3c-f6e97dab8729@s31g2000yqs.googlegroups.com...
> On 30 Dec, 15:48, Robert Hairgrove <rhairgr...@bigfoot.com> wrote:
>> Michael Doubez wrote:
>
> [...]
>> Any language will eventually need to be translated into some kind of
>> pseudo-code or byte code (even if interpreted) or else into machine
>> language, if it is to be executed at all. Machines can only understand
>> machine language. This applies to C++ as well as Java or (shudder)
>> Visual Basic.
>
> Yes, but the interpreter can interpret a textual representation
> without converting it into an itermediate format. I'm not
> saying that it's a good solution, but I've used one or two that
> worked that way.
>
yes...
and I know of a very trivial example:
using characters to directly drive the logic code behind such an
interpreter.
for example, the interpreter can be a sort of state machine, where each
character is dispatched via a switch and potentially either mutates state,
or switches to an alternate character dispatch loop, such that "parsing" and
"execution" are equivalent.
granted, this tends not to result in exactly "human readable" code (unless
one likes gobeledygook...), but allows for very simple, as well as
relatively fast, interpreters.
examples of where I have used this type of thing:
generating machine code (in my assembler);
driving instruction decoding (in my x86 interpreter, which uses the same
strings as the assembler);
generating special ASM fragments (various places, where I have both command
strings and FSM's (Finite State Machine) to convert these into ASM, to be
fed into the assembler);
...
another example:
I had used it before in basic genetic-programming tests, mostly as it had
allowed me to directly see the algos the GP evolver was devising, and
allowed allmost bytecode-like execution speeds.
granted, one would not design a general-purpose programming language this
way, or likely even attempt to implement a general-purpose compiler as a big
mass of FSM's...
>> There is no denying that some small subset of C++ could be
>> interpreted and executed at runtime instead of first compiled
>> and then the resulting file run as an executable. However, all
>> but toy programs have to deal with issues such as memory
>> management, variable scope, namespaces, pointers, exceptions,
>> etc. which cannot be resolved at runtime, but need to be dealt
>> with at compile time. An interpreter cannot do this IMHO.
>
> Sure it can. Some of these, like memory management, are purely
> runtime. Things like lexical scope are considerably trickier,
> but they can be done.
>
yeah...
there is lots which can be done at runtime, and infact, many tasks are much
easier at runtime than compile time...
we just like compile-time, as it is usually faster...
anyways, namespaces and scope are hardly a problem for runtime resolution.
Lisp and Scheme have been doing lexical scoping (at runtime) for decades;
similarly, pretty much all JavaScript interpreters can do lexical scoping.
this is not the problem...
actually, there would not seem to be anything in that list which would
likely, actually, pose a problem for an interpreter.
(that or the Scheme REPL is actually just some sort of mass delusion, and
lambda's don't really exist...).
granted, if the comment were something like:
an interpreter can't really (directly) make use of statically compiled
classes and methods, I would be more inclined to agree.
it is bridging the gap between statically compiled machine code, and
high-level logic and interpretation, which is where most of the nastiness
lies...
(granted, even this can be addressed, granted it involves digging solutions
out of an "evil bag of horrors"...).
the big challenge for the average C or C++ programmer:
if given a textual string declaring a function to be called, and the
arguments to pass to it, how will you accomplish calling this function
without hard-coding any information about the function(s) to be called (the
only information available is what can be gained from standard OS API's, or
from reading in the source files).
(IOW: "if(!strcmp(name, "foo")) foo(atoi(arg1), ...);", ..., is an instant
fail).
now, consider this moment...
now, consider expanding it to support arbitrary expressions, functions,
entire compilation units, ...
can this be done? yes...
the question is to consider how to approach this.
> --
> James Kanze
==============================================================================
TOPIC: Constructor problem
http://groups.google.com/group/comp.lang.c++/t/d528665531d6d939?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Dec 31 2009 3:33 am
From: "Balog Pal"
"Robert" <watkinsdev@hotmail.com>
class FloatKeys
{
public:
> DWORD nValues;
>float* fvalues;
replace to:
std::vector<float> fvalues;
>FloatKeys::FloatKeys( DWORD n_type, float* fkeys )
>{
>nValues = n_type;
>...
replace to:
FloatKeys::FloatKeys( size_t size, const float* fkeys )
: fvalues(fkeys, fkeys+size)
{}
This solves the few dozen problems your code currently have.
==============================================================================
TOPIC: map vs list performance
http://groups.google.com/group/comp.lang.c++/t/f0b7f86d78b91416?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Dec 31 2009 5:59 am
From: Stephen Howe
On Wed, 30 Dec 2009 16:52:05 -0800 (PST), "AnonMail2005@gmail.com" <anonmail2005@gmail.com> wrote:
>The operator< member function should be something like this:
>
>bool abcd::operator<(const abcd & rhs) const
>{
> bool res = false;
> if (a < rhs.a)
> {
> res = true;
> }
> else if (a == rhs.a)
> {
> if (b < rhs.b)
> {
> res = true;
> }
> else if (b == rhs.b)
> {
> if (c < rhs.c)
> {
> res = true;
> }
> else if (c == rhs.b)
> {
> if (d < rhs.d)
> {
> res = true;
> }
> }
> }
> }
> return res;
>}
or
bool abcd::operator<(const abcd & rhs) const
{
if (a != rhs.a)
return (a < rhs.a);
else if (b != rhs.b)
return (b < rhs.b);
else if (c != rhs.c)
return (c < rhs.c);
else
return (d < rhs.d);
}
Stephen Howe
== 2 of 5 ==
Date: Thurs, Dec 31 2009 10:09 am
From: Lars Tetzlaff
Am 31.12.2009 00:17, schrieb barcaroller:
> I have an STL list that contains about 1500 objects. To check if an object
> exists in my list I iterate over it and check if a "key" matches. A key is
> just a struct that contains four integers.
>
> typedef struct
> {
> int a;
> int b;
> int c;
> int d;
> } abcd;
>
> class C
> {
> abcd key;
> char data[100];
> }
>
> for i = list.begin(); i != list.end(); i++)
> if ( mya == i->key.a && myb == i->key.b &&
> myc == i->key.c && myd == i->key.d )
> // object has been found; access data[]
>
>
>
> To improve performance, I converted the list to an STL map. I used the
> struct as the map's key and I added the operator<() and operator==()
> functions to allow the map to sort and find objects. I also replaced the
> list's for loop with map's find() function.
>
> if (map.find(mykey) != map.end())
> // object has been found; access data[]
>
>
> Everything is working correctly (adding, finding, deleting, etc) but the map
> solution is over 100% slower than the list for searches (say 100,000
> searches). I understand that a map has some additional overhead but I would
> have expected this overhead to be negligible for 1500 elements. I can't
> explain why a sequential list search is faster (the found objects are
> randomly dispersed and are not at the beginning of the list).
>
> Has anyone else noticed this performance issue? Using gcc on Linux.
>
>
>
I think you missed something. With the follwoing code
#include <cstdlib>
#include <list>
#include <map>
#include <iostream>
#include <vector>
#include <time.h>
using namespace std;
struct abcd
{
int a;
int b;
int c;
int d;
abcd( int a, int b, int c, int d ) : a(a), b(b), c(c), d(d) {}
abcd() {}
bool operator<(const abcd& k) const
{
if (a < k.a)
return true;
else
if (a > k.a)
return false;
if (b < k.b)
return true;
else
if (b > k.b)
return false;
if (c < k.c)
return true;
else
if (c > k.c)
return false;
if (d < k.d)
return true;
return false;
}
};
struct C
{
abcd key;
char data[100];
};
std::list<C> l;
std::map<abcd,C> m;
vector<abcd> k;
void init()
{
srand( 42 );
for( int i = 0; i < 1500; ++i ) {
abcd aABCD( rand(), rand(), rand(), rand() );
C aC;
aC.key = aABCD;
l.push_back( aC );
m.insert( make_pair( aABCD, aC ) );
if( i%10 == 0 ) k.push_back( aABCD );
}
}
const int count = 1000;
int main()
{
init();
clock_t start = clock();
int x = 0;
for( int z = 0; z < count; ++z ) {
x = 0;
for( vector<abcd>::iterator j = k.begin(); j != k.end(); j++ ) {
for( list<C>::iterator i = l.begin(); i != l.end(); i++) {
if ( j->a == i->key.a && j->b == i->key.b &&
j->c == i->key.c && j->d == i->key.d ){
x++;
continue;
}
}
}
}
clock_t listtime = clock();
int y = 0;
for( int z = 0; z < count; ++z ) {
y = 0;
for( vector<abcd>::iterator j = k.begin(); j != k.end(); j++ ) {
if( m.find( *j ) != m.end() ) {
y++;
}
}
}
clock_t maptime = clock();
std::cerr << "List: " << listtime - start << " " << x << std::endl;
std::cerr << "Map: " << maptime - listtime << " " << y << std::endl;
}
i get:
List: 1780000 150
Map: 10000 150
so map is 178 times faster than map!
Testet on Linux with gcc 4.3.2, -O3 option, processor at a fixed clock.
Lars
== 3 of 5 ==
Date: Thurs, Dec 31 2009 12:17 pm
From: Jeff Flinn
Stephen Howe wrote:
> On Wed, 30 Dec 2009 16:52:05 -0800 (PST), "AnonMail2005@gmail.com" <anonmail2005@gmail.com> wrote:
>
>> The operator< member function should be something like this:
>>
>> bool abcd::operator<(const abcd & rhs) const
>> {
>> bool res = false;
>> if (a < rhs.a)
>> {
>> res = true;
>> }
>> else if (a == rhs.a)
>> {
>> if (b < rhs.b)
>> {
>> res = true;
>> }
>> else if (b == rhs.b)
>> {
>> if (c < rhs.c)
>> {
>> res = true;
>> }
>> else if (c == rhs.b)
>> {
>> if (d < rhs.d)
>> {
>> res = true;
>> }
>> }
>> }
>> }
>> return res;
>> }
>
> or
>
> bool abcd::operator<(const abcd & rhs) const
> {
> if (a != rhs.a)
> return (a < rhs.a);
> else if (b != rhs.b)
> return (b < rhs.b);
> else if (c != rhs.c)
> return (c < rhs.c);
> else
> return (d < rhs.d);
> }
>
or my favorite:
#include "boost/tuple/tuple.hpp"
#include "boost/tuple/tuple_comparison.hpp"
bool abcd::operator<(const abcd & rhs) const
{
using boost::tuple::tie; // or IIRC std::tr1::tuple::tie
return tie(a, b, c, d) < tie(rhs.a, rhs.b, rhs.c, rhs.d);
}
Jeff
== 4 of 5 ==
Date: Thurs, Dec 31 2009 3:28 pm
From: Branimir Maksimovic
Lars Tetzlaff wrote:
> i get:
>
> List: 1780000 150
> Map: 10000 150
>
> so map is 178 times faster than map!
>
> Testet on Linux with gcc 4.3.2, -O3 option, processor at a fixed clock.
n^2 algorithm have to be slower than nlogn, no matter what ;)
Greets
== 5 of 5 ==
Date: Thurs, Dec 31 2009 3:37 pm
From: Daniel Pitts
Branimir Maksimovic wrote:
> Lars Tetzlaff wrote:
>> i get:
>>
>> List: 1780000 150
>> Map: 10000 150
>>
>> so map is 178 times faster than map!
>>
>> Testet on Linux with gcc 4.3.2, -O3 option, processor at a fixed clock.
>
> n^2 algorithm have to be slower than nlogn, no matter what ;)
Your statement is not true.
If an algorithm is O(f(n)) then the number of operations can be k*f(n) +
g(n), where g(n) contributes less than f(n) for large n. so, for small
N, an O(nlogn) algorithm may be slower than an N^2 algorithm. For
example, compare heap-sort to merge-sort on a list of 3 elements.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
==============================================================================
TOPIC: Learning C++
http://groups.google.com/group/comp.lang.c++/t/4ccf5387f1787434?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Dec 31 2009 6:21 am
From: "osmium"
nick wrote:
> The only alternative to the Microsoft toolchain that really gets any
> use on Windows as far as I know is MinGW (Windows port of gcc, the
> standard-issue gnu/linux compiler). It might be worth trying as well,
> but I'm willing to bet it's a bit more trouble to get set up.
MinGW is about as easy to set up as anything you are likely to see, it is
what I use. I am not in love with the debugger or the documentation and
there is no Usenet newsgroup. Why use it? I have had some traumatic
experiences with Microsoft products and avoid them when possible, 'nuff
said. Since you and I are both guessing, my guess is that the VC footprint
is huge compared to MinGW. I tried to install a version of VC once and it
bombed during the process, I said screw it, and never looked back.
== 2 of 3 ==
Date: Thurs, Dec 31 2009 8:14 am
From: Andy Champ
dragan wrote:
<snip>
> You should focus on building something first, before you get into deployment
> scenarios. That is, unless you wanna try the way the way of General Moters.
>
Motors. But WTH.
>> Harold A Climer
>> Dept. Of Physics Geology, and Astronomy
>
> Your ignorance and lack of research on the matter makes me question whether
> you are a TROLL. Read: I don't believe you!
>
>> U.T, Chattanooga
>> Rm. 406A Engineering, Math & Computer Science Building
>> 615 McCallie Ave. Chattanooga TN 37403
>> Harold-Cimer@utc.edu
>
Whether this is him or not I can't say but:
http://www.utc.edu/Faculty/Harold-Climer/
The guy exists.
On the other hand...
http://www.utc.edu/Academic/ComputerScienceAndEngineering/
They have a comp sci department - why ask here, and not there?
Andy
== 3 of 3 ==
Date: Thurs, Dec 31 2009 8:20 am
From: Harold A. Climer
On Wed, 30 Dec 2009 22:09:51 -0600, "dragan" <spambuster@prodigy.net>
wrote:
>Harold A. Climer wrote:
>> A friend of mine is moving to California and did not want to move all
>> his library.
>
>Wow, I CAN relate!! And who is he that KNOWS C++ cannot?! An appropriate
>post for the season (if there is season for such) "lament"?. I will pose the
>question as a separate thread.
>
>> He gave me quite a few books on programming using
>> different computer languages. BASIC,PASCAL, C,C++, etc.
>> I have had some experience programming in TRUEBASIC.
>> I would like to learn to program using C or C++.( Not professionally I
>> am too old for that)
>
>That is relevant, more than you think maybe.
>
>> What software do I need?(Something inexpensive)
>
>You need: inquisitiveness, desire, drive (a purpose? an alterior
>motive?).... The software is pretty much irrelevant. Though I can recommend
>the MS free compilers (at least the behemoths gave SOMEthing back!).
>
>> I have two computers.
>> The one at work is running Vista Home SP1 and the one at home is
>> running Windows XP MCE SP3.
>> I have seen some C++ stuff by Borland and Microsoft. I really do not
>> need the latest software,but I would like to be able for it to work
>> properly on XP and Vista.
>
>You should focus on building something first, before you get into deployment
>scenarios. That is, unless you wanna try the way the way of General Moters.
>
>> Harold A Climer
>> Dept. Of Physics Geology, and Astronomy
>
>Your ignorance and lack of research on the matter makes me question whether
>you are a TROLL. Read: I don't believe you!
>
>> U.T, Chattanooga
>> Rm. 406A Engineering, Math & Computer Science Building
>> 615 McCallie Ave. Chattanooga TN 37403
>> Harold-Cimer@utc.edu
>
DROP DEAD
==============================================================================
TOPIC: Possible workaround for dlsym() and cast from/to void*
http://groups.google.com/group/comp.lang.c++/t/c0644c95757da3b1?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Dec 31 2009 8:04 am
From: anonimo
Hello everyone,
i want to dinamically load one new function with dlopen()+dlsym(). As
we all know, the problem is that ISO C++ does not allow to safely cast
from void* to pointer-to-function and viceversa.
But I had an idea about a possible workaround and I would like to hear
your opinions: instead of getting a pointer to function with dlsym()
from the object file, I could get a pointer to an
array-of-pointers-to-functions and reference the first element to obtain
the pointer to the function I need. On the other side, in the object
file, I could use a global instance of a "proxy class" to dinamically
initialize this array at loading time, so that the first element will
contain the correct address of the function.
Thanks in advance.
== 2 of 2 ==
Date: Thurs, Dec 31 2009 8:20 am
From: Joshua Maurice
On Dec 31, 11:04 am, anonimo <anon...@no.it> wrote:
> Hello everyone,
>
> i want to dinamically load one new function with dlopen()+dlsym(). As
> we all know, the problem is that ISO C++ does not allow to safely cast
> from void* to pointer-to-function and viceversa.
[snip]
Just because it's not defined by one standard (the C++ standard) does
not make it undefined. It's defined by the POSIX standard. So, it's
ok.
However, it still lacks all kinds of type safety, but there's no way
to really have type safety with the current system. The object file
format does not store the type of function, so you have to know
beforehand the function type, and thus the dynamic loader and dlsym
cannot help you out.
==============================================================================
TOPIC: Writing good articles that have much better chance to be seen by others
http://groups.google.com/group/comp.lang.c++/t/ddbe20a354342370?hl=en
==============================================================================
== 1 of 5 ==
Date: Thurs, Dec 31 2009 8:05 am
From: Andy Champ
tanix wrote:
>
> My humble friend, I understand Usenet better than you,
> probably an order of magnitude better.
>
Tanix,
James has been providing useful replies on this group for at least three
years. You've managed a month, and the replies are not as useful.
Andy
== 2 of 5 ==
Date: Thurs, Dec 31 2009 10:55 am
From: tanix@mongo.net (tanix)
In article <lKGdnWijGeJ8VqHWnZ2dnUVZ8sydnZ2d@eclipse.net.uk>, Andy Champ <no.way@nospam.invalid> wrote:
>tanix wrote:
>>
>> My humble friend, I understand Usenet better than you,
>> probably an order of magnitude better.
>>
>
>Tanix,
>
>James has been providing useful replies on this group for at least three
>years.
So what?
What does it have to do with ANYTHING, even remotely related
to the subject of this thread or even group for that matter?
:--}
Ok, since this is probably the last thing that I can do this year,
let us afford some luxury here...
> You've managed a month,
Managed what?
And if I just stumbled upon this article via google groups for example
and decided to discuss it, does it somehow make me LESS valid?
:--}
Or, if I sit here for ten years, does it make me MORE valid?
Just the the sheer fact that you hang somewhere in limbo all your
life, does it make you MORE intelligent, more insightful?
Is this some kind of a club?
:--}
> and the replies are not as useful.
What "replies" are not "usesuful"?
Useful to WHOM?
Useful for WHAT purpose?
If they are not "useful" to you, just don't read them.
Does someone FORCE you?
And THIS is the most "useful" "law" or "standard" of Usenet.
Usenet is not a political party gathering of like minded,
thinking along the same lines. Is this a surpise for you?
Why don't you wake up to the SIMPLIEST things in life?
>Andy
Now, I'd like to discuss the issue of intellectual honesty.
You see, what you have done is to strip the ENTIRE context
and left a SINGLE statement. Why did you do that?
One more time: VAST majority of article views happen via web,
where all that people see is a single article, just like you see
it via google. You do not even have a thread to look at.
And distorting things THIS bad, you MUST be utterly intellectually
dishonest. And that is the reason I said that this ugly trip of
stripping is mostly used by people who have the worst intentions
possible and that is to distort and pervert the information and
try to make white look like black and vise versa.
And I stand by every single statement of mine.
If you wish to bring it up and respond to in, fine be my guest,
even though I am not obliged to even bother about it.
If you think differently, so be it. It is not MY life. It is yours.
Interestingly enough, this is a language group where people
are expected to have above average degree of intelligence
since their minds are much more sophisticated then most others
as they have to deal with issues of logic and all softs of
most complex things every day of their lives.
Strange to see the kind of argument you are making.
Not even clear what IS the very argument?
Just plain stinky guilt manipulation trip?
If you think THIS kind of argument, such as using the "standard"
buzzword, like it was a word of God, just to instill guilt
in others, is something even appropriate, too bad.
First of all RFC are NOT "standards".
They literally mean Request For Comment or Clarification.
Do you understand?
They are NOT ANY kind of "standard".
Yes, when there is some real RFC, where a group a people worked
for years on some technical system and designed something that
works and reconciles, that is a different matter.
The other people simply decide to go with it and it becomes
a "standard" by implication.
But to have THIS kind of obsenity and to even conceive of an
idea to use it as some kind of argument, trying to make someone
GUILTY of something, that is not only ugly, not only
PROFOUNDLY dishonest, but is simply rotten to the bone and marrow.
Simply DISGUSTING.
With THESE kinds of "standards", what do you expect to see next?
A list of words, acceptable in terms of netti-fetti-betty?
The name of the streets you are allowed to walk on?
Do you understand the BASIC human rights, as signed by VAST
majority of countries in the world?
Do you understand what means BASIC?
And RIGHTS, and not some luxury for the pure blooded.
There is such a right as freedom of expression.
Do you understand?
It does not say "you have freedom of expression" if you sit
on some group for more than 3 years and you do NOT have
such freedom if you are there for onoy a month.
Do I have to chew things like THESE to the software developers,
and not only software developers but LANGUAGE developers?
:--}
This is simply pathetic, I tellya.
What kind of language you can possibly design if your mind
works like this? What kind of issues you can possibly discuss
with THIS kind of guilt manipulation procedures, trying to
discredit someone or invalidate his opinion on the basis
that someone has wasted years on this group?
And here is what the post you were following up looked like
before you mutilated it to the point of obsene:
===== Quote begin =====
In article
<4a6b5487-5f11-4845-8335-d46653060270@a21g2000yqc.googlegroups.com>, James
Kanze <james.kanze@gmail.com> wrote:
>On 30 Dec, 04:21, ta...@mongo.net (tanix) wrote:
>> In article <20091229152640....@gmail.com>, Kaz Kylheku <kkylh...@gmail.com>
> wrote:
>> >On 2009-12-24, tanix <ta...@mongo.net> wrote:
>> >> So, from this standpoint, try to keep the context of the
>> >> article intact. No not delete some section of the article
>> >> you are following upon because you think it is
>> >> "insignificant" in YOUR opinion.
>
>> >In my opinion, it is bad netiquette not to trim the quoted
>> >article as much as possible.
>
>> Just the other way around.
>
>Not according to the official documents. Quoting RFC 1855:
>
> If you are sending a reply to a message or a posting be sure
> you summarize the original at the top of the message, or
> include just enough text of the original to give a context.
>
>It's not a question of opinion. It happens to be part of an
>official standard.
I would expect THIS kind of response from you, personally.
I think your brain functions much better than this.
Ok, lemme spend a couple of minutes on this.
You see, "official standard" can ONLY be applied to technical
issues, not the posting style or personal preferences.
Those are CONTENT issues.
You can not "standartize" the content issues.
So, to me, personally, if some fools start writing THESE kinds
of things into standards, then those very standards have little,
if not less, significance.
It is like a programmer deciding to dictate others how to do
business or diplomacy.
Simply does not make sense.
Secondly, things like these, even if written into standards,
only mean an agreement between the members of the "board".
I wonder if Russ Allbery signed under THIS kinds of standard.
I have my doubts he would. But... You never know, you never know.
I'll do you a favor and check this paper.
Wow!
NETIQUETTE STANDARD?
:--}
Have they gone totally insane to produce THIS kind of garbage?
And who wrote this?
Sally Hambridge
Intel Corporation
2880 Northwestern Parkway
SC3-15
Santa Clara, CA 95052
Phone: 408-765-2931
Fax: 408-765-3679
EMail: sallyh@ludwig.sc.intel.com
INTEL writing THESE kinds of guidelines?
:--}
This is not even a joke. This is PATHETIC.
And this so called standard was written by a SINGLE individual,
who apparently is dumb enough even to CONCEIVE such a thing.
This is the biggest disgrace in the entire history of Usenet.
:--}
>> Quite often, this stripping procedure is explicitly meant to
>> distort the material and present it as something else.
>
>That happens, but it's pretty rare. And most of the time, it's
>obvious when it happens.
>
>> Secondly, there is absolutely no issues with technical aspect of it.
>
>> >A Usenet archive to be useful must preserve the tree structure of
>> >threads.
>
>> Not true.
>
>Apparently, you don't understand Usenet, or are confusing it
>with some other medium.
My humble friend, I understand Usenet better than you,
probably an order of magnitude better.
Are you getting bored out of your head and there is nothing MORE
exciting than getting into things like these?
:--}
===== Quote end =====
--
Programmer's Goldmine collections:
Tens of thousands of code examples and expert discussions on
C++, MFC, VC, ATL, STL, templates, Java, Python, Javascript,
organized by major topics of language, tools, methods, techniques.
== 3 of 5 ==
Date: Thurs, Dec 31 2009 11:18 am
From: nick
On Dec 31, 1:55 pm, ta...@mongo.net (tanix) wrote:
> So what?
> What does it have to do with ANYTHING, even remotely related
> to the subject of this thread or even group for that matter?
MLYP?
== 4 of 5 ==
Date: Thurs, Dec 31 2009 12:08 pm
From: stan
tanix wrote:
> In article <4a6b5487-5f11-4845-8335-d46653060270@a21g2000yqc.googlegroups.com>, James Kanze <james.kanze@gmail.com> wrote:
>>On 30 Dec, 04:21, ta...@mongo.net (tanix) wrote:
>>> In article <20091229152640....@gmail.com>, Kaz Kylheku <kkylh...@gmail.com>
>> wrote:
>>> >On 2009-12-24, tanix <ta...@mongo.net> wrote:
>>> >> So, from this standpoint, try to keep the context of the
>>> >> article intact. No not delete some section of the article
>>> >> you are following upon because you think it is
>>> >> "insignificant" in YOUR opinion.
>>
>>> >In my opinion, it is bad netiquette not to trim the quoted
>>> >article as much as possible.
>>
>>> Just the other way around.
Actually Emily Postnews covered this long before you got to usenet.
>>
>>Not according to the official documents. Quoting RFC 1855:
>>
>> If you are sending a reply to a message or a posting be sure
>> you summarize the original at the top of the message, or
>> include just enough text of the original to give a context.
>>
>>It's not a question of opinion. It happens to be part of an
>>official standard.
>
> I would expect THIS kind of response from you, personally.
> I think your brain functions much better than this.
>
> Ok, lemme spend a couple of minutes on this.
>
> You see, "official standard" can ONLY be applied to technical
> issues, not the posting style or personal preferences.
Says who? Can you cite a reference or is this simply your opinion?
> Those are CONTENT issues.
> You can not "standartize" the content issues.
Yet, netiquette rules were developed from lessons learned before the
internet even existed. Back then the goal was to hopefully educate the
unwashed ignorant masses that flooded newsgroups every September when
school started. By the end of the first semester, things usually got
better as the clueless started to see that the rules worked and were a
good thing.
Back then, the unwashed were capable of learning that the rules were
based on sound principles and worked because the principles were in
fact correct. They accepted that there was a possibility that there
were people who might just know something they didn't.
Contrast that description with today's consistently uncivilized,
arrogant, rude (in other words petty and juvenile) behavior and you
get a glimpse at how the world has changed.
> So, to me, personally, if some fools start writing THESE kinds
> of things into standards, then those very standards have little,
> if not less, significance.
Voluntary rules for civilized behavior are always significant, it's
just that many are not capable of seeing why. Many can't or won't see
the consequences of noncompliance; to them it feels better to be
independent and rebellious. Anarchy is rarely enjoyable.
I think you confuse significance with consequences.
> It is like a programmer deciding to dictate others how to do
> business or diplomacy.
>
> Simply does not make sense.
To whom? Exactly what part is confusing? Cooperation and consequences
maybe?
Just a thought but your description of your work experiences and your
behavior and attitude regarding netiquette seem to show a common
thread and pattern. Cause and effect? Consequences?
> Secondly, things like these, even if written into standards,
> only mean an agreement between the members of the "board".
You really don't understand usenet.
Reading usenet from a web interface is like driving a motorcycle from
a sidecar; a very distorted and unnatural experience. For those who
prefer the web, they should stick to forums. Forums are different and
have different principles apply to meet those differences. Use the
right tool for the job is a lesson many learned as children; some swim
upstream into adulthood and even old age unfortunately.
Your thoughts seem appropriate for forums but they are ineffective for
usenet.
Let me ask. There was a time when the best people in the computer
field participated in usenet and you could easily and often find help
and interesting conversations. Does that sound like this group today?
It does not seem that way to me. I watched many top people leave and
many explained why they could no longer endure usenet.
For at least a token effort at something remotely related to C, does anyone
know what the M in Dennis M Ritchie stands for?
== 5 of 5 ==
Date: Thurs, Dec 31 2009 2:04 pm
From: stan
tanix wrote:
> In article <lKGdnWijGeJ8VqHWnZ2dnUVZ8sydnZ2d@eclipse.net.uk>, Andy Champ <no.way@nospam.invalid> wrote:
>>tanix wrote:
>>>
>>> My humble friend, I understand Usenet better than you,
>>> probably an order of magnitude better.
>>
>>James has been providing useful replies on this group for at least three
>>years.
>
> So what? What does it have to do with ANYTHING, even remotely
> related to the subject of this thread or even group for that matter?
Goes to claims of understanding.
<snip>
> You see, what you have done is to strip the ENTIRE context
> and left a SINGLE statement. Why did you do that?
Good manners, common courtesy, spirit of cooperation, demonstration of
understanding, etc ...
> One more time: VAST majority of article views happen via web,
> where all that people see is a single article, just like you see
> it via google. You do not even have a thread to look at.
The claim is simply wrong. It's not a vast or even a simple
majority. With a typical newsreader it's possible to simply filter out
every post from the big web portals. Besides losing a vast amount of
spam you improve the signal to noise greatly and you lose nothing like
a vast majority of posts.
Now if you count all the spam sent through google then you might
approach half of some groups, but if you disregard spambots the
numbers are more realistic.
> First of all RFC are NOT "standards".
> They literally mean Request For Comment or Clarification.
>
> Do you understand?
Why do you ask? Do you claim understanding of the organization and
governance of usenet?
> They are NOT ANY kind of "standard". Yes, when there is some real
> RFC, where a group a people worked for years on some technical
> system and designed something that works and reconciles, that is a
> different matter. The other people simply decide to go with it and
> it becomes a "standard" by implication.
>
> But to have THIS kind of obsenity and to even conceive of an idea to
> use it as some kind of argument, trying to make someone GUILTY of
> something, that is not only ugly, not only PROFOUNDLY dishonest, but
> is simply rotten to the bone and marrow.
How many people besides you have to disagree to prevent something from
becoming standard? Are you that powerful by yourself or is there some
minimum number of others required?
For the RFC's that existed before you discovered the internet, can you
invalidate those by simple disagreement too or is there a time limit
to your power?
<snip>
> Do you understand the BASIC human rights, as signed by VAST majority
> of countries in the world?
Again with the "vast"; your understanding of the state of human rights
in the international context is underwhelming. It's hard to find a
topic with more fundamental disagreement globally.
< snip>
> There is such a right as freedom of expression. Do you understand?
Rights never stand alone, they are paired with responsibility.
Freedom of expression comes with responsibility and limits. There is a
clear limit that prevents expression that causes harm to others. You
can't falsely yell fire in a crowded theater or knowingly say false
things to harm another. Those limits derive from the burden to act
responsibly and consequences based on civil law.
> It does not say "you have freedom of expression" if you sit on some
> group for more than 3 years and you do NOT have such freedom if you
> are there for onoy a month.
Where did you read or hear this? I can't find anything that promises
freedom of expression on usenet with or without qualifications.
> Do I have to chew things like THESE to the software developers,
> and not only software developers but LANGUAGE developers?
Is there someone there threatening you? Do you need help?
==============================================================================
TOPIC: Final Call for Participation
http://groups.google.com/group/comp.lang.c++/t/9de9a68d30363972?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Dec 31 2009 9:38 am
From: hkaiser
Please distribute!
--------------------------------
4th Annual Boost Conference 2010
--------------------------------
Aspen CO, USA, May 10-14, 2010, www.boostcon.com
Final Call for Participation
--------------------------------
Important dates:
Proposal submissions Extended to January 3, 2010
Proposals decisions sent January 25, 2010
(tentative program available)
Fully scheduled program available February 10, 2010
Session materials due April 15, 2010
--------------------------------
We invite you to submit session proposals to the 4th Annual Boost
Conference: BoostCon 2010 (Aspen CO, USA, May 10-14, 2010).
Traditionally the main face-to-face event for all things Boost
(www.boost.org), BoostCon 2010 will present leading speakers from
the whole C++ community. From using the Boost libraries to writing
and maintaining them, from evangelizing to deploying Boost within
your organization, from infrastructure and process to vision and
mission, and the new C++ Standard, BoostCon brings together the
sessions, the colleagues, and the inspiration to support your work
with C++ and Boost in particular for the next year.
To reflect the breadth of the Boost community, the conference
includes sessions aimed at two constituencies: Boost end-users
and hard-core Boost library and tool developers. The program
fosters interaction and engagement within and across those two
groups, with an emphasis on hands-on, participatory sessions.
Session topics
--------------
Topics of interest include, but are not restricted to, the
following:
* General tutorial sessions introducing one or more Boost
libraries
* In-depth sessions on using specific Boost libraries
* Case studies on using Boost
* Experts panels
* Advanced sessions on implementation techniques used within
Boost libraries
* C++0x and how it will change life for users and library writers
* Development workshops to extend or enhance existing Boost
libraries
* Workshops on design process
* Infrastructure workshops such as Build tools, Website, Testing
* Concepts and Generic Programming
* Hardware and infrastructure presentations focused on how
libraries can make better use of the technology
* Other topics likely to be of great interest to Boost users and
developers
Interactive and collaborative sessions are encouraged, as this is
the nature of both the on-line Boost community and the style of
learning and participation that has proven most successful at
such events. Sessions can be tutorial based, with an emphasis on
interaction and participant involvement, or workshop based,
whether hands-on programming or paper-based, discussion-driven
collaborative work.
Session formats
---------------
Presentations
Presentations focus on a practitioner's ideas and experience with
anything relevant to Boost and Boost users.
Panels
Panels feature three or four people presenting their ideas and
experiences relating to Boost's relevant, controversial, emerging,
or unresolved issues. Panels may be conducted in several ways,
such as comparative, analytic, or historic.
Tutorials
Tutorials are sessions at which instructors teach conference
participants specific Boost-relevant skills.
Workshops
Workshops provide an active arena for advancements in Boost-
relevant topics. Workshops provide the opportunity for experienced
practitioners to develop new ideas about a topic of common interest
and experience.
Author's Corner Presentations
These were introduced at BoostCon 2008, and were a great success.
They are short (30 minute) sessions, focusing on tips on usage and
design. In addition, we're looking to uncover the hidden design gems
in Boost libraries.
Tool Vendors Presentations
We actively encourage tool vendors and ISP's to submit proposals
for a special Tool Vendors Session Track aimed at products related
to Boost and C++ (compilers, libraries, tools, etc.).
Other formats may also be of interest. Don't hold back a proposal
just because it doesn't fit into a pigeonhole.
Submitting a proposal
---------------------
Standard Sessions are 90 minutes. You may submit a proposal for
fractions or multiples of 90-minutes. Fractional proposals will be
grouped into 90 minute sessions covering related topics.
Longer sessions, such as tutorials and classes, will be assigned 90
minute, three hour (i.e. half day), or six hour (i.e. full day) time
slots.
Please include:
* The working title.
* Type of session: presentation, panel, tutorial, workshop, authors
corner, vendor track, other.
* A paragraph or two describing the topic covered, suitable for the
conference web site.
* Proposed length: 10-20 minute short talks, 45 minutes, 90 minutes,
half day, full day.
* Alternate lengths, if you are willing to make adjustments: 10-20
minute short-talks, 45 minutes, 90 minutes, half-day, full day.
* Audience: users, developers, both.
* Level: basic, intermediate, advanced.
* A biography, suitable for the conference web site.
* Your contact information (will not be made public).
Submission details
------------------
All submissions have to be done through the EasyChair conference
management system: http://www.easychair.org/conferences/?conf=boostcon10.
If you have not already registered at EasyChair, you will need to
do so in order to submit your proposal.
All submissions will go through a peer review process.
Authors are invited (but are not required) to submit PDF versions of
full papers of up to 10 pages in ACM conference proceedings format
(see http://www.acm.org/sigs/publications/proceedings-templates). The
full papers are not required unless you want them published in the
proceedings.
All accepted proposals will be made available in the Association for
Computing Machinery (ACM) Digital Library (approval pending). Best
papers, after further reviews, will be considered to be book
chapters or journal articles in a renowned journal.
The session materials go on the BoostCon website and will be
available to attendees.
For general information on the BoostCon 2010 paper submission or
the scope of technical papers solicited, please refer to the
conference website at www.boostcon.com. For any other questions
about the submission process or paper format, please contact the
Program Committee at boostcon10@easychair.com. If you have any
technical problems with EasyChair, please contact EasyChair for
help.
Note: Presenters must agree to grant a non-exclusive perpetual
license to publish submitted materials, either electronically or
in print, in any media related to BoostCon.
Hartmut Kaiser, email: hartmut.kaiser@gmail.com (Program Committee
Chair)
David Abrahams, email: dave@boostpro.com (Conference Chair)
On behalf of the conference organizers
==============================================================================
TOPIC: Which C++ books are recommended?
http://groups.google.com/group/comp.lang.c++/t/3b718e059a7036ac?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Dec 31 2009 12:50 pm
From: Immortal Nephi
I have been through study by reading How to Program C++ by Deitel 6th
Edition. I believe that it has very little information to explain
design patterns.
I want to expand more knowledge of better understanding how Design
Patterns is used with Object-Oriented Programming. I don't find any
good books.
ATM example teaches how to use UML 2.0 and write several base
classes, one inheritance and polymorphism. ATM is the base class.
Screen, Keypads, Cash Withdrawal, and Deposit Slot are base classes
and they have compositions to be placed in ATM's base class.
Think of creating more subclasses. The screen's base class is good
example. I might want to build more subclasses and add more member
functions and data members to all subclasses. They are private
subclasses inside screen's base class.
We discussed gigantic class post earlier. Screen's base class might
become gigantic class. I am able to extract gigantic class into
subclasses by using refactoring.
I want to learn how to use Design Patterns and Refactoring. Here are
two books below. I am not sure if they are the right books. If not,
please make the list which books do you recommend me to study more.
Object-Oriented Computation in C++ and Java: A Practical Guide to
Design Patterns for Object-Oriented Computing by Conrad Weisert
Refactoring: Ruby Edition (Hardcover) by Jay Fields
==============================================================================
TOPIC: String not printing data on next line despite \n in the string
http://groups.google.com/group/comp.lang.c++/t/35658d761ffe5130?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Dec 31 2009 12:55 pm
From: stan
BGB / cr88192 wrote:
>>>
>>> as well, 256 is an "accepted" maximum string length (a tradition since
>>> long past that something is seriously wrong if a string is longer than
>>> this).
You're young and your history seems to stem from the micro world.
Limits date from a time when really long punch cards were hard to deal
with and they didn't fit the reader. :)
>> Accepted by who? I'm serving 10MB HTTP packets through std::string so I'm
>> sorry I have never heard of this convention. (There was a 256-char string
>> limitation in Turbo Pascal 3.3, but fortunately this is about 15 years in
>> history ;-)
>
> "accepted" by traditional practice.
>
> typically, constants like PATH_MAX, ... are 256.
POSIX and most linux disagree, check linux/limits.h.
> it doesn't take long (for example, if one digs around in system headers),
> before a string-length limit of 256 becomes a recurring pattern (even if
> there are variations, for example, UNIX_MAX is 108, but I think this is
> because of a general rule that (sizeof(sockaddr_storage)==128) or so, ...).
>
> there are many other examples of this particular limit being in use.
Calling this "accepted" or "common" is a stretch. Basic, Pascal, and
environments that represented strings with embedded size were limited
but even in research unix the constant was often larger even with real
core memory constraints. It's hard to find or imagine a modern
unix/linux/Gnu app with a 256 limit.
Windows has some real ideas about accepted string limits scattered
around randomly but I can't agree that either the concept of limits or
even a common 256 default exists in c and it's nonsense for c++.
> it is an accepted limit, much like how i, j, and k, are accepted names for
> integer variables, ...
Mostly habit from Fortran, where it was part of the language and not
just a convention, that was passed on through generations.
> granted, sometimes one wants a bigger limit though, and sometimes a bigger
> limit is used (as there is no real technical reason for this particular
> limit apart from convention), ...
You've mentioned games many times, so maybe in that domain this is a
convention. In many other fields this doesn't wash, and it seems you
may be crossing up c and c++ to boot.
==============================================================================
TOPIC: Saving a binary file into a string
http://groups.google.com/group/comp.lang.c++/t/ddc89ddf30293133?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Dec 31 2009 2:01 pm
From: Dominik Schmidt
On Sun, 27 Dec 2009 13:06:03 -0800 (PST), Jonathan Lee wrote:
> But still, it just seems odd. If you follow Rune's advice
> and use a std::vector, just resize it to the file size
> and read directly into the vector:
> I'm just anal about types. tellg() returns a streampos,
> which is defined by the standard to be a signed integral
> type. So it will fit into long long; you won't have a
> problem with that.
Thank you all for your many tips.
Here is my code (the new part). Error handling is still missing.
std::streampos GetFileSize(string FilePath)
{
std::streampos Out1 = -1;
ifstream file1;
file1.open (FilePath.c_str(), ios::binary);
if (file1.is_open())
{
file1.seekg(0, ios::end);
Out1 = file1.tellg();
}
file1.close();
return Out1;
}
std::vector<char> OpenFile(string FilePath)
{
std::vector<char> Out1;
ifstream file1;
std::streampos filesize;
filesize = GetFileSize(FilePath);
file1.open (FilePath.c_str(), ios::binary);
if (file1.is_open())
{
Out1.resize(filesize);
file1.read(&Out1[0], filesize);
}
file1.close ();
return Out1;
}
void SaveFile(string FilePath, std::vector<char> FileContent)
{
ofstream file1;
std::streampos filesize;
filesize = FileContent.size();
if (FileExists(FilePath)) KillFile(FilePath);
if (FileExists(FilePath)) return;
file1.open (FilePath.c_str(), ios::binary);
if (file1.is_open())
{
file1.write(&FileContent[0], filesize);
}
file1.close();
}
== 2 of 2 ==
Date: Thurs, Dec 31 2009 2:04 pm
From: Dominik Schmidt
On Mon, 28 Dec 2009 12:53:46 -0800 (PST), James Kanze wrote:
>> I'd like to know if I made an error, so if there's any
>> possibility that my functions won't work in some case?
>
> The question is: how portable do you want to be?
Currently I'm working on a Windows application, but I'm sure I'll use those
functions in other projects in the future.
So it should at least work on Windows and on common Linux distributions
(like Debian).
> Not related to your question, but if either OpenFile or SaveFile
> fails, you shouldn't return 0.
Yes, I'll change this...
>> void SaveFile(string FilePath, string FileContent)
>> {
>> ofstream file1;
>> long long filesize;
>> char Chr1;
>
>> filesize = FileContent.length();
>
>> if (FileExists(FilePath)) KillFile(FilePath);
>> if (FileExists(FilePath)) return;
>> if (filesize < 0) return;
>
> If filesize < 0, here, you've got a very serious bug in your
> implementation.
This line must have been a typo.
> (While I'm at it, what's with these file1? It's output, or what
> ever, or even file, given the context, but without the 1.)
I like names with numbers!? Is there something wrong about calling this
variable "file1"? Would you prefer "Johnson"? :-)
>> file1.open (FilePath.c_str());
>
> Formally, this is not guaranteed to work. Practically, it
> doesn't work under Windows if the file is opened in text mode
> (as you've done). Nor under most other systems: Unix is the
> exception.
Thanks, see my answer to Jonathan...
> If you're using system specific code... Use system specific
> versions of open/read/write/close. They should offer the
> necessary options for causing open to fail if the file doesn't
> exist (input) or causing your file to replace any existing file
> (output). For that matter, IIRC, this is guaranteed when you
> open an ifstream or an ofstream, so you don't need any of this
> anywhere.
Yes, I'm using system specific code in FileExists().
The only reason is that I'm not sure yet how to do this in a better way.
I want to get a false (as return value) only if the file does not exist,
but a true, if it exists, even if it's locked or hidden.
>> void Attach(string *OldString, string AddString, bool InNewLine)
>> {
>> if (InNewLine)
>> {
>> *OldString += Cr;
>> *OldString += Lf;
>> }
>> *OldString += AddString;
>
> And what on earth is this? (You only pass two arguments to
> Attach, so your code shouldn't even compile.)
My code does compile, because I have this in the header:
void Attach(string *OldString, string AddString, bool InNewLine = false);
>> bool KillFile(string FilePath)
>> {
>> int Out1;
>
>> Out1 = remove(FilePath.c_str());
>
>> return Out1 == 0;
>> }
>
> Just for the record, this can have interesting consequences
> under Unix, and might not be what you want.
What (consequences) do you mean by that?
==============================================================================
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
No comments:
Post a Comment