1. Class Hierarchy | 1 |
2. Class Reference | 7 |
| ..RWAuditStreamBuffer | 7 |
| ..RWBag | 12 |
| ..RWBagIterator | 16 |
| ..RWBench | 18 |
| ..RWBinaryTree | 25 |
| ..RWBinaryTreeIterator | 29 |
| ..RWbistream | 31 |
| ..RWBitVec | 37 |
| ..RWbostream | 43 |
| ..RWBTree | 49 |
| ..RWBTreeDictionary | 53 |
| ..RWBTreeOnDisk | 59 |
| ..RWBufferedPageHeap | 65 |
| ..RWCacheManager | 67 |
| ..RWCLIPstreambuf | 69 |
| ..RWCollectable | 73 |
| ..RWCollectableAssociation | 77 |
| ..RWCollectableDate | 79 |
| ..RWCollectableInt | 81 |
| ..RWCollectableString | 83 |
| ..RWCollectableTime | 86 |
| ..RWCollection | 87 |
| ..RWCRegexp | 92 |
| ..RWCRExpr | 96 |
| ..RWCString | 100 |
| ..RWCSubString | 118 |
| ..RWCTokenizer | 122 |
| ..RWDate | 124 |
| ..RWDDEstreambuf | 134 |
| ..RWDiskPageHeap | 139 |
| ..RWDlistCollectables | 142 |
| ..RWDlistCollectablesIterator | 147 |
| ..RWeistream | 150 |
| ..RWeostream | 157 |
| ..RWFactory | 162 |
| ..RWFile | 166 |
| ..RWFileManager | 171 |
| ..RWGBitVec(size) | 173 |
| ..RWGDlist(type) | 177 |
| ..RWGDlistIterator(type) | 182 |
| ..RWGOrderedVector(val) | 185 |
| ..RWGQueue(type) | 190 |
| ..RWGSlist(type) | 192 |
| ..RWGSlistIterator(type) | 196 |
| ..RWGSortedVector(val) | 199 |
| ..RWGStack(type) | 203 |
| ..RWGVector(val) | 205 |
| ..RWHashDictionary | 209 |
| ..RWHashDictionaryIterator | 214 |
| ..rw_hashmap | 216 |
| ..rw_hashmultimap | 223 |
| ..rw_hashmultiset | 229 |
| ..rw_hashset | 235 |
| ..RWHashTable | 241 |
| ..RWHashTableIterator | 246 |
| ..RWIdentityDictionary | 247 |
| ..RWIdentitySet | 249 |
| ..RWInteger | 250 |
| ..RWIterator | 252 |
| ..RWLocale | 253 |
| ..RWLocaleSnapshot | 259 |
| ..RWModel | 262 |
| ..RWModelClient | 264 |
| ..RWOrdered | 265 |
| ..RWOrderedIterator | 269 |
| ..RWpistream | 271 |
| ..RWpostream | 277 |
| ..RWSequenceable | 284 |
| ..RWSet | 285 |
| ..RWSetIterator | 290 |
| ..rw_slist<T> | 291 |
| ..RWSlistCollectables | 297 |
| ..RWSlistCollectablesIterator | 301 |
| ..RWSlistCollectablesQueue | 304 |
| ..RWSlistCollectablesStack | 307 |
| ..RWSortedVector | 310 |
| ..RWTBitVec<size> | 314 |
| ..RWTime | 318 |
| ..RWTimer | 325 |
| ..RWTIsvDlist<T> | 328 |
| ..RWTIsvDlistIterator<T> | 333 |
| ..RWTIsvSlist<T> | 336 |
| ..RWTIsvSlistIterator<T> | 341 |
| ..RWTPtrDeque<T> | 343 |
| ..RWTPtrDlist<T> | 354 |
| ..RWTPtrDlistIterator<T> | 365 |
| ..RWTPtrHashDictionary | 369 |
| ..RWTPtrHashDictionaryIterator | 370 |
| ..RWTPtrHashMap<K,T,H,EQ> | 370 |
| ..RWTPtrHashMapIterator<K,T,H,EQ> | 379 |
| ..RWTPtrHashMultiMap<K,T,H,EQ> | 382 |
| ..RWTPtrHashMultiMapIterator<K,T,H,EQ> | 390 |
| ..RWTPtrHashMultiSet<T,H,EQ> | 393 |
| ..RWTPtrHashMultiSetIterator<T,H,EQ> | 402 |
| ..RWTPtrHashSet<T,H,EQ> | 405 |
| ..RWTPtrHashSetIterator<T,H,EQ> | 413 |
| ..RWTPtrHashTable | 417 |
| ..RWTPtrHashTableIterator | 417 |
| ..RWTPtrMap<K,T,C> | 417 |
| ..RWTPtrMapIterator<K,T,C> | 426 |
| ..RWTPtrMultiMap<K,T,C> | 429 |
| ..RWTPtrMultiMapIterator<K,T,C> | 437 |
| ..RWTPtrMultiSet<T,C> | 441 |
| ..RWTPtrMultiSetIterator<T,C> | 448 |
| ..RWTPtrOrderedVector<T> | 451 |
| ..RWTPtrSet<T,C> | 461 |
| ..RWTPtrSetIterator<T,C> | 469 |
| ..RWTPtrSlist<T> | 472 |
| ..RWTPtrSlistIterator<T> | 482 |
| ..RWTPtrSortedDlist<T,C> | 486 |
| ..RWTPtrSortedDlistIterator<T,C> | 495 |
| ..RWTPtrSortedVector<T,C> | 499 |
| ..RWTPtrVector<T> | 508 |
| ..RWTQueue<T,C> | 511 |
| ..RWTStack<T,C> | 513 |
| ..RWTValDeque<T> | 515 |
| ..RWTValDlist<T> | 526 |
| ..RWTValDlistIterator<T> | 536 |
| ..RWTValHashDictionary | 541 |
| ..RWTValHashDictionaryIterator | 541 |
| ..RWTValHashMap<K,T,H,EQ> | 542 |
| ..RWTValHashMapIterator<K,T,H,EQ> | 549 |
| ..RWTValHashMultiMap<K,T,H,EQ> | 552 |
| ..RWTValHashMultiMapIterator<K,T,H,EQ> | 560 |
| ..RWTValHashMultiSet<T,H,EQ> | 563 |
| ..RWTValHashMultiSetIterator<T,H,EQ> | 571 |
| ..RWTValHashSet<T,H,EQ> | 574 |
| ..RWTValHashSetIterator<T,H,EQ> | 583 |
| ..RWTValHashTable | 586 |
| ..RWTValHashTableIterator | 586 |
| ..RWTValMap<K,T,C> | 586 |
| ..RWTValMapIterator<K,T,C> | 594 |
| ..RWTValMultiMap<K,T,C> | 598 |
| ..RWTValMultiMapIterator<K,T,C> | 606 |
| ..RWTValMultiSet<T,C> | 609 |
| ..RWTValMultiSetIterator<T,C> | 616 |
| ..RWTValOrderedVector<T> | 619 |
| ..RWTValSet<T,C> | 628 |
| ..RWTValSetIterator<T,C> | 636 |
| ..RWTValSlist<T> | 639 |
| ..RWTValSlistIterator<T> | 648 |
| ..RWTValSortedDlist<T,C> | 653 |
| ..RWTValSortedDlistIterator<T,C> | 661 |
| ..RWTValSortedVector<T,C> | 666 |
| ..RWTValVector<T> | 675 |
| ..RWTValVirtualArray<T> | 678 |
| ..RWVirtualPageHeap | 683 |
| ..RWvios | 686 |
| ..RWvistream | 688 |
| ..RWvostream | 693 |
| ..RWWString | 698 |
| ..RWWSubString | 714 |
| ..RWWTokenizer | 718 |
| ..RWXDRistream (Unix only) | 720 |
| ..RWXDRostream (Unix only) | 726 |
| ..RWZone | 732 |
| ..RWZoneSimple | 736 |
A. Alternate Template Class Interfaces | 743 |
| ..RWTPtrDlist<T> | 743 |
| ..RWTPtrDlistIterator<T> | 752 |
| ..RWTPtrHashDictionary<K,V> | 755 |
| ..RWTPtrHashDictionaryIterator<K,V> | 760 |
| ..RWTPtrHashSet<T> | 762 |
| ..RWTPtrHashTable<T> | 766 |
| ..RWTPtrHashTableIterator<T> | 770 |
| ..RWTPtrOrderedVector<T> | 772 |
| ..RWTPtrSlist<T> | 778 |
| ..RWTPtrSlistIterator<T> | 786 |
| ..RWTPtrSortedVector<T> | 789 |
| ..RWTValDlist<T> | 795 |
| ..RWTValDlistIterator<T> | 803 |
| ..RWTValHashDictionary<K,V> | 807 |
| ..RWTValHashDictionaryIterator<K,V> | 811 |
| ..RWTValHashSet<T> | 813 |
| ..RWTValHashTable<T> | 817 |
| ..RWTValHashTableIterator<T> | 821 |
| ..RWTValOrderedVector<T> | 823 |
| ..RWTValSlist<T> | 829 |
| ..RWTValSlistIterator<T> | 837 |
| ..RWTValSortedVector<T> | 840 |


