Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126959
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
46 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/ebox.cpp b/util/ebox.cpp
index 74819320..31e67962 100644
--- a/util/ebox.cpp
+++ b/util/ebox.cpp
@@ -1,713 +1,715 @@
/* ebox version 3:
* by Jon Rafkind
*/
#include "ebox.h"
#include <stdio.h>
#include "funcs.h"
#include "bitmap.h"
#include <iostream>
+using namespace std;
+
extern "C" void rest( int i );
// using namespace Ebox2;
#ifndef debug
// #define debug printf("File: %s Line: %d\n", __FILE__, __LINE__ );
#define debug std::cout<<"File: "<<__FILE__<<" Line: "<<__LINE__<<std::endl;
#endif
// #define MIN_SIZE 8
const int MIN_SIZE = 8;
/* copy constructor but with a pointer */
EQuad::EQuad( EQuad * const head ):
width( head->width ),
height( head->height ),
full( head->full ),
min_x( head->min_x ),
min_y( head->min_y ),
parent( NULL ),
num_quads( head->num_quads ){
for ( int q = 0; q < 4; q++ )
quads[q] = NULL;
for ( int i = 0; i < head->numQuads(); i++ ){
// EQuad * tmp = head->getQuad( i );
quads[i] = new EQuad( head->getQuad( i ) );
quads[i]->parent = this;
}
}
EQuad::EQuad( int w, int h, EQuad * _parent ):
width( w ),
height( h ),
min_x( 0 ),
min_y( 0 ),
parent( _parent ),
num_quads( 0 ){
full = true;
for ( int i = 0; i < 4; i++ )
quads[i] = NULL;
}
EQuad::EQuad( const Bitmap * who, int min_size, int mask_pixel, int _min_x, int _min_y, EQuad * _parent ):
width( who->getWidth() ),
height( who->getHeight() ),
full( false ),
min_x( _min_x ),
min_y( _min_y ),
parent( _parent ){
Bitmap * b1, * b2, * b3, * b4;
EQuad * quad1, * quad2, * quad3, * quad4;
quad1 = quad2 = quad3 = quad4 = NULL;
if ( width > min_size && height > min_size ){
int w = who->getWidth() >> 1;
int h = who->getHeight() >> 1;
// b1 = create_sub_Bitmap( who, 0, 0, w, h );
b1 = new Bitmap( *who, 0, 0, w, h );
quad1 = new EQuad( b1, min_size, mask_pixel, 0, 0, this );
// destroy_Bitmap( b1 );
delete b1;
// b2 = create_sub_Bitmap( who, w, 0, w, h );
b2 = new Bitmap( *who, w, 0, w, h );
quad2 = new EQuad( b2, min_size, mask_pixel, w, 0, this );
delete b2;
// destroy_Bitmap( b2 );
// b3 = create_sub_Bitmap( who, 0, h, w, h );
b3 = new Bitmap( *who, 0, h, w, h );
quad3 = new EQuad( b3, min_size, mask_pixel, 0, h, this );
delete b3;
// destroy_Bitmap( b3 );
// b4 = create_sub_Bitmap( who, w, h, w, h );
b4 = new Bitmap( *who, w, h, w, h );
quad4 = new EQuad( b4, min_size, mask_pixel, w, h, this );
delete b4;
// destroy_Bitmap( b4 );
if ( quad1->empty() ){
delete quad1;
quad1 = NULL;
}
if ( quad2->empty() ){
delete quad2;
quad2 = NULL;
}
if ( quad3->empty() ){
delete quad3;
quad3 = NULL;
}
if ( quad4->empty() ){
delete quad4;
quad4 = NULL;
}
if ( quad1 && quad2 && quad3 && quad4 )
if ( quad1->full && quad2->full && quad3->full && quad4->full ){
delete quad1;
delete quad2;
delete quad3;
delete quad4;
quad1 = NULL;
quad2 = NULL;
quad3 = NULL;
quad4 = NULL;
full = true;
}
checkQuad( quad1 );
checkQuad( quad2 );
checkQuad( quad3 );
checkQuad( quad4 );
} else {
// printf("Size X:%d Y:%d\n", width, height );
int total = 0;
int denom = who->getWidth() * who->getHeight();
for ( int x = 0; x < who->getWidth(); x++ ){
for ( int y = 0; y < who->getHeight(); y++ ){
// int pixel = _getpixel16( who, x, y );
int pixel = who->getPixel( x, y );
if ( pixel != mask_pixel ){
++total;
}
if ( total * 100 / denom > 50 ){
/* we're done already,
* stop counting pixels
*/
goto short_circuit;
}
}
}
/* johnny 5 alive! */
short_circuit:
if ( total * 100 / denom > 50 ){
full = true;
}
}
for ( int i = 0; i < 4; i++ )
quads[i] = NULL;
int i = 0;
if ( quad1 ) quads[i++] = quad1;
if ( quad2 ) quads[i++] = quad2;
if ( quad3 ) quads[i++] = quad3;
if ( quad4 ) quads[i++] = quad4;
num_quads = numQuads();
}
bool EQuad::addQuad( EQuad * who ){
int n = numQuads();
if ( n < 4 ){
quads[n] = who;
full = false;
return true;
} else return false;
}
void EQuad::checkQuad( EQuad *& q ){
if ( q != NULL ){
while ( q->numQuads() == 1 ){
EQuad * const newquad = q->getQuad();
q->detach( newquad );
int x = q->getMinX();
int y = q->getMinY();
delete q;
q = newquad;
newquad->setMinX( newquad->getMinX() + x );
newquad->setMinY( newquad->getMinY() + y );
q->parent = this;
}
}
}
int EQuad::totalQuads(){
if ( full ) return 1;
int total = 0;
for ( int i = 0; i < numQuads(); i++ )
if ( quads[i] )
total += quads[i]->totalQuads();
/*
if ( quad1 ) total += quad1->totalQuads();
if ( quad2 ) total += quad2->totalQuads();
if ( quad3 ) total += quad3->totalQuads();
if ( quad4 ) total += quad4->totalQuads();
*/
return total;
}
void EQuad::setMinX( int x ){
min_x = x;
}
void EQuad::setMinY( int y ){
min_y = y;
}
/*
int EQuad::numQuads() const{
int total = 0;
/ *
if ( quad1 ) ++total;
if ( quad2 ) ++total;
if ( quad3 ) ++total;
if ( quad4 ) ++total;
* /
for ( total = 0; total < 4 && quads[total] != NULL; total++ );
return total;
}
*/
EQuad * const EQuad::getQuad() const{
return quads[0];
/*
if ( quad1 ) return quad1;
if ( quad2 ) return quad2;
if ( quad3 ) return quad3;
if ( quad4 ) return quad4;
return NULL;
*/
}
EQuad * const EQuad::getQuad( int x ) const{
return quads[x];
}
void EQuad::detach( EQuad * const who ){
// printf("Detach %p\n", who );
/*
if ( who == quad1 ) quad1 = NULL;
if ( who == quad2 ) quad2 = NULL;
if ( who == quad3 ) quad3 = NULL;
if ( who == quad4 ) quad4 = NULL;
*/
for ( int i = 0; i < numQuads(); i++ )
if ( who == quads[i] )
quads[i] = NULL;
EQuad * tmp[ 4 ];
int begin = 0;
for ( int i = 0; i < 4; i++ )
if ( quads[i] ){
tmp[begin++] = quads[i];
quads[i] = NULL;
}
for ( int q = 0; q < begin; q++ )
quads[q] = tmp[q];
}
int EQuad::calcSize(){
int total = sizeof(*this);
for ( int q = 0; q < numQuads(); q++ ){
total += quads[q]->calcSize();
}
return total;
}
bool EQuad::empty(){
if ( numQuads() == 0 ) return !full;
// if ( !quad1 && !quad2 && !quad3 && !quad4 ) return !full;
return false;
}
void EQuad::draw( const Bitmap & work, int x, int y, int color, bool flipped ){
int mx = x + getMinX();
int my = y + getMinY();
// std::cout<<"getMinX: "<<getMinX()<<std::endl;
if ( flipped ){
if ( parent ){
mx = x + parent->getWidth() - (getMinX()+getWidth());
// mx = getMinX() - parent->getWidth()/2 + x;
// my = y + parent->getHeight()/2 - getMinY();
// my = y + getMinY();
// mx2 = mx - getWidth();
// mx2 = mx + getWidth();
/*
int i;
i = mx;
mx = mx2;
mx2 = i;
*/
}
}
int mx2 = mx + getWidth();
int my2 = my + getHeight();
for ( int i = 0; i < numQuads(); i++ )
quads[i]->draw( work, mx, my, color, flipped );
if ( full )
work.rectangle( mx, my, mx2, my2, color );
/*
if ( full )
work->rectangle( x+getMinX(), y+getMinY(), x+getMinX()+getWidth(), y+getMinY()+getHeight(), Bitmap::makeColor(255,64,32) );
else
work->rectangle( x+getMinX(), y+getMinY(), x+getMinX()+getWidth(), y+getMinY()+getHeight(), color );
*/
}
void EQuad::draw( const Bitmap & work, int x, int y, int color, EQuad * who ){
bool cy = false;
for ( int i = 0; i < numQuads(); i++ )
if ( who == quads[i] )
cy = true;
int mx = x + getMinX();
int my = y + getMinY();
if ( cy )
who->draw( work, mx, my, color );
else {
for ( int i = 0; i < numQuads(); i++ )
quads[i]->draw( work, mx, my, color, who );
}
}
static bool boxCollide( int zx1, int zy1, int zx2, int zy2, int zx3, int zy3, int zx4, int zy4 ){
if ( zx1 < zx3 && zx1 < zx4 &&
zx2 < zx3 && zx2 < zx4 ) return false;
if ( zx1 > zx3 && zx1 > zx4 &&
zx2 > zx3 && zx2 > zx4 ) return false;
if ( zy1 < zy3 && zy1 < zy4 &&
zy2 < zy3 && zy2 < zy4 ) return false;
if ( zy1 > zy3 && zy1 > zy4 &&
zy2 > zy3 && zy2 > zy4 ) return false;
return true;
}
/* sure this could be simplified, but thats no fun :p */
int EQuad::getX1( bool xflipped ){
if ( parent ){
if ( xflipped ){
return parent->getWidth() - (getMinX() + getWidth());
} else {
return getMinX();
}
} else {
return getMinX();
}
}
int EQuad::getFullX1( bool xflipped ){
if ( parent ){
if ( xflipped ){
return parent->getFullX1( xflipped ) + parent->getWidth() - (getMinX() + getWidth());
} else {
return parent->getFullX1( xflipped ) + getMinX();
}
} else {
return getMinX();
}
}
int EQuad::getY1( bool yflipped ){
if ( parent ){
if ( yflipped ){
return parent->getHeight() - (getMinY() + getHeight());
} else {
return getMinY();
}
} else {
return getMinY();
}
}
int EQuad::getFullY1( bool yflipped ){
if ( parent ){
if ( yflipped ){
return parent->getFullY1( yflipped ) - (parent->getHeight() + getMinY() + getHeight());
} else {
return parent->getFullY1( yflipped ) + getMinY();
}
} else {
return getMinY();
}
}
void EQuad::gather( int mx, int my, int x1, int y1, int x2, int y2, vector< EQuad * > & collides, bool xflipped, bool yflipped ){
/*
int rx = mx + getX1();
int ry = my + getY1();
*/
int rx = mx;
int ry = my;
int rx2 = rx + getWidth();
int ry2 = ry + getHeight();
if ( ! boxCollide( rx, ry, rx2, ry2, x1, y1, x2, y2 ) ){
return;
}
for ( int i = 0; i < numQuads(); i++ ){
quads[i]->gather( rx + quads[i]->getX1( xflipped ), ry + quads[i]->getY1( yflipped ), x1, y1, x2, y2, collides, xflipped, yflipped );
}
if ( full ){
collides.push_back( this );
}
}
bool EQuad::collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped, bool yflipped ){
/*
int rx = mx + getMinX();
int ry = my + getMinY();
if ( parent ){
if ( xflipped ){
rx = mx + parent->getWidth() - (getMinX()+getWidth());
}
if ( yflipped ){
ry = my + parent->getHeight() - (getMinY()+getHeight());
}
}
*/
int rx = mx + getX1( xflipped );
int ry = my + getY1( yflipped );
int rx2 = rx + getWidth();
int ry2 = ry + getHeight();
// rect( screen, rx, ry, rx2, ry2, makecol(255,255,0) );
bool cy = boxCollide( rx, ry, rx2, ry2, x1, y1, x2, y2 );
if ( !cy ) return false;
for ( int i = 0; i < numQuads(); i++ )
if ( quads[i]->collide( rx, ry, x1, y1, x2, y2, last ) )
return true;
if ( !full ) return false;
if ( cy ) *last = this;
return cy;
return false;
}
EQuad::~EQuad(){
/*
if ( quad1 ) delete quad1;
if ( quad2 ) delete quad2;
if ( quad3 ) delete quad3;
if ( quad4 ) delete quad4;
*/
for ( int q = 0; q < 4; q++ )
if ( quads[q] != NULL )
delete quads[q];
}
long long ECollide::totalTime = 0;
void ECollide::initECollide( const Bitmap * who, int mask_pixel ){
/*
TimeDifference dif;
dif.startTime();
*/
head_quad = new EQuad( who, MIN_SIZE, mask_pixel, 0, 0, NULL );
last_collide = NULL;
/*
dif.endTime();
totalTime += dif.getTime();
cout<<"Total time taken: "<< totalTime / 1000 <<" ms" <<endl;
*/
}
ECollide::ECollide( const Bitmap * who, int mask_pixel ){
initECollide( who, mask_pixel );
/*
head_quad = new EQuad( who, MIN_SIZE, mask_pixel, 0, 0, NULL );
last_collide = NULL;
*/
}
ECollide::ECollide( const Bitmap & who, int mask_pixel ){
initECollide( &who, mask_pixel );
/*
head_quad = new EQuad( &who, MIN_SIZE, mask_pixel, 0, 0, NULL );
last_collide = NULL;
*/
}
ECollide::ECollide( BITMAP * who, int mask_pixel ){
Bitmap tmp( who );
initECollide( &tmp, mask_pixel );
/*
head_quad = new EQuad( &tmp, MIN_SIZE, mask_pixel, 0, 0, NULL );
last_collide = NULL;
*/
}
ECollide::ECollide( int width, int height ){
last_collide = NULL;
head_quad = new EQuad( width, height, NULL );
}
ECollide::ECollide( const ECollide * e ){
initQuad( e->head_quad );
/*
last_collide = NULL;
head_quad = new EQuad( e->head_quad );
*/
}
ECollide::ECollide( const ECollide & e ){
initQuad( e.head_quad );
/*
last_collide = NULL;
head_quad = new EQuad( e.head_quad );
*/
}
ECollide::ECollide( EQuad * const head ){
initQuad( head );
/*
last_collide = NULL;
head_quad = new EQuad( head );
*/
}
void ECollide::initQuad( EQuad * const head ){
last_collide = NULL;
head_quad = new EQuad( head );
}
ECollide * ECollide::copy(){
return new ECollide( head_quad );
}
int ECollide::getMinHeight(){
return head_quad->getMinY();
}
int ECollide::getMaxHeight(){
return head_quad->getMinY() + head_quad->getHeight();
}
int ECollide::getMinWidth(){
return head_quad->getMinX();
}
int ECollide::getMaxWidth(){
return head_quad->getMinX() + head_quad->getWidth();
}
int ECollide::calcSize(){
int total = sizeof(*this);
if ( head_quad )
total += head_quad->calcSize();
return total;
}
bool ECollide::collide( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped, bool yflipped ){
last_collide = NULL;
return head_quad->collide(mx,my,x1,y1,x2,y2, &last_collide, xflipped, yflipped );
}
bool ECollide::collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped, bool yflipped ){
return head_quad->collide(mx,my,x1,y1,x2,y2, last, xflipped, yflipped );
}
void ECollide::gather( int mx, int my, int x1, int y1, int x2, int y2, vector< EQuad * > & e, bool xflipped, bool yflipped ){
return head_quad->gather( mx, my, x1, y1, x2, y2, e, xflipped, yflipped );
}
bool ECollide::Collision( int mx, int my, int ax, int ay, bool xflipped, bool ylfipped ){
return collide( mx, my, ax, ay, ax, ay );
}
bool ECollide::Collision( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped, bool yflipped ){
return collide( mx, my, x1, y1, x2, y2 );
}
bool ECollide::Collision( ECollide * col, int mx, int my, int ax, int ay, bool my_xflipped, bool my_yflipped, bool him_xflipped, bool him_yflipped ){
if ( !col ) return false;
int x1 = mx > ax ? mx : ax;
int y1 = my > ay ? my : ay;
int x2 = (mx+getWidth()) < (ax+col->getWidth()) ? (mx+getWidth()) : (ax+col->getWidth());
int y2 = (my+getHeight()) < (ay+col->getHeight()) ? (my+getHeight()) : (ay+col->getHeight());
if ( x1 > x2 ) return false;
if ( y1 > y2 ) return false;
vector< EQuad * > collides1;
gather( mx, my, x1, y1, x2, y2, collides1, my_xflipped, my_yflipped );
vector< EQuad * > collides2;
col->gather( ax, ay, x1, y1, x2, y2, collides2, him_xflipped, him_yflipped );
for ( vector< EQuad * >::iterator it = collides1.begin(); it != collides1.end(); it++ ){
EQuad * e = *it;
int px1 = mx + e->getFullX1( my_xflipped );
int py1 = my + e->getFullY1( my_yflipped );
int px2 = px1 + e->getWidth();
int py2 = py1 + e->getHeight();
// Bitmap::Screen->rectangle( px1, py1, px2, py2, Bitmap::makeColor( 128, 128, 255 ) );
for ( vector< EQuad * >::iterator it2 = collides2.begin(); it2 != collides2.end(); it2++ ){
EQuad * e2 = *it2;
int zx1 = ax + e2->getFullX1( him_xflipped );
int zy1 = ay + e2->getFullY1( him_yflipped );
// printf( "Test %d,%d,%d,%d against %d,%d,%d,%d\n", px1, py1, px2, py2, zx1, zy1, zx1 + e2->getWidth(), zy1 + e2->getHeight() );
// Bitmap::Screen->rectangle( zx1, zy1, zx1 + e2->getWidth(), zy1 + e2->getHeight(), Bitmap::makeColor( Util::rnd( 255 ), 255, 255 ) );
// if ( e2->collide( zx1, zy1, px1, py1, px2, py2, &last_collide, him_xflipped, him_yflipped ) ){
if ( boxCollide( px1, py1, px2, py2, zx1, zy1, zx1 + e2->getWidth(), zy1 + e2->getHeight() ) ){
// Bitmap::Screen->rectangle( zx1, zy1, zx1 + e2->getWidth(), zy1 + e2->getHeight(), Bitmap::makeColor( 255, 255, 0 ) );
// cout << "Collided!" << endl;
// rest( 1000 );
return true;
}
}
}
// rest( 100 );
return false;
/*
return ( collide(mx,my,x1,y1,x2,y2,my_xflipped,my_yflipped) && col->collide(ax,ay,x1,y1,x2,y2,him_xflipped,him_yflipped) );
*/
}
/*
int ECollide::getWidth() const{
return head_quad->getWidth();
}
int ECollide::getHeight() const{
return head_quad->getHeight();
}
*/
void ECollide::draw( const Bitmap & work, int x, int y, int color, bool flipped ){
head_quad->draw( work, x, y, color, flipped );
}
int ECollide::numQuads() const{
return head_quad->totalQuads();
}
void ECollide::draw( const Bitmap & work, int x, int y, int color, EQuad * who ){
if ( head_quad == who )
head_quad->draw( work, x, y, color );
else head_quad->draw( work, x, y, color, who );
}
EQuad * ECollide::getLast(){
return last_collide;
}
ECollide::~ECollide(){
delete head_quad;
}
diff --git a/util/ebox.h b/util/ebox.h
index d2baf9f0..cf06ed95 100644
--- a/util/ebox.h
+++ b/util/ebox.h
@@ -1,178 +1,176 @@
/* ebox version 3:
* by Jon Rafkind
*/
#ifndef _ebox_3_h
#define _ebox_3_h
#include "bitmap.h"
#include <vector>
-using namespace std;
-
class EQuad{
public:
EQuad( EQuad * const head );
EQuad( int w, int h, EQuad * _parent );
EQuad( const Bitmap * who, int min_size, int mask_pixel, int min_x, int min_y, EQuad * _parent );
void draw( const Bitmap & work, int x, int y, int color, bool flipped = false );
void draw( const Bitmap & work, int x, int y, int color, EQuad * who );
inline int getWidth() const{
return width;
}
inline int getHeight() const{
return height;
}
inline void setFull( bool x ){
full = x;
}
EQuad * const getQuad( int x ) const;
bool addQuad( EQuad * who );
inline int getPosX() const {
if ( parent )
return min_x + parent->getPosX();
return min_x;
}
inline int getPosY() const {
if ( parent )
return min_y + parent->getPosY();
return min_y;
}
- void gather( int mx, int my, int x1, int y1, int x2, int y2, vector< EQuad * > & collides, bool xflipped, bool yflipped );
+ void gather( int mx, int my, int x1, int y1, int x2, int y2, std::vector< EQuad * > & collides, bool xflipped, bool yflipped );
// bool collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last );
bool collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped = false, bool yflipped = false );
// int collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, int depth );
int calcSize();
void setMinX( int x );
void setMinY( int y );
int getFullX1( bool xflipped = false );
int getFullY1( bool yflipped = false );
inline int getMinX() const{
return min_x;
}
inline int getMinY() const{
return min_y;
}
int totalQuads();
~EQuad();
protected:
int getX1( bool xflipped = false );
int getY1( bool yflipped = false );
EQuad * const getQuad() const;
void detach( EQuad * const who );
void checkQuad( EQuad *& q );
inline int numQuads() const{
int total = 0;
if ( quads[0] != NULL ) total++;
if ( quads[1] != NULL ) total++;
if ( quads[2] != NULL ) total++;
if ( quads[3] != NULL ) total++;
// for ( int total = 0; total < 4 && quads[total] != NULL; total++ );
return total;
}
bool empty();
// bool boxCollide( int zx1, int zy1, int zx2, int zy2, int zx3, int zy3, int zx4, int zy4 );
protected:
int width, height;
// EQuad * quad1, * quad2, * quad3, * quad4;
bool full;
int min_x, min_y;
EQuad * quads[ 4 ];
EQuad * parent;
int num_quads;
};
class ECollide{
public:
ECollide( EQuad * const head );
ECollide( BITMAP * who, int mask_pixel = Bitmap::MaskColor );
ECollide( const Bitmap * who, int mask_pixel = Bitmap::MaskColor );
ECollide( const Bitmap & who, int mask_pixel = Bitmap::MaskColor );
ECollide( const ECollide & e );
ECollide( const ECollide * e );
ECollide( int width, int height );
void draw( const Bitmap & work, int x, int y, int color, bool flipped = false );
void draw( const Bitmap & work, int x, int y, int color, EQuad * who );
bool Collision( ECollide * col, int mx, int my, int ax, int ay, bool my_xflipped = false, bool my_yflipped = false, bool him_xflipped = false, bool him_flipped = false );
bool Collision( int mx, int my, int ax, int ay, bool xflipped = false, bool yflipped = false );
bool Collision( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped = false, bool yflipped = false );
int getMinHeight();
int getMaxHeight();
int getMinWidth();
int getMaxWidth();
ECollide * copy();
EQuad * getLast();
EQuad * getHead() const{
return head_quad;
}
- void gather( int mx, int my, int x1, int y1, int x2, int y2, vector< EQuad * > & e, bool xflipped, bool yflipped );
+ void gather( int mx, int my, int x1, int y1, int x2, int y2, std::vector< EQuad * > & e, bool xflipped, bool yflipped );
int calcSize();
inline int getWidth() const{
return head_quad->getWidth();
}
inline int getHeight() const{
return head_quad->getHeight();
}
int numQuads() const;
~ECollide();
private:
void initECollide( const Bitmap * who, int mask_pixel );
void initQuad( EQuad * const head );
static long long totalTime;
protected:
bool collide( int mx, int my, int x1, int y1, int x2, int y2, bool xflipped = false, bool yflipped = false );
bool collide( int mx, int my, int x1, int y1, int x2, int y2, EQuad ** last, bool xflipped, bool yflipped );
// bool collide( int mx, int my, int x1, int y1 );
EQuad * head_quad;
EQuad * last_collide;
};
#endif
diff --git a/util/font.cpp b/util/font.cpp
index da437ebb..81f1c4bc 100644
--- a/util/font.cpp
+++ b/util/font.cpp
@@ -1,143 +1,145 @@
#include <allegro.h>
#include "font.h"
#include "init.h"
#include "factory/font_factory.h"
+using namespace std;
+
Font::Font(){
}
Font::~Font(){
}
AllegroFont::AllegroFont( const FONT * const font ):
font( font ){
}
AllegroFont::AllegroFont( const AllegroFont & copy ):
font( copy.getInternalFont() ){
}
AllegroFont::~AllegroFont(){
}
const int AllegroFont::textLength( const char * text ) const{
return text_length( getInternalFont(), text );
}
const int AllegroFont::getHeight( const string & str ) const {
return getHeight();
}
const int AllegroFont::getHeight() const {
return text_height( getInternalFont() );
}
void AllegroFont::setSize( const int x, const int y ){
}
const int AllegroFont::getSizeX() const {
return 0;
}
const int AllegroFont::getSizeY() const {
return 0;
}
void AllegroFont::printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const string & str, int marker, ... ) const {
char buf[512];
va_list ap;
va_start(ap, marker);
uvszprintf(buf, sizeof(buf), str.c_str(), ap);
va_end(ap);
textout_ex( work.getBitmap(), getInternalFont(), buf, x, y, color, -1 );
}
void AllegroFont::printf( int x, int y, int color, const Bitmap & work, const string & str, int marker, ... ) const {
char buf[512];
va_list ap;
va_start(ap, marker);
uvszprintf(buf, sizeof(buf), str.c_str(), ap);
va_end(ap);
textout_ex( work.getBitmap(), getInternalFont(), buf, x, y, color, -1 );
}
const Font & Font::getDefaultFont(){
// return getFont( "tmp/comic.ttf" );
return getFont( "bios", 16, 16 );
}
const Font & Font::getFont( const string & name, const int x, const int y ){
return *FontFactory::getFont( name, x, y );
}
FreeTypeFont::FreeTypeFont( const string & str ):
sizeX( 16 ),
sizeY( 16 ){
this->font = new ftalleg::freetype( str, getSizeX(), getSizeY() );
}
const int FreeTypeFont::getHeight( const string & str ) const {
return this->font->getHeight( str );
}
const int FreeTypeFont::getHeight() const {
return getHeight( "A" );
}
const int FreeTypeFont::textLength( const char * text ) const {
return this->font->getLength( string( text ) );
}
void FreeTypeFont::printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const string & str, int marker, ... ) const {
char buf[512];
va_list ap;
va_start(ap, marker);
vsnprintf(buf, sizeof(buf), str.c_str(), ap);
va_end(ap);
int old_x = 0;
int old_y = 0;
this->font->getSize(&old_x, &old_y);
this->font->setSize(xSize, ySize);
this->font->render( x, y, color, work.getBitmap(), ftalleg::freetype::ftLeft, string( buf ), 0 );
this->font->setSize(old_x, old_y);
}
void FreeTypeFont::printf( int x, int y, int color, const Bitmap & work, const string & str, int marker, ... ) const {
char buf[512];
va_list ap;
va_start(ap, marker);
vsnprintf(buf, sizeof(buf), str.c_str(), ap);
va_end(ap);
this->font->render( x, y, color, work.getBitmap(), ftalleg::freetype::ftLeft, string( buf ), 0 );
}
void FreeTypeFont::setSize( const int x, const int y ){
this->sizeX = x;
this->sizeY = y;
this->font->setSize( this->sizeX, this->sizeY );
}
const int FreeTypeFont::getSizeX() const {
return this->sizeX;
}
const int FreeTypeFont::getSizeY() const {
return this->sizeY;
}
FreeTypeFont::~FreeTypeFont(){
// cout << "Delete font " << this->font << endl;
delete this->font;
}
diff --git a/util/font.h b/util/font.h
index e0a811c8..642f1155 100644
--- a/util/font.h
+++ b/util/font.h
@@ -1,86 +1,84 @@
#ifndef _paintown_font_h
#define _paintown_font_h
-struct FONT;
-
#include <string>
#include <vector>
#include "bitmap.h"
#include "ftalleg.h"
-using namespace std;
+struct FONT;
/* handle allegro fonts and true type fonts */
class Font{
public:
Font();
virtual ~Font();
virtual void setSize( const int x, const int y ) = 0;
virtual const int getSizeX() const = 0;
virtual const int getSizeY() const = 0;
virtual const int textLength( const char * text ) const = 0;
- virtual const int getHeight( const string & str ) const = 0;
+ virtual const int getHeight( const std::string & str ) const = 0;
virtual const int getHeight() const = 0;
- virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const string & str, int marker, ... ) const = 0;
- virtual void printf( int x, int y, int color, const Bitmap & work, const string & str, int marker, ... ) const = 0;
+ virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const std::string & str, int marker, ... ) const = 0;
+ virtual void printf( int x, int y, int color, const Bitmap & work, const std::string & str, int marker, ... ) const = 0;
static const Font & getDefaultFont();
- static const Font & getFont( const string & name, const int x = 32, const int y = 32 );
+ static const Font & getFont( const std::string & name, const int x = 32, const int y = 32 );
/* store all the freetype fonts forever */
- static vector< ftalleg::freetype * > cacheFreeType;
+ static std::vector< ftalleg::freetype * > cacheFreeType;
};
class AllegroFont: public Font {
public:
AllegroFont( const FONT * const font );
AllegroFont( const AllegroFont & copy );
virtual ~AllegroFont();
virtual const int getHeight() const;
- virtual const int getHeight( const string & str ) const;
+ virtual const int getHeight( const std::string & str ) const;
virtual const int textLength( const char * text ) const;
- virtual void printf( int x, int y, int color, const Bitmap & work, const string & str, int marker, ... ) const;
- virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const string & str, int marker, ... ) const;
+ virtual void printf( int x, int y, int color, const Bitmap & work, const std::string & str, int marker, ... ) const;
+ virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const std::string & str, int marker, ... ) const;
virtual void setSize( const int x, const int y );
virtual const int getSizeX() const;
virtual const int getSizeY() const;
private:
inline const FONT * const getInternalFont() const{
return font;
}
const FONT * const font;
};
class FreeTypeFont: public Font {
public:
- FreeTypeFont( const string & filename );
+ FreeTypeFont( const std::string & filename );
FreeTypeFont( const FreeTypeFont & copy );
virtual ~FreeTypeFont();
virtual const int getHeight() const;
- virtual const int getHeight( const string & str ) const;
+ virtual const int getHeight( const std::string & str ) const;
virtual const int textLength( const char * text ) const;
- virtual void printf( int x, int y, int color, const Bitmap & work, const string & str, int marker, ... ) const;
- virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const string & str, int marker, ... ) const;
+ virtual void printf( int x, int y, int color, const Bitmap & work, const std::string & str, int marker, ... ) const;
+ virtual void printf( int x, int y, int xSize, int ySize, int color, const Bitmap & work, const std::string & str, int marker, ... ) const;
virtual void setSize( const int x, const int y );
virtual const int getSizeX() const;
virtual const int getSizeY() const;
private:
ftalleg::freetype * font;
int sizeX;
int sizeY;
};
#endif
diff --git a/util/keyboard.h b/util/keyboard.h
index b5617b40..cd485ea1 100644
--- a/util/keyboard.h
+++ b/util/keyboard.h
@@ -1,198 +1,196 @@
#ifndef _keyboard_h
#define _keyboard_h
#include <map>
#include <vector>
-// using namespace std;
-
/* handles allegro key[] array better than keypressed()
* and readkey()
*/
class Keyboard{
public:
Keyboard();
/* poll:
* Put the keys in Allegro's key[] array into our map of int -> bool
*/
void poll();
/* wait for all keys to be released */
void wait();
/* []:
* Extract a boolean value given a key number
*/
inline const bool operator[] ( const int i ){
/* if the key has been pressed for the first time return true */
if ( my_keys[ i ] < 0 ){
my_keys[ i ] = 1;
return true;
}
bool b = my_keys[ i ] > key_delay[ i ];
if ( b ){
my_keys[ i ] = 1;
}
return b;
}
/* keypressed:
* Returns true if a key is pressed
*/
const bool keypressed();
/* readKeys:
* Store all pressed keys in a user supplied vector
*/
void readKeys( std::vector< int > & all_keys );
const int readKey();
void clear();
void setDelay( const int key, const int delay );
void setAllDelay( const int delay );
static const char * keyToName( int key );
static const bool isNumber( int key );
static const bool isChar( int key );
static const bool isAlpha( int key );
static const int Key_A;
static const int Key_B;
static const int Key_C;
static const int Key_D;
static const int Key_E;
static const int Key_F;
static const int Key_G;
static const int Key_H;
static const int Key_I;
static const int Key_J;
static const int Key_K;
static const int Key_L;
static const int Key_M;
static const int Key_N;
static const int Key_O;
static const int Key_P;
static const int Key_Q;
static const int Key_R;
static const int Key_S;
static const int Key_T;
static const int Key_U;
static const int Key_V;
static const int Key_W;
static const int Key_X;
static const int Key_Y;
static const int Key_Z;
static const int Key_0;
static const int Key_1;
static const int Key_2;
static const int Key_3;
static const int Key_4;
static const int Key_5;
static const int Key_6;
static const int Key_7;
static const int Key_8;
static const int Key_9;
static const int Key_0_PAD;
static const int Key_1_PAD;
static const int Key_2_PAD;
static const int Key_3_PAD;
static const int Key_4_PAD;
static const int Key_5_PAD;
static const int Key_6_PAD;
static const int Key_7_PAD;
static const int Key_8_PAD;
static const int Key_9_PAD;
static const int Key_F1;
static const int Key_F2;
static const int Key_F3;
static const int Key_F4;
static const int Key_F5;
static const int Key_F6;
static const int Key_F7;
static const int Key_F8;
static const int Key_F9;
static const int Key_F10;
static const int Key_F11;
static const int Key_F12;
static const int Key_ESC;
static const int Key_TILDE;
static const int Key_MINUS;
static const int Key_EQUALS;
static const int Key_BACKSPACE;
static const int Key_TAB;
static const int Key_OPENBRACE;
static const int Key_CLOSEBRACE;
static const int Key_ENTER;
static const int Key_COLON;
static const int Key_QUOTE;
static const int Key_BACKSLASH;
static const int Key_BACKSLASH2;
static const int Key_COMMA;
static const int Key_STOP;
static const int Key_SLASH;
static const int Key_SPACE;
static const int Key_INSERT;
static const int Key_DEL;
static const int Key_HOME;
static const int Key_END;
static const int Key_PGUP;
static const int Key_PGDN;
static const int Key_LEFT;
static const int Key_RIGHT;
static const int Key_UP;
static const int Key_DOWN;
static const int Key_SLASH_PAD;
static const int Key_ASTERISK;
static const int Key_MINUS_PAD;
static const int Key_PLUS_PAD;
static const int Key_DEL_PAD;
static const int Key_ENTER_PAD;
static const int Key_PRTSCR;
static const int Key_PAUSE;
static const int Key_ABNT_C1;
static const int Key_YEN;
static const int Key_KANA;
static const int Key_CONVERT;
static const int Key_NOCONVERT;
static const int Key_AT;
static const int Key_CIRCUMFLEX;
static const int Key_COLON2;
static const int Key_KANJI;
static const int Key_EQUALS_PAD;
static const int Key_BACKQUOTE;
static const int Key_SEMICOLON;
static const int Key_COMMAND;
static const int Key_UNKNOWN1;
static const int Key_UNKNOWN2;
static const int Key_UNKNOWN3;
static const int Key_UNKNOWN4;
static const int Key_UNKNOWN5;
static const int Key_UNKNOWN6;
static const int Key_UNKNOWN7;
static const int Key_UNKNOWN8;
static const int Key_MODIFIERS;
static const int Key_LSHIFT;
static const int Key_RSHIFT;
static const int Key_LCONTROL;
static const int Key_RCONTROL;
static const int Key_ALT;
static const int Key_ALTGR;
static const int Key_LWIN;
static const int Key_RWIN;
static const int Key_MENU;
static const int Key_SCRLOCK;
static const int Key_NUMLOCK;
static const int Key_CAPSLOCK;
protected:
std::map<int,int> my_keys;
std::map<int,int> key_delay;
};
#endif
diff --git a/util/sound.h b/util/sound.h
index a1b274b3..41e55b71 100644
--- a/util/sound.h
+++ b/util/sound.h
@@ -1,37 +1,35 @@
#ifndef _pain_sound_h
#define _pain_sound_h
#include <string>
#include "load_exception.h"
struct SAMPLE;
-using namespace std;
-
/* a sound! */
class Sound{
public:
Sound();
- Sound( const string & path ) throw( LoadException );
+ Sound( const std::string & path ) throw( LoadException );
Sound( const Sound & copy );
Sound & operator=( const Sound & rhs );
void play();
void play( int volume, int pan );
void playLoop();
virtual ~Sound();
protected:
void destroy();
SAMPLE * my_sound;
/* reference counting */
int * own;
};
#endif
diff --git a/util/timedifference.h b/util/timedifference.h
index 3a882af4..f41d48d6 100644
--- a/util/timedifference.h
+++ b/util/timedifference.h
@@ -1,39 +1,37 @@
#ifndef _time_difference_h
#define _time_difference_h
#include <time.h>
#include <sys/time.h>
#include <string>
-using namespace std;
-
class TimeDifference{
public:
TimeDifference();
inline void startTime(){
#ifndef WINDOWS
gettimeofday( &start, NULL );
#endif
}
inline void endTime(){
#ifndef WINDOWS
gettimeofday( &end, NULL );
#endif
}
unsigned long long int getTime();
- const string printTime();
- const string printTime( const string & s );
+ const std::string printTime();
+ const std::string printTime( const std::string & s );
~TimeDifference();
protected:
struct timeval start, end;
};
#endif
diff --git a/util/token.cpp b/util/token.cpp
index 8e7e3909..8e7ecc7d 100644
--- a/util/token.cpp
+++ b/util/token.cpp
@@ -1,249 +1,257 @@
#include "token.h"
#include "token_exception.h"
#include <string>
#include <vector>
#include <ostream>
#include <sstream>
#include <iostream>
using namespace std;
Token::Token():
num_token(1),
parent( NULL ),
own(true){
name = "HEAD";
}
Token::Token( string tok, bool parse ):
num_token( 1 ),
parent( NULL ),
own(true){
/* legacy code, not used much */
if ( !parse ){
name = tok;
while ( name.find(' ' ) == 0 )
name.erase( 0, 1 );
// lowerCase( name );
return;
}
}
Token::Token(Token const & copy):
num_token(1),
parent(copy.parent),
own(false){
this->tokens = copy.tokens;
this->name = copy.name;
this->filename = copy.filename;
}
/* Dump token to the screen */
void Token::print( const string & space ){
cout<<space<<"Token: "<< getName() << endl;
for ( signed int i = 0; i < numTokens(); i++ ){
Token * x = getToken( i );
x->print( space + " |--" );
}
}
void Token::toString( ostream & stream, const string & space ){
if ( numTokens() == -1 ){
stream << getName();
} else {
stream << endl;
stream << space << "(" << getName();
for ( signed int i = 0; i < numTokens(); i++ ){
Token * x = getToken( i );
stream << " ";
x->toString( stream, space + " " );
}
stream << ")";
}
}
/* helper function */
string Token::lowerCase( const string & s ){
string ret;
for ( unsigned int q = 0; q < s.length(); q++ ){
if ( s[q] >= 'A' && s[q] <= 'Z' ){
ret += s[q] - 'A' + 'a';
} else {
ret += s[q];
}
}
return ret;
}
/* Return next token and increment the internal position
* of the current token
*/
Token * Token::readToken(){
if ( num_token < tokens.size() ){
return tokens[ num_token++ ];
}
return NULL;
}
bool Token::hasTokens(){
return num_token < tokens.size();
}
Token * Token::getToken( unsigned int n ){
int q = numTokens();
if ( q == -1 ) return NULL;
if ( n >= 0 && (signed int)n < q )
return tokens[n+1];
return NULL;
}
/* If the token has children then the name of this token
* is the name of the first child token.
* Otherwise, the name is this token's name
*/
const string & Token::getName() const {
if ( numTokens() != -1 ){
return tokens[0]->_getName();
}
// cout<<"No tokens!!"<<endl;
return name;
}
const Token * const Token::getParent() const {
return this->parent;
}
const string Token::getLineage() const {
if ( getParent() != NULL ){
return getParent()->getLineage() + " -> " + getName();
}
return getName();
}
/* A token's identity is its name
*/
bool Token::operator== ( const string & rhs ){
return lowerCase( getName() ) == lowerCase( rhs );
}
bool Token::operator!= ( const string & rhs ){
return !( *this == rhs );
}
/* extracting operators */
Token & Token::operator>>( Token * & rhs ) throw( TokenException ){
Token * x = readToken();
if ( x == NULL ){
throw TokenException( getFileName() + ": " + string("Tried to read a token from ") + this->getName() + string(" but there are no more elements") );
}
rhs = x;
return *this;
}
void Token::setFile( const string & s ){
filename = s;
}
const string Token::getFileName() const {
if ( parent ){
return parent->getFileName();
} else {
return filename;
}
}
Token & Token::operator>>( string & rhs ) throw( TokenException ){
Token * l = readToken();
if ( l == NULL ){
throw TokenException( getFileName() + ":" + string("Tried to read a string from ") + this->getLineage() + string(" but there no more elements") );
}
rhs = l->getName();
// rhs = getName();
return *this;
}
Token & Token::operator>>( int & rhs ) throw( TokenException ){
Token * l = readToken();
if ( l == NULL ){
throw TokenException( getFileName() + ": " + string("Tried to read an int from ") + this->getLineage() + string(" but there are no more elements") );
}
istringstream is ( l->getName() );
is >> rhs;
return *this;
}
Token & Token::operator>>( double & rhs ) throw( TokenException ){
Token * l = readToken();
if ( l == NULL ){
throw TokenException( getFileName() + ": " + string("Tried to read a double from ") + this->getLineage() + string(" but there no more elements") );
}
istringstream is ( l->getName() );
is >> rhs;
return *this;
}
Token & Token::operator>>( bool & rhs ) throw( TokenException ){
Token * l = readToken();
if ( l == NULL ){
throw TokenException( getFileName() + ": " + string("Tried to read a bool from ") + this->getLineage() + string(" but there no more elements") );
}
istringstream is ( l->getName() );
is >> rhs;
return *this;
}
void Token::addToken(Token * t) throw (TokenException){
if (!own){
throw TokenException("This token does not own its own tokens, so you cannot add tokens to it");
}
tokens.push_back( t );
}
-
+
+/* put quotes around a string if there are spaces in it */
+static string quoteify(const string & rhs){
+ if (rhs.find(' ') != string::npos){
+ return "\"" + rhs + "\"";
+ }
+ return rhs;
+}
+
Token & Token::operator<<( const string & rhs ){
- Token * n = new Token( rhs, false );
- this->addToken( n );
+ Token * n = new Token(quoteify(rhs), false );
+ this->addToken(n);
return *this;
}
Token & Token::operator<<( const int rhs ){
ostringstream o;
o << rhs;
return *this << o.str();
}
Token & Token::operator<<( const double rhs ){
ostringstream o;
o << rhs;
return *this << o.str();
}
/* Delete tokens that are commented.
* A commented token has a '!' character as the first
* character in the name, e.g:
* (!a_token (child_token 2))
*/
void Token::finalize(){
for ( vector< Token * >::iterator it = tokens.begin(); it != tokens.end(); ){
Token * t = *it;
if ( t->getName().find('!') == 0 ){
delete t;
it = tokens.erase( it );
} else {
t->finalize();
it++;
}
}
}
Token::~Token(){
if (own){
for ( vector< Token * >::iterator it = tokens.begin(); it != tokens.end(); it++ ){
delete *it;
}
}
}
diff --git a/util/token.h b/util/token.h
index 8f7079a3..4314fb4d 100644
--- a/util/token.h
+++ b/util/token.h
@@ -1,98 +1,96 @@
#ifndef _token_h
#define _token_h
#include <string>
#include <vector>
#include <ostream>
#include "token_exception.h"
class TokenReader;
class Configuration;
-using namespace std;
-
/* Token:
* Basically a tree where each node stores a value in a string
* and can have 0 or more children
*/
class Token{
public:
Token(Token const & copy);
virtual ~Token();
- void addToken( Token * t ) throw (TokenException);
+ void addToken( Token * t ) throw (TokenException);
/*
inline const string & getName(){
return name;
}
*/
- const string & getName() const;
+ const std::string & getName() const;
const Token * const getParent() const;
- void setFile( const string & s );
- const string getFileName() const;
+ void setFile( const std::string & s );
+ const std::string getFileName() const;
- const string getLineage() const;
+ const std::string getLineage() const;
- void print( const string & space );
- void toString( ostream & stream, const string & space );
+ void print( const std::string & space );
+ void toString( std::ostream & stream, const std::string & space );
Token * getToken( unsigned int n );
inline signed int numTokens() const{
return tokens.size() - 1;
}
- inline const vector< Token * > * getTokens() const{
+ inline const std::vector< Token * > * getTokens() const{
return &tokens;
}
inline void resetToken(){
num_token = 1;
}
Token * readToken();
bool hasTokens();
- bool operator== ( const string & rhs );
- bool operator!= ( const string & rhs );
+ bool operator== ( const std::string & rhs );
+ bool operator!= ( const std::string & rhs );
- Token & operator>>( string & rhs ) throw( TokenException );
+ Token & operator>>( std::string & rhs ) throw( TokenException );
Token & operator>>( int & rhs ) throw( TokenException );
Token & operator>>( double & rhs ) throw( TokenException );
Token & operator>>( Token * & rhs ) throw( TokenException );
Token & operator>>( bool & rhs ) throw( TokenException );
protected:
/* Only TokenReader and Configuration can create and destroy a Token */
Token();
- Token( string tok, bool parse = true );
+ Token( std::string tok, bool parse = true );
friend class TokenReader;
friend class Configuration;
- Token & operator<<( const string & rhs );
+ Token & operator<<( const std::string & rhs );
Token & operator<<( const int rhs );
Token & operator<<( const double rhs );
- virtual inline const string & _getName(){
+ virtual inline const std::string & _getName(){
return name;
}
virtual inline void setParent( const Token * const parent ){
this->parent = parent;
}
- string lowerCase( const string & s );
+ std::string lowerCase( const std::string & s );
void finalize();
unsigned int num_token;
- vector< Token * > tokens;
- string filename;
+ std::vector< Token * > tokens;
+ std::string filename;
Token const * parent;
- string name;
+ std::string name;
bool own;
};
#endif
diff --git a/util/token_exception.cpp b/util/token_exception.cpp
index 3854ed2f..b4c75d06 100644
--- a/util/token_exception.cpp
+++ b/util/token_exception.cpp
@@ -1,15 +1,15 @@
#include <exception>
#include <string>
#include "token_exception.h"
TokenException::TokenException():
-exception(){
+std::exception(){
}
-TokenException::TokenException( const string & reason ):
-exception(){
+TokenException::TokenException( const std::string & reason ):
+std::exception(){
this->reason = reason;
}
TokenException::~TokenException() throw() {
}
diff --git a/util/token_exception.h b/util/token_exception.h
index e641c5ee..edfc61d7 100644
--- a/util/token_exception.h
+++ b/util/token_exception.h
@@ -1,25 +1,22 @@
#ifndef _token_exception_h
#define _token_exception_h
#include <exception>
#include <string>
-using namespace std;
-
-class TokenException : public exception {
+class TokenException : public std::exception {
public:
- TokenException();
- TokenException( const string & reason );
+ TokenException();
+ TokenException( const std::string & reason );
- ~TokenException() throw();
+ virtual ~TokenException() throw();
- inline const string & getReason() const{
- return reason;
- }
+ inline const std::string & getReason() const{
+ return reason;
+ }
protected:
- string reason;
-
+ std::string reason;
};
#endif
diff --git a/util/tokenreader.h b/util/tokenreader.h
index 27c24840..9e7b5412 100644
--- a/util/tokenreader.h
+++ b/util/tokenreader.h
@@ -1,29 +1,27 @@
#ifndef _tokenreader_h
#define _tokenreader_h
#include <fstream>
#include <string>
#include <vector>
#include "token_exception.h"
-using namespace std;
-
class Token;
class TokenReader{
public:
- TokenReader( const string & s );
+ TokenReader( const std::string & s );
TokenReader( const char * filename );
- Token * readToken() throw( TokenException );
+ virtual Token * readToken() throw (TokenException);
- ~TokenReader();
+ virtual ~TokenReader();
protected:
- ifstream ifile;
- string myfile;
- vector< Token * > my_tokens;
+ std::ifstream ifile;
+ std::string myfile;
+ std::vector< Token * > my_tokens;
};
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:47 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69315
Default Alt Text
(46 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline