http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* ♪~Hot sale Fashion Jewelrys,Bangle,Bracelet,Cufflink,Earrings,Necklace,
Pendants,Puncture,Ring Www.nikejordanshoe.com ~♪ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/960de4e5d9733a12?hl=en
* Is there any difference of g++ 3.4.3 and g++ 3.3.4 ? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/e8755b9cb8f0fd61?hl=en
* ♀﹌♀SALE HOODY Lacoste,Edhardy,BBC,EVS,Coogi,Adidas,Bape,Polo,Christina
Audigier Hoody GOOD NO. ONE!!! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/5a94afbe77abd0ff?hl=en
* ✖♥✖Wholesale Versace,Gucci,DG,LV,DB,Coach,Chanel Wallets WWW.NIKEJORDANSHOE.
COM fashion&the best quality with low price - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/987f658b46af4f5d?hl=en
* ★✖★✖★ Sport shoes,Nike,Jordan,Gucci,Adidas,Puma,EdhardyShox,Max,Free,Rift,&
Polo,Lacoste,BBC,Gucci,Armani,LV,Christina Audigier Tshirt and Jeans - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/1e669a4fe51bdbc0?hl=en
* ⊕*▲*⊕Brand new POLO,Lacoste,Affliction ,Gucci,Edhardy,Armani,LV,Christina
Audigier Tshirt and Jeans ⊙ www.nikejordanshoe.com⊙ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/26e34a3a62d2b984?hl=en
* *∴⊕∵- HOT sale Watches,Ferrari,Armani,Gucci,Lange&Sohne,Longines,Breitling,
Alain Silberstein!!! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/15b7b3d4b8410380?hl=en
* STL simple problem - 9 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/ad063dc9bb2c3618?hl=en
* Explicitly calling constructors - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/756699b6d51d41c8?hl=en
* If you can help... (map::find and map::insert) - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a72f37731cef189f?hl=en
* object used to convert a pointer to a c string - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/85b01b97814e68fe?hl=en
* *-▼Welcome to www.fjrjtrade.com^_^Wholesale Fashion Tshirt,Jeans,Pants,
Hoody,Short--s,short shoes,causal shoes,sandals !!! - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/216e49e77af52121?hl=en
* ✪✪✪✦Paypal Payment✦ Fashion Style Brand Handbags Sale in China AAA True
Leather ,Purses, Handbags, GUCCI,JIMMY,LV,DIOR,CHLOE,CHANEL,BOSS,PRADA,etc.
Exempt Freight-▶-▶www.guomeitrade.com - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/9e7f5f0ad5e97b8d?hl=en
* wholesale Iphone 3G 8gb,16gb,N97,Blackberry,mobile phones!!! - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/9cbcfc8317a3f34e?hl=en
==============================================================================
TOPIC: ♪~Hot sale Fashion Jewelrys,Bangle,Bracelet,Cufflink,Earrings,Necklace,
Pendants,Puncture,Ring Www.nikejordanshoe.com ~♪
http://groups.google.com/group/comp.lang.c++/t/960de4e5d9733a12?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Jun 30 2009 4:41 am
From: Selina peng
Www.nikejordanshoe.com found in 1995, our email is
nikejordanshoe@hotmail.com. As a manufacture supplier,we have more
than 10 years experience of this business.All products are at prices
from original factory.All items have been verified by us, so they are
credible.Veries of sizes,brands,colors and styles can meets the
different customer need, fit customer demand to adjust the
production.AAA quality,most competitive prices is our promise. Our
main products are Sneaker,Tshirt,Jeans,Jacket,suits,Handbags,Watches,
mobile phones, and so on, you can click our website www.nikejordanshoe.com
to have a look.
==============================================================================
TOPIC: Is there any difference of g++ 3.4.3 and g++ 3.3.4 ?
http://groups.google.com/group/comp.lang.c++/t/e8755b9cb8f0fd61?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Jun 30 2009 4:45 am
From: Carfield Yim
HI, my source code was compiled ok in g++ 3.3.4 . But when I try to
use 3.4.3 to compile, I get the following error:
Utility.h: In constructor `Buffer<size>::Buffer(const char*)':
Utility.h:174: error: `buffer' undeclared (first use this function)
Utility.h:174: error: (Each undeclared identifier is reported only
once for each function it appears in.)
Utility.h:176: error: no matching function for call to `strchr(<type
error>, char)'
/usr/include/iso/string_iso.h:130: note: candidates are: char* strchr
(const char*, int)
/usr/sfw/lib/gcc/sparc-sun-solaris2.10/3.4.3/../../../../include/c++/
3.4.3/cstring:107: note: char* std::strchr(char*, int)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(const char*)':
Utility.h:183: error: `buffer' undeclared (first use this function)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(char)':
Utility.h:258: error: `buffer' undeclared (first use this function)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(int)':
Utility.h:271: error: `buffer' undeclared (first use this function)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(long int)':
Utility.h:287: error: `buffer' undeclared (first use this function)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(short int)':
Utility.h:303: error: `buffer' undeclared (first use this function)
Utility.h: In member function `Buffer<size>& Buffer<size>::operator+
(double)':
Utility.h:319: error: `buffer' undeclared (first use this function)
Utility.h: In member function `int Buffer<size>::length()':
Utility.h:329: error: `buffer' undeclared (first use this function)
I've checked the source code, look like "buffer" is declared at the
very beginning, can you help to suggest were is the problem? And what
is the hint of checking this problem?
Here is the source code:
#ifndef _Utility_h
#define _Utility_h
extern "C" {
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
}
// quick and dirty template string class (unfortunately non-standard!)
template<int size>
class String {
public:
char buffer[size + 1];
String() { buffer[0] = '\0';}
String(const char *from) {
// strncpy(buffer, from, size);
int smaller = (size < strlen(from)) ? size : strlen(from);
strncpy(buffer, from, smaller);
buffer[smaller] = '\0';
}
String(const int from) {
memset(buffer, '\0', size);
sprintf(buffer, "%d", from);
}
// assignment from String<size>
String& operator=(const String& from) {
int smaller = (size < from.getSize())? size : from.getSize();
strncpy(buffer, from.buffer, smaller);
buffer[smaller] = '\0';
return *this;
}
// assignment from const char *
String& operator=(const char *from) {
// strncpy(buffer, from, size);
if (!from) {
buffer[0] = '\0';
return *this;
}
int smaller = (size < strlen(from)) ? size : strlen(from);
strncpy(buffer, from, smaller);
buffer[smaller] = '\0';
return *this;
}
// assignment from int&
String& operator=(const int& from) {
memset(buffer, '\0', size);
sprintf(buffer, "%d", from);
return *this;
}
// assignment from short&
String& operator=(const short& from) {
memset(buffer, '\0', size);
sprintf(buffer, "%d", from);
return *this;
}
// assignment from long&
String& operator=(const long& from) {
memset(buffer, '\0', size);
sprintf(buffer, "%d", from);
return *this;
}
// assignment from double&
String& operator=(const double& from) {
memset(buffer, '\0', size);
sprintf(buffer, "%f", from);
return *this;
}
// comparison to String<size>&
int operator==(const String& to) const {
// JK 990329 - Compare null-terminated string rather than
// whole block of memory
// return !memcmp(buffer, to.buffer, size);
return !strncmp(buffer, to.buffer, size);
}
// comparison to String<size>&
int operator!=(const String& to) const {
// JK 990329 - Compare null-terminated string rather than
// whole block of memory
// return memcmp(buffer, to.buffer, size) != 0;
return strncmp(buffer, to.buffer, size) != 0;
}
// comparison to const char *
int operator==(const char *to) const {
return !strcmp(buffer, to);
}
// comparison to const char *
int operator!=(const char *to) const {
return strcmp(buffer, to);
}
// operator const char*() const { return buffer; }
operator char *() const { return (char *)buffer; }
operator int() const { return atoi(buffer); }
char *operator*() const { return (char *)buffer; }
int getSize() const{ return size; }
};
// Buffer is used only for generating the ISQL output.
template<int size>
class Buffer : public String<size> {
char *end;
public:
Buffer(const char *from = "") {
strncpy(buffer, from, size);
buffer[size] = '\0';
end = strchr(buffer, '\0');
}
// append operator from const char *
Buffer& operator+(const char *from) {
int length = strlen(from);
if (end + length <= buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, buffer + size - end);
end = buffer + size;
}
return *this;
}
Buffer& operator+=(const char *from) {
int length = strlen(from);
if (end + length <= String<size>::buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, String<size>::buffer + size - end);
end = String<size>::buffer + size;
}
return *this;
}
// append operator from char
Buffer& operator+=(char from) {
if (from == '\0') {
return *this;
}
if (end + 1 <= String<size>::buffer + size) {
end[0] = from;
end += 1;
}
return *this;
}
// append operator from int
Buffer& operator+=(int i) {
char from[16];
sprintf(from, "%d", i);
int length = strlen(from);
if (end + length <= String<size>::buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, String<size>::buffer + size - end);
end = String<size>::buffer + size;
}
return *this;
}
// append operator from double
Buffer& operator+=(double d) {
char from[64];
// JK 990329 - Ouput precision to 9 decimal places
// sprintf(from, "%f", d);
sprintf(from, "%.9f", d);
int length = strlen(from);
if (end + length <= String<size>::buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, String<size>::buffer + size - end);
end = String<size>::buffer + size;
}
return *this;
}
// append operator from char
Buffer& operator+(char from) {
if (from == '\0') {
return *this;
}
if (end + 1 <= buffer + size) {
end[0] = from;
end += 1;
}
return *this;
}
// append operator from int
Buffer& operator+(int i) {
char from[16];
sprintf(from, "%d", i);
int length = strlen(from);
if (end + length <= buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, buffer + size - end);
end = buffer + size;
}
return *this;
}
// append operator from long
Buffer& operator+(long i) {
char from[16];
sprintf(from, "%d", i);
int length = strlen(from);
if (end + length <= buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, buffer + size - end);
end = buffer + size;
}
return *this;
}
// append operator from short
Buffer& operator+(short i) {
char from[16];
sprintf(from, "%d", i);
int length = strlen(from);
if (end + length <= buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, buffer + size - end);
end = buffer + size;
}
return *this;
}
// append operator from double
Buffer& operator+(double d) {
char from[64];
sprintf(from, "%.9f", d);
int length = strlen(from);
if (end + length <= buffer + size) {
memcpy(end, from, length);
end += length;
} else {
memcpy(end, from, buffer + size - end);
end = buffer + size;
}
return *this;
}
int length() { return end - buffer; }
};
class Date : public String<16> {
static Date time;
public:
Date& operator=(const Date& from) {
String<16>::operator=(from);
return *this;
}
// TODO check that it is fine to leave this out
// Date& operator=(const char *& from) {
// String<16>::operator=(from);
// return *this;
//}
Date& operator=(const char *from) {
String<16>::operator=(from);
return *this;
}
int operator>(const Date& to) const {
return memcmp(buffer, to.buffer, 16) > 0;
}
int operator>=(const Date& to) const {
return memcmp(buffer, to.buffer, 16) >= 0;
}
int operator<(const Date& to) const {
return memcmp(buffer, to.buffer, 16) < 0;
}
int operator<=(const Date& to) const {
return memcmp(buffer, to.buffer, 16) <= 0;
}
int validate() const {
int yr, mo, dy, hr, mn, sc, hn;
if (sscanf(buffer, "%4d%2d%2d%2d%2d%2d%2d",
&yr, &mo, &dy, &hr, &mn, &sc, &hn) != 7) {
return -1;
}
if (yr < 1995 || mo < 1 || mo > 12 || dy < 1 || dy > 31 || hr
< 0 ||
hr > 23 || mn < 0 || mn > 60 || sc < 0 || sc > 60) {
return -1;
}
return 1;
}
static const Date& currentTime();
};
No comments:
Post a Comment