#include <rw/auditbuf.h> #include <iostream.h> RWAuditStreamBuffer buf(arguments) ostream os(&buf); // may be used for ostreams istream is(&buf); // or istreams of any kind
#include <rw/auditbuf.h>
#include <rw/bstream.h>
#include <rw/pstream.h>
#include <iostream.h>
int main() {
RWCollectable ct;
fillCollectable(); // make a collection, somehow
RWAuditStreamBuffer bcounter, pcounter;
RWbostream bcount(&bcounter); //ctor takes streambuf pointer
RWpostream pcount(&pcounter);
//...
bcount << ct;
pcount << ct;
cout << "We just counted " << bcounter
<< " bytes from an RWbostream." << endl;
cout << "We just counted " << pcounter
<< " bytes from an RWpostream." << endl;
return 0;
}
|
typedef void (*RWauditFunction)(unsigned char, void*);
RWAuditStreamBuffer(RWauditFunction=0, void*=0);
RWAuditStreamBuffer(istream&, RWauditFunction=0, void*=0);
RWAuditStreamBuffer(iostream&, RWauditFunction=0, void*=0);
RWAuditStreamBuffer(ostream&, RWauditFunction=0, void*=0);
RWAuditStreamBuffer(streambuf*, RWauditFunction=0, void*=0);
virtual ~RWAuditStreamBuffer();
operator unsigned long();
unsigned long reset(unsigned long value = 0);
#include <iostream.h>
#include <fstream.h>
#include <rw/auditbuf.h>
#include <rw/pstream.h>
#include <rw/cstring.h>
void doCrc (unsigned char c, void* x) {
*(unsigned char*)x ^= c;
}
int main() {
if(1) { // just a block to control variable lifetime
unsigned char check = '\0';
// create an output stream
ofstream op("crc.pst");
|
// create an RWAuditStreamBuffer that will do CRC
RWAuditStreamBuffer crcb(op,doCrc,&check);
// create an RWpostream to put the data through.
RWpostream p(&crcb);
// now send some random stuff to the stream
p << RWCString("The value of Tools.h++ is at least ");
p << (int)4;
p << RWCString(" times that of the next best library!\n") ;
p << RWCString("Pi is about ") << (double)3.14159 << '.';
// finally, save the sum on the stream itself.
p << (unsigned int)check; // alters check, _after_ saving it...
// just for fun, print out some statistics:
cout << "We just saved " << crcb
<< " bytes of data to the file." << endl;
cout << "The checksum for those bytes was " <<check << endl;
} // end of block
// now read the data back in, checking to see if it survived.
unsigned char check = '\0';
// create an instream
ifstream ip("crc.pst");
// create an RWAuditStreamBuffer that will do CRC
RWAuditStreamBuffer crcb(ip,doCrc,&check);
// create an RWpistream to interpret the bytes
RWpistream p(&crcb);
RWCString first, mid1, mid2;
int value;
double pi;
char pnc;
unsigned int savedCRC;
unsigned char matchCRC;
// read in the data. Don\'t read the checksum yet!
p >> first >> value >> mid1 >> mid2 >> pi >> pnc;
// save the checksum
matchCRC = check;
|
// Now it is safe to alter the running checksum by reading in
// the one saved in the file.
p >> savedCRC;
if(savedCRC != matchCRC) {
cout << "Checksum error. Saved CRC: " << savedCRC
<< " built CRC: " << matchCRC << dec << endl;
}
else {
cout << "The message was: " << endl;
cout << first << value << mid1 << mid2 << pi << pnc << endl;
}
// just for fun, print out some statistics:
cout << "We just read " << crcb
<< " bytes of data from the file." << endl;
cout << "The checksum was " << matchCRC << flush;
cout << " and the saved checksum was " << savedCRC << endl;
return 0;
}
|
typedef RWBag Bag; // Smalltalk typedef . #include <rw/rwbag.h> RWBag h;
RWBag(size_t n = RWDEFAULT_CAPACITY);
RWBag(const RWBag& b);
void operator=(const RWBag& b);
RWBoolean operator==(const RWBag& b) const;
virtual void apply(RWapplyCollectable ap, void*);
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
virtual unsigned hash() const;
virtual RWCollectable* insert(RWCollectable* c);
RWCollectable* insertWithOccurrences(RWCollectable* c,size_t n);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
void resize(size_t n = 0);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
#include <rw/rwbag.h> RWBag b; RWBagIterator it(b);
RWBagIterator(const RWBag&);
virtual RWCollectable* operator()();
virtual RWCollectable* findNext(const RWCollectable* target);
virtual RWCollectable* key() const;
virtual void reset();
#include <rw/bench.h> (Abstract base class)
#include <rw/bench.h> /* Benchmark software */ #include <rw/cstring.h> /* Rogue Wave string class */ #include <stdlib.h> |
#include <iostream.h>
#include <rw/ctoken.h>
#include <rw/regexp.h>
// The string to be hashed:
const char* cs = "A multi-character string with lots of words in
it to be parsed out and searched for.";
class TestBrute : public RWBench {
public:
TestBrute() { }
virtual void doLoop(unsigned long n);
virtual void idleLoop(unsigned long n);
virtual void what(ostream& s) const
{ s << "Brute force string search: \n"; }
};
class TestRW : public RWBench {
public:
TestRW() { }
virtual void doLoop(unsigned long n);
virtual void idleLoop(unsigned long n);
virtual void what(ostream& s) const
{ s << "Rogue Wave search: \n"; }
};
main(int argc, char* argv[]){
cout << "Testing string \n\"" << cs << "\"\n";
// Test brute force string search algorithm:
TestBrute other;
other.parse(argc, argv);
other.go();
other.report(cout);
// Test RW searching w/regular expressions:
TestRW rw;
rw.parse(argc, argv);
rw.go();
rw.report(cout);
return 0;
}
|
void TestBrute::doLoop(unsigned long n){
RWCString string(cs);
RWCTokenizer *tokener;
RWCString token;
tokener = new RWCTokenizer(string);
while(n--){
if((token = (*tokener)()).isNull())
{
delete tokener;
tokener = new RWCTokenizer(string);
token = (*tokener)();
}
size_t j = 0;
for(size_t i = 0; i < string.length() && j != token.length();
i++)
{
j = 0;
while((j < token.length()) && (string[i+j]==token[j]))
j++;
}
}
delete tokener;
}
void TestRW::doLoop(unsigned long n){
RWCString string(cs);
RWCTokenizer *tokener;
RWCString token, result;
RWCRegexp re("");
tokener = new RWCTokenizer(string);
while(n--){
if((token = (*tokener)()).isNull())
|
{
delete tokener;
tokener = new RWCTokenizer(string);
token = (*tokener)();
}
re = RWCRegexp(token);
result = string(re); //Do the search!
}
delete tokener;
}
void TestBrute::idleLoop(unsigned long n){
RWCString string(cs); // Subtract out the overhead
RWCTokenizer *tokener;
RWCString token;
tokener = new RWCTokenizer(string);
while(n--){
if((token = (*tokener)()).isNull())
{
delete tokener;
tokener = new RWCTokenizer(string);
token = (*tokener)();
}
}
delete tokener;
}
void TestRW::idleLoop(unsigned long n){
RWCString string(cs); //Subtract out the overhead
RWCTokenizer *tokener;
RWCString token, result;
RWCRegexp re("");
tokener = new RWCTokenizer(string);
while(n--){
if((token = (*tokener)()).isNull())
|
{
delete tokener;
tokener = new RWCTokenizer(string);
token = (*tokener)();
}
re = RWCRegexp(token);
}
delete tokener;
}
|
Testing string "A multi-character string with lots of words in it to be parsed out and searched for." Borland C++ V4.0 Brute force string search: Iterations: 35 Inner loop operations: 1000 Total operations: 35000 Elapsed (user) time: 4.596 Kilo-operations per second: 7.61532 Borland C++ V4.0 Rogue Wave search: Iterations: 53 Inner loop operations: 1000 Total operations: 53000 Elapsed (user) time: 2.824 Kilo-operations per second: 18.7677 |
RWBench(double duration = 5, unsigned long ILO=1000,
const char* machine = 0);
virtual void doLoop(unsigned long N)=0;
double duration() const;
virtual void go();
virtual void idleLoop(unsigned long N);
const char * machine();
virtual void parse(int argc, char* argv[]);
| Argument | Type | Description |
| argv[1] | double | Duration (sec.) |
| argv[2] | unsigned long | No. of inner loops |
| argv[3] | const char* | Machine |
void parse(const char *);
virtual void report(ostream&) const;
double setDuration(double t);
unsigned long setInnerLoops(unsigned long N);
virtual void what(ostream&) const;
void where(ostream&) const;
unsigned long innerLoops() const;
double time() const;
unsigned long outerLoops() const;
double ops() const;
double opsRate() const;
typedef RWBinaryTree SortedCollection; // Smalltalk typedef. #include <rw/bintree.h> RWBinaryTree bt;
RWBinaryTree();
RWBinaryTree(const RWBinaryTree& t);
virtual ~RWBinaryTree();
void operator=(const RWBinaryTree& bt);
void operator+=(const RWCollection ct);
RWBoolean operator<=(const RWBinaryTree& bt) const;
RWBoolean operator==(const RWBinaryTree& bt) const;
virtual void apply(RWapplyCollectable ap, void*);
void balance();
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
virtual unsigned hash() const;
unsigned height() const;
virtual RWCollectable* insert(RWCollectable* c);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&);
virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
// Smalltalk typedef: typedef RWBinaryTreeIterator SortedCollectionIterator; #include <rw/bintree.h> RWBinaryTree bt; RWBinaryTreeIterator iterate(bt);
RWBinaryTreeIterator(const RWBinaryTree&);
virtual RWCollectable* operator()();
virtual RWCollectable* findNext(const RWCollectable* target);
virtual void reset();
virtual RWCollectable* key() const;
#include <rw/bstream.h>
RWbistream bstr(cin); // Construct an RWbistream,
// using cin's streambuf
#include <rw/bstream.h>
#include <fstream.h>
main(){
ifstream fstr("data.dat"); // Open an input file
RWbistream bstr(fstr); // Construct RWbistream from it
int i;
float f;
double d;
bstr >> i; // Restore an int that was stored in binary
bstr >> f >> d; // Restore a float & double
}
END FILE
|
RWbistream(streambuf* s);
RWbistream(istream& str);
virtual RWvistream& operator>>(char& c);
virtual RWvistream& operator>>(wchar_t& wc);
virtual RWvistream& operator>>(double& d);
virtual RWvistream& operator>>(float& f);
virtual RWvistream& operator>>(int& i);
virtual RWvistream& operator>>(long& l);
virtual RWvistream& operator>>(short& s);
virtual RWvistream& operator>>(unsigned char& c);
virtual RWvistream& operator>>(unsigned short& s);
virtual RWvistream& operator>>(unsigned int& i);
virtual RWvistream& operator>>(unsigned long& l);
operator void*();
virtual int get();
virtual RWvistream& get(char& c);
virtual RWvistream& get(wchar_t& wc);
virtual RWvistream& get(unsigned char& c);
virtual RWvistream& get(char* v, size_t N);
virtual RWvistream& get(wchar_t* v, size_t N);
virtual RWvistream& get(double* v, size_t N);
virtual RWvistream& get(float* v, size_t N);
virtual RWvistream& get(int* v, size_t N);
virtual RWvistream& get(long* v, size_t N);
virtual RWvistream& get(short* v, size_t N);
virtual RWvistream& get(unsigned char* v, size_t N);
virtual RWvistream& get(unsigned short* v, size_t N);
virtual RWvistream& get(unsigned int* v, size_t N);
virtual RWvistream& get(unsigned long* v, size_t N);
virtual RWvistream& getString(char* s, size_t N);
virtual RWvistream& getString(wchar_t* ws, size_t N);
#include <rw/bitvec.h> RWBitVec v;
#include <rw/bitvec.h>
#include <rw/rstream.h>
main(){
// Allocate a vector with 20 bits, set to TRUE:
RWBitVec av(20, TRUE);
av(2) = FALSE; // Turn bit 2 off
av.clearBit(7); // Turn bit 7 off
av.setBit(2); // Turn bit 2 back on
for(int i=11; i<=14; i++) av(i) = FALSE;
cout << av << endl; // Print the vector out
}
|
[
1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1
]
|
RWBitVec();
RWBitVec(size_t N);
RWBitVec(size_t N, RWBoolean initVal);
RWBitVec(const RWByte* bp, size_t N);
RWBitVec(const RWBitVec& v);
~RWBitVec();
RWBitVec& operator=(const RWBitVec& v);
RWBitVec& operator=(RWBoolean b);
RWBitVec& operator&=(const RWBitVec& v); RWBitVec& operator^=(const RWBitVec& v); RWBitVec& operator|=(const RWBitVec& v);
RWBitRef operator[](size_t i);
RWBitRef operator()(size_t i);
RWBoolean operator[](size_t i) const;
RWBoolean operator()(size_t i) const;
RWBoolean operator==(const RWBitVec& u) const;
RWBoolean operator!=(const RWBitVec& u) const;
RWBoolean operator==(RWBoolean b) const;
RWBoolean operator!=(RWBoolean b) const;
void clearBit(size_t i);
a(i) = FALSE; a.clearBit(i); const RWByte* data() const;
size_t firstFalse() const;
size_t firstTrue() const;
unsigned hash() const;
RWBoolean isEqual(const RWBitVec& v) const;
size_t length() const;
ostream& printOn(ostream& s) const;
void resize(size_t N);
istream& scanFrom(istream&);
void setBit(size_t i);
a(i) = TRUE; a.setBit(i); RWBoolean testBit(size_t i) const;
operator()(size_t): if( a(i) ) doSomething(); if( a.testBit(i) ) doSomething();
RWBitVec operator!(const RWBitVec& v);
RWBitVec operator&(const RWBitVec&,const RWBitVec&); RWBitVec operator^(const RWBitVec&,const RWBitVec&); RWBitVec operator|(const RWBitVec&,const RWBitVec&);
ostream& operator<<(ostream& s, const RWBitVec& v);
istream& operator>>(istream& s, RWBitVec& v);
RWvostream& operator<<(RWvostream&, const RWBitVec& vec); RWFile& operator<<(RWFile&, const RWBitVec& vec);
RWvistream& operator>>(RWvistream&, RWBitVec& vec); RWFile& operator>>(RWFile&, RWBitVec& vec);
size_t sum(const RWBitVec& v);
#include <rw/bstream.h> // Construct an RWbostream, using cout's streambuf: RWbostream bstr(cout);
#include <rw/bstream.h>
#include <fstream.h>
main(){
ofstream fstr("data.dat"); // Open an output file
RWbostream bstr(fstr); // Construct an RWbostream from it
int i = 5;
float f = 22.1;
double d = -0.05;
bstr << i; // Store an int in binary
bstr << f << d; // Store a float & double
}
|
RWbostream(streambuf* s);
RWbostream(ostream& str);
virtual ~RWvostream();
virtual RWvostream& operator<<(const char* s);
virtual RWvostream& operator<<(const wchar_t* ws);
virtual RWvostream& operator<<(char c);
virtual RWvostream& operator<<(wchar_t wc);
virtual RWvostream& operator<<(unsigned char c);
virtual RWvostream& operator<<(double d);
virtual RWvostream& operator<<(float f);
virtual RWvostream& operator<<(int i);
virtual RWvostream& operator<<(unsigned int i);
virtual RWvostream& operator<<(long l);
virtual RWvostream& operator<<(unsigned long l);
virtual RWvostream& operator<<(short s);
virtual RWvostream& operator<<(unsigned short s);
operator void*(); Inherited via RWvostream from RWvios.
virtual RWvostream& flush();
virtual RWvostream& put(char c);
virtual RWvostream& put(wchar_t wc);
virtual RWvostream& put(unsigned char c);
virtual RWvostream& put(const char* p, size_t N);
virtual RWvostream& put(const wchar_t* p, size_t N);
virtual RWvostream& put(const unsigned char* p, size_t N);
virtual RWvostream& put(const short* p, size_t N);
virtual RWvostream& put(const unsigned short* p, size_t N);
virtual RWvostream& put(const int* p, size_t N);
virtual RWvostream& put(const unsigned int* p, size_t N);
virtual RWvostream& put(const long* p, size_t N);
virtual RWvostream& put(const unsigned long* p, size_t N);
virtual RWvostream& put(const float* p, size_t N);
virtual RWvostream& put(const double* p, size_t N);
virtual RWvostream& putString(const char* p, size_t N);
virtual RWvostream& putString(const char*s, size_t N);
#include <rw/btree.h> RWBTree a;
RWBTree();
RWBTree(const RWBTree& btr);
Public Destructor virtual ~RWBTree();
void operator=(const RWBTree& btr);
RWBoolean operator<=(const RWBTree& btr) const;
RWBoolean operator==(const RWBTree& btr) const;
virtual void apply(RWapplyCollectable ap, void*);
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
virtual unsigned hash() const;
unsigned height() const;
virtual RWCollectable* insert(RWCollectable* c);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
#include <rw/btrdict.h> RWBTreeDictionary a;
RWBTreeDictionary();
RWBoolean operator<=(const RWBTreeDictionary& btr) const;
void applyToKeyAndValue(RWapplyKeyAndValue ap,void*);
RWBinaryTree asBinaryTree(); RWBag asBag() const; RWSet asSet() const; RWOrdered asOrderedCollection() const; RWBinaryTree asSortedCollection() const:
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
RWCollectable*
findKeyAndValue(const RWCollectable* target,
RWCollectable*& v) const;
RWCollectable* findValue(const RWCollectable* target) const;
RWCollectable*
findValue(const RWCollectable* target,
RWCollectable* newValue);
virtual unsigned hash() const;
unsigned height() const;
RWCollectable* insertKeyAndValue(RWCollectable* key,RWCollectable* value);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
RWCollectable*
removeKeyAndValue(const RWCollectable* target,
RWCollectable*& v);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
virtual RWCollection* select(RWtestCollectable testfunc, void* x) const;
virtual RWCollection* select(RWtestCollectablePair testfunc, void* x) const;
RWStringID stringID();
typedef long RWstoredValue ;
typedef int (*RWdiskTreeCompare)(const char*, const char*,
size_t);
#include <rw/disktree.h>
#include <rw/filemgr.h>
RWFileManager fm("filename.dat");
RWBTreeOnDisk bt(fm);
enum styleMode {V6Style, V5Style};
| V6Style | Initialize a new tree using V6.X style trees. This is the default. |
| V5Style | Initialize a new tree using V5.X style trees. In this case, the key length is fixed at 16 bytes. |
enum createMode {autoCreate, create};
| autoCreate | Look in the location given by the constructor argument start for the root node. If valid, use it. Otherwise, allocate a new tree. This is the default. |
| create | Forces the creation of a new tree. The argument start is ignored. |
RWBTreeOnDisk(RWFileManager& f,
unsigned nbuf = 10,
createMode omode = autoCreate,
unsigned keylen = 16,
RWBoolean ignoreNull = FALSE,
RWoffset start = RWNIL,
styleMode smode = V6Style,
unsigned halfOrder = 10,
unsigned minFill = 10);
| f | The file in which the B-tree is to be managed. This is the only required parameter. |
| nbuf | The maximum number of nodes that can be cached in memory. |
| omode | Determines whether to force the creation of a new tree or whether to attempt to open an existing tree for update (the default). |
| keylen | The length of a key in bytes. Ignored when opening an existing tree. |
| ignoreNull | Controls whether to allow embedded nulls in keys. If FALSE (the default), then keys end with a terminating null. If TRUE, then all keylen bytes are significant. Ignored when opening an existing tree. |
| start | Where to find the root node. If set to RWNIL (the default), then uses the value returned by the RWFileManager's start() member function. Ignored when creating a new tree. |
| smode | Sets the type of B-tree to create, allowing backwards compatibility (see above). The default specifies new V6.X style B-trees. Ignored when opening an existing tree. |
| halfOrder | One half the order of the B-tree (that is, one half the number of entries in a node). Ignored when opening an existing tree. |
| minFill | The minimum number of entries allowed in a node (must be less than or equal to halfOrder). Ignored when opening an existing tree. |
void applyToKeyAndValue((*ap)(const char*,RWstoredValue), void* x);
void yourApplyFunction(const char* ky,
RWstoredValue val,void* x);
RWoffset baseLocation() const;
unsigned cacheCount() const;
unsigned cacheCount(unsigned newcount);
void clear();
RWBoolean contains(const char* ky) const;
size_t entries();
RWoffset extraLocation(RWoffset newlocation);
RWBoolean findKey( const char* ky, RWCString& foundKy)const ;
RWBoolean
findKeyAndValue( const char* ky,
RWCString& foundKy,
RWStoredValue& foundVal)const ;
RWstoredValue findValue(const char* ky)const;
int height();
int insertKeyAndValue(const char* ky,RWstoredValue v);
unsigned keyLength() const;
unsigned minOrder()const;
unsigned nodeSize() const;
unsigned order()const;
RWBoolean isEmpty() const;
void remove(const char* ky);
RWBoolean
replaceValue(const RWCString& key,
const RWstoredValue newval,
RWstoredValue& oldVal);
RWdiskTreeCompare setComparison(RWdiskTreeCompare fun);
int yourFun(const char* key1, const char* key2, size_t N);
#include <rw/bufpage.h> (Abstract base class )
RWBufferedPageHeap(unsigned pgsize, unsigned nbufs=10);
virtual RWBoolean swapIn(RWHandle h, void* buf) = 0; virtual RWBoolean swapOut(RWHandle, h void* buf) = 0;
virtual RWHandle allocate() = 0;
virtual ~RWBufferedPageHeap();
RWBoolean isValid();
virtual void deallocate(RWHandle h);
virtual void dirty(RWHandle h);
virtual void* lock(RWHandle h);
virtual void unlock(RWHandle h);
#include <rw/cacheman.h>
RWFile f("file.dat"); // Construct a file
RWCacheManager(&f, 100); // Cache 100 byte blocks to file.dat
#include <rw/cacheman.h>
#include <rw/rwfile.h>
struct Record {
int i;
float f;
char str[15];
};
main(){
RWoffset loc;
RWFile file("file.dat"); // Construct a file
// Construct a cache, using 20 slots for struct Record:
RWCacheManager cache(&file, sizeof(Record), 20);
Record r;
// ...
cache.write(loc, &r);
// ...
cache.read(loc, &r);
}
|
RWCacheManager(RWFile* file, unsigned blocksz,
unsigned mxblks = 10);
~RWCacheManager();
RWBoolean flush();
void invalidate();
RWBoolean read(RWoffset locn, void* dat);
RWBoolean write(RWoffset locn, void* dat);
#include <rw/winstrea.h> #include <iostream.h> iostream str( new RWCLIPstreambuf() );
//Instructions: compile as a Windows program.
//Run this program, then using your favorite text editor or word
//processor, select paste and see the result!
#include <rw/winstrea.h>
#include <stdlib.h>
#include <iostream.h>
#include <windows.h>
void postToClipboard(HWND owner);
main()
{
postToClipboard(NULL);
return 0;
}
// PASS YOUR WINDOW HANDLE TO THIS FUNCTION THEN PASS YOUR VALUES
// TO THE CLIPBOARD USING ostr.
void postToClipboard(HWND owner)
{
//Build the clipstream buffer on the heap
RWCLIPstreambuf* buf = new
RWCLIPstreambuf();
ostream ostr(buf);
double d = 12.34;
ostr << "Some text to be exchanged through the clipboard.\n";
ostr << "Might as well add a double: " << d << endl;
ostr.put('\0'); // Include the terminating null
// Lock the streambuf, get its handle:
HANDLE hMem = buf->str();
OpenClipboard(owner);
|
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
// Don't delete the buffer!. Windows is now responsible for it.
}
|
RWCLIPstreambuf();
RWCLIPstreambuf(HANDLE hMem);
~RWCLIPstreambuf();
HANDLE str();
typedef RWCollectable Object; // Smalltalk typedef #include <rw/collect.h>
virtual ~RWCollectable();
virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable*) const;
virtual unsigned hash() const;
virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* t) const;
virtual RWCollectable* newSpecies() const;
virtual void restoreGuts(RWFile&);
virtual void restoreGuts(RWvistream&);
virtual void saveGuts(RWFile&) const;
virtual void saveGuts(RWvostream&) const;
RWStringID stringID();
RWspace recursiveStoreSize() const;
RWFile& operator<<(RWFile&, const RWCollectable&);
static RWClassID classID(const RWStringID& name);
static RWClassID classIsA();
static RWBoolean isAtom(RWClassID id);
static RWspace nilStoreSize();
RWvostream& operator<<(RWvostream&, const RWCollectable& obj); RWFile& operator<<(RWFile&, const RWCollectable& obj);
RWvistream& operator>>(RWvistream&, RWCollectable& obj); RWFile& operator>>(RWFile&, RWCollectable& obj);
RWvistream& operator>>(RWvistream&, RWCollectable*& obj); RWFile& operator>>(RWFile&, RWCollectable*& obj);
#include <rw/collass.h>
RWCollectableAssociation(); RWCollectableAssociation(RWCollectable* k, RWCollectable* v);
virtual ~RWCollectableAssociation(); virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable* c) const;
virtual unsigned hash() const;
key()->hash(). virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* c) const;
key()->isEqual(c). RWCollectable* key() const;
RWCollectable* value() const;
RWCollectable* value(RWCollectable* ct);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
typedef RWCollectableDate Date; // Smalltalk typedef #include <rw/colldate.h> RWCollectableDate d;
RWCollectableDate();
RWCollectableDate(unsigned long julianDate);
RWCollectableDate(unsigned day, unsigned year);
RWCollectableDate(unsigned day, unsigned month, unsigned year);
RWCollectableDate(unsigned day, const char* mon,
unsigned year,const RWLocale&
locale = RWLocale::global());
RWCollectableDate(istream& s, const RWLocale& locale =
RWLocale::global());
RWCollectableDate(const RWCString& str,const RWLocale&
locale = RWLocale::global());
RWCollectableDate(const RWTime& t, const RWZone& zone =
RWZone::local());
RWCollectableDate(const struct tm* tmb);
RWCollectableDate(const RWDate& d);
virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable* c) const;
RWDate::compareTo. virtual unsigned hash() const;
RWDate::hash(). virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* t) const;
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
typedef RWCollectableInt Integer; // Smalltalk typedef #include <rw/collint.h> RWCollectableInt i;
RWCollectableInt();
RWCollectableInt(int i);
virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable* c) const;
virtual unsigned hash() const;
virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* c) const;
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
typedef RWCollectableString String; // Smalltalk typedef #include <rw/collstr.h> RWCollectableString c;
RWCollectableString();
RWCollectableString(const RWCString& s);
RWCollectableString(const char* c);
RWCollectableString(const RWCSubString&);
RWCollectableString(char c, size_t N);
virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable* c) const;
virtual unsigned hash() const;
virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* c) const;
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
typedef RWCollectableTime ; // Smalltalk typedef #include <rw/colltime.h> RWCollectableTime t;
RWCollectableTime();
RWCollectableTime(unsigned long s);
RWCollectableTime(unsigned hour, unsigned minute,
unsigned sec = 0,const RWZone&
zone = RWZone::local());
RWCollectableTime(const RWDate& day, unsigned hour=0,
unsigned minute=0, unsigned sec = 0,
const RWZone& zone = RWZone::local());
RWCollectableTime(const RWDate& day, const RWCString& str,
const RWZone& zone = RWZone::local(),
const RWLocale& locale = RWLocale::global());
RWCollectableTime(const struct tm* tmb,
const RWZone& zone = RWZone::local());
virtual RWspace binaryStoreSize() const;
virtual int compareTo(const RWCollectable* c) const;
RWTime::compareTo. virtual unsigned hash() const;
RWTime::hash(). virtual RWClassID isA() const;
virtual RWBoolean isEqual(const RWCollectable* c) const;
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
#include <rw/colclass.h> typedef RWCollection Collection; // Smalltalk typedef
void operator+=(const RWCollection&); void operator-=(const RWCollection&);
virtual ~RWCollection();
virtual void apply(RWapplyCollectable ap, void*) = 0;
void yourApplyFunction(RWCollectable* ctp, void*);
RWBag asBag() const; RWSet asSet() const; RWOrdered asOrderedCollection() const; RWBinaryTree asSortedCollection() const;
virtual RWspace binaryStoreSize() const;
virtual void clear() = 0;
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const = 0;
virtual RWCollectable* find(const RWCollectable* target) const = 0;
virtual unsigned hash() const;
virtual RWCollectable* insert(RWCollectable* e) = 0;
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const = 0;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* t) const = 0;
virtual void restoreGuts(RWFile&);
RWFile& operator>>(RWFile&, RWCollectable*&);
virtual void restoreGuts(RWvistream&);
RWvistream& operator>>(RWvistream&, RWCollectable*&);
RWCollectable* remove(const RWCollectable* target) = 0;
virtual void removeAndDestroy(const RWCollectable* target);
RWCollection* select(RWtestCollectable tst, void* x) const;
virtual void saveGuts(RWFile&);
RWFile& operator<<(RWFile&, const RWCollectable&);
virtual void saveGuts(RWvostream&);
RWvostream& operator<<(RWvostream&, const RWCollectable&);
#include <rw/regexp.h>
RWCRegexp re(".*\\.doc");// Matches filename with suffix ".doc"
+ * ? . [ ] ^ $
| \b | backspace |
| \e | ESC (escape) |
| \f | formfeed |
| \n | newline |
| \r | carriage return |
| \t | tab |
| \xddd | the literal hex number 0xdd |
| \ddd | the literal octal number ddd |
| \^C | Control code. E.g. \^D is "control-D" |
#include <rw/regexp.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
main(){
RWCString aString("Hark! Hark! the lark");
// A regular expression matching any lower-case word
// starting with "l":
RWCRegexp reg("l[a-z]*");
cout << aString(reg) << endl; // Prints "lark"
}
|
RWCRegexp(const char* pat);
RWCRegexp(const RWCRegexp& r);
~RWCRegexp();
RWCRegexp& operator=(const RWCRegexp&);
RWCRegexp& operator=(const char* pat);
size_t index(const RWCString& str,size_t* len, size_t start=0) const;
statVal status();
| statVal | Meaning |
| RWCRegexp::OK | No errors |
| RWCRegexp::ILLEGAL | Pattern was illegal |
| RWCRegexp::TOOLONG | 1 Pattern exceeded maximum length |
#include <rw/re.h>
RWCRExpr re(".*\\.doc"); // Matches filename with suffix ".doc"
+ * ? . [ ] ^ $ ( ) { } | \
#include <rw/re.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
main(){
RWCString aString("Hark! Hark! the lark");
// A regular expression matching any lowercase word or end of a
//word starting with "l":
RWCRExpr re("l[a-z]*");
cout << aString(re) << endl; // Prints "lark"
}
|
RWCRExpr(const char* pat); RWCRExpr(const RWCString& pat);
RWCRExpr(const RWCRExpr& r);
RWCRExpr();
~RWCRExpr();
RWCRExpr& operator=(const RWCRExpr& r);
RWCRExpr& operator=(const char* pat); RWCRExpr& operator=(const RWCString& pat);
size_t
index(const RWCString& str, size_t* len = NULL,
size_t start=0) const;
statusType status() const;
| statusType | Meaning |
| RWCRExpr::OK | No errors |
| RWCRExpr::NOT_SUPPORTED | POSIX.2 feature not yet supported. |
| RWCRExpr::NO_MATCH | Tried to find a match but failed |
| RWCRExpr::BAD_PATTERN | Pattern was illegal |
| RWCRExpr::BAD_COLLATING_ELEMENT | Invalid collating element referenced |
| RWCRExpr::BAD_CHAR_CLASS_TYPE | Invalid character class type referenced |
| RWCRExpr::TRAILING_BACKSLASH | Trailing \ in pattern |
| RWCRExpr::UNMATCHED_BRACKET | [] imbalance |
| RWCRExpr::UNMATCHED_PARENTHESIS | () imbalance |
| RWCRExpr::UNMATCHED_BRACE | {} imbalance |
| RWCRExpr::BAD_BRACE | Content of {} invalid. |
| statusType | Meaning |
|---|---|
| RWCRExpr::BAD_CHAR_RANGE | Invalid endpoint in [a-z] expression |
| RWCRExpr::OUT_OF_MEMORY | Out of memory |
| RWCRExpr::BAD_REPEAT | ?,* or + not preceded by valid regular expression |
#include <rw/cstring.h> RWCString a;
#include <rw/re.h>
#include <rw/rstream.h>
main(){
RWCString a("There is no joy in Beantown.");
cout << a << endl << "becomes...." << endl;
RWCRExpr re("[A-Z][a-z]*town"); // Any capitalized "town"
a.replace(re, "Redmond");
cout << a << endl;
}
|
There is no joy in Redmond. |
enum RWCString::caseCompare { exact, ignoreCase }
enum RWCString::scopeType { one, all }
RWCString();
RWCString(const char* cs);
RWCString(const char* cs, size_t N);
RWCString(RWSize_T ic);
RWCString(const RWCString& str);
RWCString(const RWCSubString& ss);
RWCString(char c);
RWCString(char c, size_t N);
operator const char*() const;
RWCString& operator=(const char* cs);
RWCString& operator+=(const char* cs);
RWCString& operator+=(const RWCString& str);
char& operator[](size_t i); char operator[](size_t i) const;
char& operator()(size_t i); char operator()(size_t i) const;
RWCSubString operator()(size_t start, size_t len); const RWCSubString operator()(size_t start, size_t len) const;
RWCSubString operator()(const RWCRExpr& re, size_t start=0); const RWCSubString operator()(const RWCRExpr& re, size_t start=0) const; RWCSubString operator()(const RWCRegexp& re, size_t start=0); const RWCSubString operator()(const RWCRegexp& re, size_t start=0) const;
RWCString& append(const char* cs);
RWCString& append(const char* cs, size_t N);
RWCString& append(char c, size_t N);
RWCString& append(const RWCString& cstr);
RWCString& append(const RWCString& cstr, size_t N);
size_t binaryStoreSize() const;
RWFile& operator<<(RWFile&, const RWCString&);
size_t capacity() const;
size_t capacity(size_t capac);
int collate(const char* str) const; int collate(const RWCString& str) const;
int
compareTo(const char* str, caseCompare = RWCString::exact) const;
int
compareTo(const RWCString& str,
caseCompare = RWCString::exact) const;
RWBoolean
contains(const char* str, caseCompare = RWCString::exact)
const;
RWBoolean
contains(const RWCString& cs,
caseCompare = RWCString::exact) const;
const char* data() const;
size_t first(char c) const;
size_t first(char c, size_t) const;
size_t first(const char* str) const;
size_t first(const char* str, size_t N) const;
unsigned hash(caseCompare = RWCString::exact) const;
size_t
index(const char* pat,size_t i=0,
caseCompare = RWCString::exact) const;
size_t
index(const RWCString& pat,size_t i=0,
caseCompare = RWCString::exact) const;
size_t
index(const char* pat, size_t patlen,size_t i,
caseCompare cmp) const;
size_t
index(const RWCString& pat, size_t patlen,size_t i,
caseCompare cmp) const;
size_t index(const RWCRExpr& re, size_t i=0) const; size_t index(const RWCRegexp& re, size_t i=0) const;
size_t index(const RWCRExpr& re,size_t* ext,size_t i=0) const; size_t index(const RWCRegexp& re,size_t* ext,size_t i=0) const;
RWCString& insert(size_t pos, const char* cs);
RWCString& insert(size_t pos, const char* cs, size_t N);
RWCString& insert(size_t pos, const RWCString& str);
RWCString& insert(size_t pos, const RWCString& str, size_t N);
RWBoolean isAscii() const;
RWBoolean isNull() const;
size_t last(char c) const;
size_t last(char c, size_t N) const;
size_t length() const;
RWCSubString match(const RWCRExpr& re, size_t start=0); const RWCSubString match(const RWCRExpr& re, size_t start=0) const;
size_t mbLength() const;
RWCString& prepend(const char* cs);
RWCString& prepend(const char* cs, size_t N);
RWCString& prepend(char c, size_t N);
RWCString& prepend(const RWCString& str);
RWCString& prepend(const RWCString& cstr, size_t N);
istream& readFile(istream& s);
istream& readLine(istream& s, RWBoolean skipWhite = TRUE);
istream& readString(istream& s);
istream& readToDelim(istream& s, char delim='\n');
istream& readToken(istream& s);
RWCString& remove(size_t pos);
RWCString& remove(size_t pos, size_t N);
RWCString& replace(size_t pos, size_t N, const char* cs);
RWCString& replace(size_t pos, size_t N1,const char* cs, size_t N2);
RWCString& replace(size_t pos, size_t N, const RWCString& str);
RWCString& replace(size_t pos, size_t N1,const RWCString& str, size_t N2);
replace(const RWCRExpr& pattern, const char* replacement,
scopeType scope=one);
replace(const RWCRExpr& pattern,
const RWCString& replacement,scopeType scope=one);
RWCString s("hahahohoheehee");
s.replace(RWCRExpr("(ho)+","HAR"); // s == "hahaHARheehee"
void resize(size_t n);
RWCSubString strip(stripType s = RWCString::trailing, char c = ' '); const RWCSubString strip(stripType s = RWCString::trailing, char c = ' ') const;
| stripType | Meaning |
| leading | Remove characters at beginning |
| trailing | Remove characters at end |
| both | Remove characters at both ends |
RWCSubString
subString(const char* cs, size_t start=0,
caseCompare = RWCString::exact);
const RWCSubString
subString(const char* cs, size_t start=0,
caseCompare = RWCString::exact) const;
void toLower();
void toUpper();
static unsigned hash(const RWCString& str);
str.hash(RWCString::exact). static size_t initialCapacity(size_t ic = 15);
static size_t maxWaste(size_t mw = 15);
static size_t resizeIncrement(size_t ri = 16);
RWBoolean operator==(const RWCString&, const char* ); RWBoolean operator==(const char*, const RWCString&); RWBoolean operator==(const RWCString&, const RWCString&); RWBoolean operator!=(const RWCString&, const char* ); RWBoolean
operator!=(const char*, const RWCString&); RWBoolean operator!=(const RWCString&, const RWCString&);
RWBoolean operator< (const RWCString&, const char* ); RWBoolean operator< (const char*, const RWCString&); RWBoolean operator< (const RWCString&, const RWCString&); RWBoolean operator> (const RWCString&, const char* ); RWBoolean operator> (const char*, const RWCString&); RWBoolean operator> (const RWCString&, const RWCString&); RWBoolean operator<=(const RWCString&, const char* ); RWBoolean operator<=(const char*, const RWCString&); RWBoolean operator<=(const RWCString&, const RWCString&); RWBoolean operator>=(const RWCString&, const char* ); RWBoolean operator>=(const char*, const RWCString&); RWBoolean operator>=(const RWCString&, const RWCString&);
RWCString operator+(const RWCString&, const RWCString&); RWCString operator+(const char*, const RWCString&); RWCString operator+(const RWCString&, const char* );
ostream& operator<<(ostream& s, const RWCString&);
istream& operator>>(istream& s, RWCString& str);
RWvostream& operator<<(RWvostream&, const RWCString& str); RWFile& operator<<(RWFile&, const RWCString& str);
RWvistream& operator>>(RWvistream&, RWCString& str); RWFile& operator>>(RWFile&, RWCString& str);
RWCString strXForm(const RWCString&);
RWCString toLower(const RWCString& str);
RWCString toUpper(const RWCString& str);
#include <rw/cstring.h>
RWCString s("test string");
s(6,3); // "tri"
#include <rw/cstring.h>
#include <rw/rstream.h>
main(){
RWCString s("What I tell you is true.");
// Create a substring and use it as an lvalue:
s(19, 0) = "three times ";
cout << s << endl;
}
|
What I tell you is three times true. |
RWCSubString& operator=(const RWCString&);
RWCString a; RWCString b; ... b(2, 3) = a;
RWCSubString& operator=(const RWCSubString&);
RWCString a; RWCString b; ... b(2, 3) = a(5,5);
operator=(const char*);
RWCString str("Mary had a lamb");
char dat[] = "Perrier";
str(11,4) = dat; // "Mary had a Perrier"
char& operator[](size_t i); char operator[](size_t i) const;
char& operator()(size_t i); char operator()(size_t i) const;
RWBoolean isNull() const;
size_t length() const;
RWBoolean operator!() const;
size_t start() const;
void toLower();
void toUpper();
RWBoolean operator==(const RWCSubString&, const RWCSubString&); RWBoolean operator==(const RWCString&, const RWCSubString&); RWBoolean operator==(const RWCSubString&, const RWCString& ); RWBoolean operator==(const char*, const RWCSubString&); RWBoolean operator==(const RWCSubString&, const char* );
RWBoolean operator!=(const RWCString&, const RWCString& ); RWBoolean operator!=(const RWCString&, const RWCSubString&); RWBoolean operator!=(const RWCSubString&, const RWCString& ); RWBoolean operator!=(const char*, const RWCString& ); RWBoolean operator!=(const RWCString&, const char* );
#include <rw/ctoken.h>
RWCString str("a string of tokens");
RWCTokenizer(str); // Lex the above string
#include <rw/ctoken.h>
#include <rw/rstream.h>
main(){
RWCString a("Something is rotten in the state of Denmark");
RWCTokenizer next(a); // Tokenize the string a
RWCString token; // Will receive each token
// Advance until the null string is returned:
while (!(token=next()).isNull())
cout << token << "\n";
}
|
Something
is
rotten
in
the
state
of
Denmark
|
RWCTokenizer(const RWCString& s);
RWCSubString operator();
RWCSubString operator()(const char* s);
RWCSubString operator()(const char* s,size_t num);
#include <rw/rwdate.h>RWDate a; // Construct today's date
RWDate v[5000]; // Figures out the current date 5000 times
// Figures out the current date just once: RWTValOrderedVector<RWDate> v(5000, RWDate());
#include <rw/rwdate.h>
#include <rw/rstream.h>
main(){
// Today's date
RWDate d;
// Last Sunday's date:
RWDate lastSunday = d.previous("Sunday");
cout << d << endl << lastSunday << endl;
}
|
03/22/91 03/17/91 |
RWDate();
RWDate(const RWDate&);
RWDate(unsigned day, unsigned year);
RWDate(unsigned day, unsigned month, unsigned year);
RWDate(unsigned day, const char* mon, unsigned year,
const RWLocale& locale = RWLocale::global());
RWDate(istream& s,const RWLocale& locale =
RWLocale::global());
RWDate(const RWCString& str,
const RWLocale& locale = RWLocale::global());
RWDate(const RWTime& t,
const RWZone& zone = RWZone::local());
RWDate(const struct tm*);
RWDate(unsigned long jd);
RWDate& operator=(const RWDate&);
RWDate operator++();
RWDate operator--();
RWDate operator++(int);
RWDate operator--(int);
RWDate& operator+=(unsigned long s);
RWDate& operator-=(unsigned long s);
RWCString
asString(char format = 'x',
const RWLocale& = RWLocale::global()) const;
RWCString
asString(const char* format,
const RWLocale& = RWLocale::global()) const;
RWBoolean between(const RWDate& a, const RWDate& b) const;
size_t binaryStoreSize() const;
RWFile& operator<<(RWFile&, const RWDate&); int compareTo(const RWDate* d) const;
unsigned day() const;
unsigned dayOfMonth() const;
void extract(struct tm*) const;
unsigned firstDayOfMonth() const;
unsigned firstDayOfMonth(unsigned month) const;
unsigned hash() const;
RWBoolean isValid() const;
unsigned long julian() const;
void julian(unsigned long j);
RWBoolean leap() const;
RWDate max(const RWDate& t) const;
RWDate min(const RWDate& t) const;
unsigned month() const;
RWCString monthName(const RWLocale& = RWLocale::global()) const;
RWDate next(unsigned dayNum) const;
RWDate
next(const char* dayName,
const RWLocale& = RWLocale::global()) const;
RWDate previous(unsigned dayNum) const;
RWDate
previous(const char* dayName,
const RWLocale& = RWLocale::global()) const;
RWCString weekDayName(const RWLocale& = RWLocale::global()) const;
unsigned weekDay() const;
unsigned year() const;
static unsigned
dayOfWeek(const char* dayName,
const RWLocale& = RWLocale::global());
static unsigned daysInMonthYear(unsigned month, unsigned year);
static unsigned daysInYear(unsigned year);
static RWBoolean
dayWithinMonth(unsigned monthNum, unsigned dayNum,
unsigned year);
static unsigned hash(const RWDate& d);
static unsigned
indexOfMonth(const char* monthName,
const RWLocale& = RWLocale::global());
static unsigned long jday(unsigned mon, unsigned day, unsigned year);
static RWCString
nameOfMonth(unsigned monNum,
const RWLocale& = RWLocale::global());
static RWBoolean leapYear(unsigned year);
static RWDate now();
static RWCString
weekDayName(unsigned dayNum,
const RWLocale& = RWLocale::global());
RWBoolean operator<(const RWDate& d1, const RWDate& d2);
RWBoolean operator<=(const RWDate& d1, const RWDate& d2);
RWBoolean operator>(const RWDate& d1, const RWDate& d2);
RWBoolean operator>=(const RWDate& d1, const RWDate& d2);
RWBoolean operator==(const RWDate& d1, const RWDate& d2);
RWBoolean operator!=(const RWDate& d1, const RWDate& d2);
RWDate operator+(const RWDate& d, unsigned long s); RWDate operator+(unsigned long s, const RWDate& d);
unsigned long operator-(const RWDate& d1, const RWDate& d2);
RWDate operator-(const RWDate& d, unsigned long s);
ostream& operator<<(ostream& s, const RWDate& d);
istream& operator>>(istream& s, RWDate& t);
RWvostream& operator<<(RWvostream&, const RWDate& date); RWFile& operator<<(RWFile&, const RWDate& date);
RWvistream& operator>>(RWvistream&, RWDate& date); RWFile& operator>>(RWFile&, RWDate& date);
#include <rw/winstrea.h> #include <iostream.h> iostream str( new RWDDEstreambuf(CF_TEXT, TRUE, TRUE, TRUE) ) ;
#include <rw/winstrea.h>
#include <iostream.h>
#include <windows.h>
#include <dde.h>
BOOL
postToDDE(HWND hwndServer, HWND hwndClient) {
RWDDEstreambuf* buf =
new RWDDEstreambuf(CF_TEXT, TRUE, TRUE, TRUE);
ostream ostr(buf);
double d = 12.34;
ostr << "Some text to be exchanged through the DDE.\n";
ostr << "The double you requested is: " << d << endl;
ostr.put(0);// Include the terminating null
// Lock the streambuf, get its handle:
HANDLE hMem = buf->str();
// Get an identifying atom:
ATOM aItem = GlobalAddAtom("YourData");
if(!PostMessage(hwndClient, WM_DDE_DATA, hwndServer,
MAKELONG(hMem, aItem))){
// Whoops! The message post failed, perhaps because
// the client terminated. Now we are responsible
// for deallocating the memory:
if( hMem != NULL )
GlobalFree(hMem);
GlobalDeleteAtom(aItem);
return FALSE;
}
return TRUE;
}
|
RWDDEstreambuf(WORD cfFormat = CF_TEXT,
BOOL fResponse = TRUE
BOOL fAckReq = TRUE
BOOL fRelease = TRUE);
RWDDEstreambuf(HANDLE hMem);
~RWDDEstreambuf();
BOOL ackReq() const;
WORD format() const;
BOOL release() const;
BOOL response() const;
HANDLE str();
#include <rw/diskpage.h>
unsigned nbufs;
unsigned pagesize;
RWDiskPageHeap heap("filename", nbufs, pagesize) ;
#include <rw/diskpage.h>
#include <rw/rstream.h>
struct Node {
int key;
RWHandlenext;
};
RWHandle head = 0;
const int N = 100; // Exercise 100 Nodes
main() {
// Construct a disk-based page heap with page size equal
// to the size of Node and with 10 buffers:
RWDiskPageHeap heap(0, 10, sizeof(Node));
// Build the linked list:
for (int i=0; i<N; i++){
RWHandle h = heap.allocate();
Node* newNode = (Node*)heap.lock(h);
newNode->key = i;
newNode->next = head;
head = h;
heap.dirty(h);
heap.unlock(h);
}
// Now walk the list:
unsigned count = 0;
RWHandle nodeHandle = head;
while(nodeHandle){
Node* node = (Node*)heap.lock(nodeHandle);
RWHandle nextHandle = node->next;
heap.unlock(nodeHandle);
heap.deallocate(nodeHandle);
|
nodeHandle = nextHandle;
count++;
}
cout << "List with " << count << " nodes walked.\n";
return 0;
}
|
List with 100 nodes walked. |
RWDiskPageHeap(const char* filename = 0,
unsigned nbufs = 10,
unsigned pgsize = 512);
virtual ~RWDiskPageHeap();
virtual RWHandle allocate();
virtual void deallocate(RWHandle h);
virtual void dirty(RWHandle h);
RWBoolean isValid() const;
virtual void* lock(RWHandle h);
virtual void unlock(RWHandle h);
#include <rw/dlistcol.h> RWDlistCollectables a;
RWDlistCollectables();
RWDlistCollectables (RWCollectable* a);
RWBoolean operator==(const RWDlistCollectables& d) const;
virtual Collectable* append(RWCollectable*);
virtual void apply(RWapplyCollectable ap, void*);
virtual RWCollectable*& at(size_t i); virtual const RWCollectable* at(size_t i) const;
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
RWBoolean containsReference(const RWCollectable* e) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
RWCollectable* findReference(const RWCollectable* e) const;
virtual RWCollectable* first() const;
RWCollectable* get();
virtual unsigned hash() const;
virtual size_t index(const RWCollectable* c) const;
virtual RWCollectable* insert(RWCollectable* c);
void insertAt(size_t indx, RWCollectable* e);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWCollectable* last() const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
size_t occurrencesOfReference(const RWCollectable* e) const;
virtual RWCollectable* prepend(RWCollectable*);
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
RWCollectable* removeReference(const RWCollectable* e);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
RWStringID stringID();
#include <rw/dlistcol.h> RWDlistCollectables d; RWDlistCollectablesIterator it(d) ;
RWDlistCollectablesIterator (RWDlistCollectables& d);
virtual RWCollectable* operator()();
void operator++();
void operator--();
void operator+=(size_t n);
void operator-=(size_t n);
RWBoolean atFirst() const;
RWBoolean atLast() const;
virtual RWCollectable* findNext(const RWCollectable* target);
RWCollectable* findNextReference(const RWCollectable* e);
RWCollectable* insertAfterPoint(RWCollectable* a);
virtual RWCollectable* key() const;
RWCollectable* remove();
RWCollectable* removeNext(const RWCollectable* target);
RWCollectable* removeNextReference(const RWCollectable* e);
virtual void reset();
void toFirst();
void toLast();
#include <rw/estream.h>
RWeistream estr(cin); // Construct an RWeistream,
// using cin's streambuf
#include <rw/estream.h>
#include <fstream.h>
main()
{
ifstream fstr("data.dat"); // Open an input file
RWeistream estr(fstr); // Construct an RWeistream from it
// (For DOS: RWeistream estr(fstr, ios::binary)
int i;
float f;
double d;
estr >> i; // Restore an int that was stored in binary,
// without regard to size or endian format.
estr >> f >> d; // Restore a float & double without regard to
// endian formats.
}
|
RWeistream(streambuf* s);
RWeistream(istream& str);
virtual int get(); virtual RWvistream& get(char& c); virtual RWvistream& get(unsigned char& c); virtual RWvistream& get(char* v, size_t N); virtual RWvistream& get(unsigned char* v, size_t N);
virtual RWvistream& get(wchar_t& wc);
virtual RWvistream& get(wchar_t* v, size_t N);
virtual RWvistream& get(double* v, size_t N);
virtual RWvistream& get(float* v, size_t N);
virtual RWvistream& get(int* v, size_t N);
virtual RWvistream& get(long* v, size_t N);
virtual RWvistream& get(short* v, size_t N);
virtual RWvistream& get(unsigned short* v, size_t N);
virtual RWvistream& get(unsigned int* v, size_t N);
virtual RWvistream& get(unsigned long* v, size_t N);
virtual RWvistream& getString(char* s, size_t N);
virtual RWvistream& operator>>(char& c);
virtual RWvistream& operator>>(wchar_t& wc);
virtual RWvistream& operator>>(double& d);
virtual RWvistream& operator>>(float& f);
virtual RWvistream& operator>>(int& i);
virtual RWvistream& operator>>(long& l);
virtual RWvistream& operator>>(short& s);
virtual RWvistream& operator>>(unsigned char& c);
virtual RWvistream& operator>>(unsigned short& s);
virtual RWvistream& operator>>(unsigned int& i);
virtual RWvistream& operator>>(unsigned long& l);
RWeostream::EndianstreamEndian();
size_t streamSizeofInt();
size_t streamSizeofLong();
size_t streamSizeofShort();
size_t streamSizeofSizeT();
size_t streamSizeofWchar();
. RWbostream . RWvostream . RWvios
#include <rw/estream.h> // Construct an RWeostream that uses cout's streambuf, // and writes out values in little-endian format: RWeostream estr(cout, RWeostream::LittleEndian);
#include <rw/estream.h>
#include <fstream.h>
main()
{
ofstream fstr("data.dat"); // Open an output file
RWeostream estr(fstr); // Construct an RWeostream from it
// (For DOS: RWeistream estr(fstr, ios::binary)
int i = 5;
float f = 22.1;
double d = -0.05;
estr << i; // Store an int, float, and double
estr << f << d; // using the native endian format
}
|
enum RWeostream::Endian { LittleEndian,
BigEndian,
HostEndian }
RWeostream(streambuf* s, Endian fmt = HostEndian);
RWeostream(ostream& str, Endian fmt = HostEndian);
virtual ~RWvostream();
virtual RWvostream& flush();
virtual RWvostream& operator<<(const char* s);
virtual RWvostream& operator<<(char c);
virtual RWvostream& operator<<(wchar_t wc);
virtual RWvostream& operator<<(unsigned char c);
virtual RWvostream& operator<<(double d);
virtual RWvostream& operator<<(float f);
virtual RWvostream& operator<<(int i);
virtual RWvostream& operator<<(unsigned int i);
virtual RWvostream& operator<<(long l);
virtual RWvostream& operator<<(unsigned long l);
virtual RWvostream& operator<<(short s);
virtual RWvostream& operator<<(unsigned short s);
virtual RWvostream& put(char c);
virtual RWvostream& put(unsigned char c); virtual RWvostream& put(const char* p, size_t N);
virtual RWvostream& put(wchar_t wc);
virtual RWvostream& put(const wchar_t* p, size_t N);
virtual RWvostream& put(const unsigned char* p, size_t N);
virtual RWvostream& put(const short* p, size_t N);
virtual RWvostream& put(const unsigned short* p, size_t N);
virtual RWvostream& put(const int* p, size_t N);
virtual RWvostream& put(const unsigned int* p, size_t N);
virtual RWvostream& put(const long* p, size_t N);
virtual RWvostream& put(const unsigned long* p, size_t N);
virtual RWvostream& put(const float* p, size_t N);
virtual RWvostream& put(const double* p, size_t N);
virtual RWvostream& putString(const char*s, size_t N);
typedef unsigned short RWClassID; typedef RWCollectable* (*RWuserCreator)(); #include <rw/factory.h> RWFactory* theFactory;
RWCollectable* aCreatorFunction();
#include <rw/factory.h>
#include <rw/rwbag.h>
#include <rw/colldate.h>
#include <rw/rstream.h>
main(){
// Create new RWBag off the heap, using Class ID __RWBAG.
RWBag* b = (RWBag*)getRWFactory ()-> create(__RWBAG);
b->insert( new RWCollectableDate ); // Insert today's date
// ...
b->clearAndDestroy(); // Cleanup: first delete members,
delete b; // then the bag itself
}
END FILE
|
RWFactory();
RWBoolean operator<=(const RWFactory& h);
void addFunction(RWuserCreator uc, RWClassID id);
void addFunction(RWuserCreator uc, RWClassID id, RWStringID sid);
RWCollectable* create(RWClassID id) const;
RWCollectable* create(RWString sid) const;
RWuserCreator getFunction(RWClassID id) const;
RWuserCreator getFunction(RWStringID sid) const;
void removeFunction(RWClassID id);
void removeFunction(RWStringID sid);
RWStringID stringID(RWClassID id) const;
RWClassID classID(RWStringID) const;
#include <rw/rwfile.h>
RWFile f("filename");
RWFile(const char* filename, const char* mode = 0);
~RWFile();
const char* Access();
void ClearErr();
RWoffset CurOffset();
RWBoolean Eof();
RWBoolean Erase();
RWBoolean Error();
RWBoolean Exists();
RWBoolean Flush();
const char* GetName();
FILE* GetStream();
RWBoolean IsEmpty();
RWBoolean isValid() const;
RWBoolean Read(char& c); RWBoolean Read(wchar_t& wc); RWBoolean Read(short& i); RWBoolean Read(int& i); RWBoolean Read(long& i); RWBoolean Read(unsigned char& c); RWBoolean Read(unsigned short& i); RWBoolean Read(unsigned int& i); RWBoolean Read(unsigned long& i); RWBoolean Read(float& f); RWBoolean Read(double& d);
RWBoolean Read(char* i, size_t count); RWBoolean Read(wchar_t* i, size_t count); RWBoolean Read(short* i, size_t count);
RWBoolean Read(int* i, size_t count); RWBoolean Read(long* i, size_t count); RWBoolean Read(unsigned char* i, size_t count); RWBoolean Read(unsigned short* i,size_t count); RWBoolean Read(unsigned int* i, size_t count); RWBoolean Read(unsigned long* i, size_t count); RWBoolean Read(float* i, size_t count); RWBoolean Read(double* i, size_t count);
RWBoolean Read(char* string);
RWBoolean SeekTo(RWoffset offset)
RWBoolean SeekToBegin();
RWBoolean SeekToEnd();
RWBoolean Write(char i); RWBoolean Write(wchar_t i); RWBoolean Write(short i); RWBoolean Write(int i); RWBoolean Write(long i); RWBoolean Write(unsigned char i); RWBoolean Write(unsigned short i); RWBoolean Write(unsigned int i); RWBoolean Write(unsigned long i); RWBoolean Write(float f); RWBoolean Write(double d);
RWBoolean Write(const char* i, size_t count); RWBoolean Write(const wchar_t* i, size_t count); RWBoolean Write(const short* i, size_t count); RWBoolean Write(const int* i, size_t count); RWBoolean Write(const long* i, size_t count); RWBoolean Write(const unsigned char* i, size_t count); RWBoolean Write(const unsigned short* i,size_t count); RWBoolean Write(const unsigned int* i, size_t count); RWBoolean Write(const unsigned long* i, size_t count); RWBoolean
Write(const float* i, size_t count); RWBoolean Write(const double* i, size_t count);
RWBoolean Write(const char* string);
static RWBoolean Exists(const char* filename, int mode = F_OK);
typedef long RWoffset ;
typedef unsigned long RWspace; // (typically)
#include <rw/filemgr.h>
RWFileManager f("file.dat");
RWFileManager(const char* filename, const char* mode = 0);
RWoffset allocate(RWspace s);
void deallocate(RWoffset t);
RWoffset endData();
RWoffset start();
#include <rw/gbitvec.h> declare(RWGBitVec,size) RWGBitVec(size) a;
#include "rw/gbitvec.h"
#include <iostream.h>
const int VECSIZE = 8;
declare(RWGBitVec, VECSIZE) // declare a 24 bit long vector
implement(RWGBitVec, VECSIZE) // implement the vector
main()
{
RWGBitVec(VECSIZE) a, b; // Allocate two vectors.
a(2) = TRUE; // Set bit 2 (the third bit) of a on.
b(3) = TRUE; // Set bit 3 (the fourth bit) of b on.
RWGBitVec(VECSIZE) c = a ^ b; // Set c to the XOR of a and b.
cout << "Vector 1" << "\t" << "Vector 2" << "\t"
<< "Vector 1 xor Vector 2" << endl;
for(int i = 0; i < VECSIZE; i++)
cout << a[i] << "\t\t" << b[i] << "\t\t" << c[i] << endl;
return 0;
}
|
RWGBitVec(size)();
RWGBitVec(size)(RWBoolean f);
RWGBitVec(sz)& operator=(const RWGBitVec(sz)& v);
RWGBitVec(sz)& operator=(RWBoolean f);
RWGBitVec(sz)& operator&=(const RWGBitVec(sz)& v); RWGBitVec(sz)& operator^=(const RWGBitVec(sz)& v); RWGBitVec(sz)& operator|=(const RWGBitVec(sz)& v);
RWBitRef operator[](size_t i);
RWBitRef operator()(size_t i);
void clearBit(size_t i);
a(i) = FALSE;
a.clearBit(i);
const RWByte*
data() const;
void setBit(size_t i);
a(i) = TRUE;
a.setBit(i);
RWBoolean
testBit(size_t i) const;
operator()(size_t):
if( a(i) ) doSomething();
if( a.testBit(i) ) doSomething();
RWGBitVec(sz) operator&(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2); RWGBitVec(sz) operator^(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2); RWGBitVec(sz) operator|(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2);
RWBoolean
operator==(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2)
const;
RWBoolean
operator!=(const RWGBitVec(sz)& v1, const RWGBitVec(sz)& v2)
const;
#include <rw/gdlist.h> declare(RWGDlist, type) RWGDlist(type) a;
RWBoolean yourTesterFunction(const type* c, const void* d);
typedef RWBoolean (*yourTester)(const type*, const void*);
#include <rw/gdlist.h>
#include <rw/rstream.h>
declare(RWGDlist,int) /* Declare a list of ints */
main() {
RWGDlist(int) list; // Define a list of ints
int *ip;
list.insert(new int(5)); // Insert some ints
list.insert(new int(7));
list.insert(new int(1));
list.prepend(new int(11));
RWGDlistIterator(int) next(list);
while(ip = next() )
cout << *ip << endl; // Print out the members
|
while(!list.isEmpty())
delete list.get(); // Remove & delete list items
return 0;
}
END FILE
|
11
5
7
1
|
RWGDlist(type)();
RWGDlist(type)(type* a);
RWGDlist(type)(const RWGDlist(type)& a);
void operator=(const RWGDlist(type)& a);
type* append(type* a);
void apply(void (*ap)(type*, void*), void* );
void yourApplyFunction(type* c, void*);
type*& at(size_t i); const type* at(size_t i) const;
void clear();
RWBoolean contains(yourTester t, const void* d) const;
RWBoolean containsReference(const type* e) const;
size_t entries() const;
type* find(yourTester t, const void* d) const;
type* findReference(const type* e) const;
type* first() const;
type* get();
type* insert(type* e);
void insertAt(size_t indx, type* e);
RWBoolean isEmpty() const;
type* last() const;
size_t occurrencesOf(yourTester t, const void* d) const;
size_t occurrencesOfReference(const type* e) const;
type* prepend(type* a);
type* remove(yourTester t, const void* d);
type* removeReference(const type* e);
#include <rw/gdlist.h> declare(RWGDlist, type) RWGDlist(type) a; RWGDlistIterator(type) I(a) ;
typedef RWBoolean (*yourTester)(const type*, const void*);
RWGDlistIterator(type)( RWGDlist(type)& list);
type* operator()();
void operator++();
void operator--();
void operator+=(size_t n);
void operator-=(size_t n);
RWBoolean atFirst() const;
RWBoolean atLast() const;
type* findNext(yourTester t,const type* d);
type* findNextReference(const type* e);
type* insertAfterPoint(type* a);
type* key() const;
type* remove();
type* removeNext(yourTester t, const type* d);
type* removeNextReference(const type* a);
void reset();
void toFirst();
void toLast();
#include <rw/gordvec.h> declare(RWGVector,val) declare(RWGOrderedVector,val) implement(RWGVector,val) implement(RWGOrderedVector,val) RWGOrderedVector(val) v;// Ordered vector of objects of val val.
declare(RWGVector,double) // Declare base class declare(RWGOrderedVector,double) // Declare ordered vector // In one and only one .cpp file you must put the following: implement(RWGVector,double) // Implement base class implement(RWGOrderedVector,double) // Implement ordered vector
#include <rw/gordvec.h>
#include <rw/cstring.h>
#include <rw/rstream.h>
declare(RWGVector,RWCString)
declare(RWGOrderedVector,RWCString)
implement(RWGVector,RWCString)
implement(RWGOrderedVector,RWCString)
main() {
RWGOrderedVector(RWCString) vec;
RWCString one("First");
vec.insert(one);
vec.insert("Second"); // Automatic val conversion occurs
vec.insert("Last"); // Automatic val conversion occurs
for(size_t i=0; i<vec.entries(); i++) cout << vec[i] << endl;
return 0;
}
|
First Second Last |
RWGOrderedVector(val)(size_t capac=RWDEFAULT_CAPACITY);
val operator()(size_t i) const; val& operator()(size_t i);
val operator[](size_t i) const; val& operator[](size_t i);
void clear();
const val* data() const;
size_t entries() const;
size_t index(val item) const;
void insert(val item);
void insertAt(size_t indx, val item);
RWBoolean isEmpty() const;
void size_t length() const;
val pop();
void push(val);
removeAt(size_t indx);
void resize(size_t newCapacity);
#include <rw/gqueue.h> declare(RWGQueue, type) RWGQueue(type) a ;
RWBoolean yourTesterFunction(const type* c, const void* d);
typedef RWBoolean (*yourTester)(const type*, const void*);
RWGQueue(type)();
RWGQueue(type)(type* a);
RWGQueue(type)(const RWGQueue(type)& q);
void operator=(const RWGQueue(type)& q);
type* append(type* a);
void clear();
RWBoolean contains(yourTester t, const void* d) const;
RWBoolean containsReference(const type* e) const;
size_t entries() const;
type* first() const;
type* get();
RWBoolean isEmpty() const;
type* insert(type* a);
type* last();
size_t occurrencesOf(yourTester t, const void* d) const;
size_t occurrencesOfReference(const type* e) const;
#include <rw/gslist.h> declare(RWGSlist, type) RWGSlist(type) a ;
RWBoolean yourTesterFunction(const type* c, const void* d);
typedef RWBoolean (*yourTester)(const type*, const void*);
RWGSlist(type)();
RWGSlist(type)(type* a);
RWGSlist(type)(const RWGSlist(type)& a);
void operator=(const RWGSlist(type)&);
type* append(type* a);
void apply(void (*ap)(type*, void*), void* );
void yourApplyFunction(type* c, void*);
type*& at(size_t i); const type* at(size_t i) const;
void clear();
RWBoolean contains(yourTester t, const void* d) const;
RWBoolean containsReference(const type* e) const;
size_t entries() const;
type* find(yourTester t, const void* d) const;
type* findReference(const type* e) const;
type* first() const;
type* get();
type* insert(type* e);
void insertAt(size_t indx, type* e);
RWBoolean isEmpty() const;
type* last() const;
size_t occurrencesOf(yourTester t, const void* d) const;
size_t occurrencesOfReference(const type* e) const;
type* prepend(const type* a);
type* remove(yourTester t, const void* d);
type* removeReference(const type* e);
#include <rw/gslist.h> declare(RWGSlist, type) RWGSlist(type) a ; RWGSlistIterator(type) I(a);
typedef RWBoolean (*yourTester)(const type*, const void*);
RWGSlistIterator(type)( RWGSlist(type)& list);
type* operator()();
void operator++();
void operator+=(size_t n);
RWBoolean atFirst() const;
RWBoolean atLast() const;
type* findNext(yourTester t,const type* d);
type* findNextReference(const type* e);
type* insertAfterPoint(type* a);
type* key() const;
type* remove();
type* removeNext(yourTester t, const type* d);
type* removeNextReference(const type* e);
void reset();
void toFirst();
void toLast();
#include <rw/gsortvec.h> declare(RWGSortedVector,val) implement(RWGSortedVector, val) RWGSortedVector(val) v; // A sorted vector of vals .
declare(RWGVector,double) // Declare base class declare(RWGSortedVector,double) // Declare sorted vector // In one and only one .cpp file you must put the following: implement(RWGVector,double) // Implement base class implement(RWGSortedVector,double) // Implement sorted vector
int comparisonFunction(const val* a, const val* b);
#include <rw/gsortvec.h>
#include <rw/rstream.h>
declare(RWGVector,int)
declare(RWGSortedVector,int)
implement(RWGVector,int)
implement(RWGSortedVector,int)
// Declare and define the "comparison function":
int compFun(const int* a, const int* b) {
return *a - *b;
}
main() {
// Declare and define an instance,
// using the comparison function 'compFun':
RWGSortedVector(int) avec(compFun);
// Do some insertions:
avec.insert(3); // 3
avec.insert(17); // 3 17
avec.insert(5); // 3 5 17
cout << avec(1); // Prints '5'
cout << avec.index(17); // Prints '2'
}
END FILE
|
RWGSortedVector(val)( int (*f)(const val*, const val*) );
RWGSortedVector(val)(int (*f)(const val*, const val*),
size_t N);
val operator()(size_t i) const;
val operator[](size_t i) const;
size_t entries() const;
size_t index(val v);
RWBoolean insert(val v);
void removeAt(size_t indx);
void resize(size_t newCapacity);
#include <rw/gstack.h> declare(RWGStack,type) RWGStack(type) a ;
RWBoolean yourTesterFunction(const type* c, const void* d);
typedef RWBoolean (*yourTester)(const type*, const void*);
RWGStack(type)();
RWGStack(type)(type* a);
RWGStack(type)(const RWGStack(type)& a);
void operator=(const RWGStack(type)& a);
void clear();
RWBoolean contains(yourTester t, const void* d) const;
RWBoolean containsReference(const type* e) const;
size_t entries() const;
RWBoolean isEmpty() const;
size_t occurrencesOf(yourTester t, const void* d) const;
size_t occurrencesOfReference(const type* e) const;
type* pop();
void push(type* a);
type* top() const;
#include <rw/gvector.h> declare(RWGVector,val) implement(RWGVector,val) RWGVector(val) a; // A Vector of val's.
#include <rw/gvector.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
declare(RWGVector, RWDate) /* Declare a vector of dates */
implement(RWGVector, RWDate) /* Implement a vector of dates */
main() {
RWGVector(RWDate) oneWeek(7);
for (int i=1; i<7; i++)
oneWeek(i) = oneWeek(0) + i;
for (i=0; i<7; i++)
cout << oneWeek(i) << endl;
return 0;
}
|
04/12/93 04/13/93 04/14/93 04/15/93 04/16/93 04/17/93 04/18/93 |
RWGVector(val)();
RWGVector(val)(size_t n);
RWGVector(val)(size_t n, val v);
RWGVector(val)(RWGVector(val)& s);
RWGVector(val)& operator=(RWGVector(val)& s);
RWGVector(val)& operator=(val v);
val operator()(size_t i) const; val& operator()(size_t i);
val operator[](size_t i) const; val& operator[](size_t i);
const val* data() const;
size_t length() const;
void reshape(size_t n);
typedef RWHashDictionary Dictionary; // Smalltalk typedef. #include <rw/hashdict.h> RWHashDictionary a ;
RWHashDictionary(size_t n = RWDEFAULT_CAPACITY);
RWHashDictionary(const RWHashDictionary& hd);
void operator=(const RWHashDictionary& hd);
RWBoolean operator<=(const RWHashDictionary& hd) const;
RWBoolean operator==(const RWHashDictionary& hd) const;
void applyToKeyAndValue(RWapplyKeyAndValue ap, void* x);
RWBinaryTree asBinaryTree(); RWBag asBag() const; RWSet asOrderedCollection() const; asSet() const; RWOrdered RWBinaryTree asSortedCollection() const;
virtual RWspace binaryStoreSize() const;
virtual void clear();
virtual void clearAndDestroy();
virtual int compareTo(const RWCollectable* a) const;
virtual RWBoolean contains(const RWCollectable* target) const;
virtual size_t entries() const;
virtual RWCollectable* find(const RWCollectable* target) const;
RWCollectable*
findKeyAndValue(const RWCollectable* target,
RWCollectable*& v) const;
RWCollectable* findValue(const RWCollectable* target) const;
RWCollectable* findValue(const RWCollectable* target, RWCollectable* newValue);
virtual unsigned hash() const;
RWCollectable* insertKeyAndValue(RWCollectable* key,RWCollectable* value);
virtual RWClassID isA() const;
virtual RWBoolean isEmpty() const;
virtual RWBoolean isEqual(const RWCollectable* a) const;
virtual size_t occurrencesOf(const RWCollectable* target) const;
virtual RWCollectable* remove(const RWCollectable* target);
virtual void removeAndDestroy(const RWCollectable* target);
RWCollectable*
removeKeyAndValue(const RWCollectable* target,
RWCollectable*& v);
void resize(size_t n = 0);
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const;
virtual RWCollection* select(RWtestCollectable testfunc, void* x) const;
virtual RWCollection* select(RWtestCollectablePair testfunc, void* x) const;
RWStringID stringID();
#include <rw/hashdict.h> RWHashDictionary hd; RWHashDictionaryIterator iter(hd);
RWHashDictionaryIterator(RWHashDictionary&);
virtual RWCollectable* operator()();
virtual RWCollectable* findNext(const RWCollectable* target);
virtual RWCollectable* key() const;
RWCollectable* remove();
RWCollectable* removeNext(const RWCollectable* target);
virtual void reset();
RWCollectable* value() const;
RWCollectable* value(RWCollectable* newValue) const;
#include <rw/rwstl/hashmap.h> rw_hashmap<K,V,Hash,EQ> map;
typedef K key_type; typedef Hash key_hash; typedef EQ key_equal; typedef pair<K,V> value_type; // or ... "const K" typedef (unsigned) size_type; //from rw_slist typedef (int) difference_type; // from rw_slist typedef (value_type&) reference; typedef (const value_type&) const_reference; //from rw_slist
typedef (scoped Iterator) iterator; typedef (scoped ConstIterator) const_iterator;
rw_hashmap<K,V,Hash,EQ>(size_type sz = 1024,
const Hash& h = Hash(),
const EQ& eq = EQ());
rw_hashmap<K,V,Hash,EQ>(const rw_hashmap<K,V,Hash,EQ>& map);
rw_hashmap<K,V,Hash,EQ>(const_iterator first,
const_iterator bound
size_type sz=1024,