File:  [parser3project] / parser3 / src / include / Attic / pa_vint.h
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Sat Mar 10 16:34:36 2001 UTC (25 years, 4 months ago) by paf
Branches: MAIN
CVS tags: HEAD
sources header

/*
	Parser
	Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
	Author: Alexander Petrosyan <paf@design.ru>

	$Id: pa_vint.h,v 1.4 2001/03/10 16:34:36 paf Exp $
*/

#ifndef PA_VINT_H
#define PA_VINT_H

#include "pa_value.h"
#include "pa_common.h"
#include "classes/_int.h"

#define MAX_INT_AS_STRING 20

class VInt : public VObject {
public: // Value

	// all: for error reporting after fail(), etc
	const char *type() const { return "int"; }
	// int: this
	Value *get_expr_result() { return this; }

	// integer: finteger
	const String *get_string() {
		char *buf=static_cast<char *>(pool().malloc(MAX_INT_AS_STRING));
		snprintf(buf, MAX_INT_AS_STRING, "%d", finteger);
		String *result=NEW String(pool());
		result->APPEND_CONST(buf);
		return result;
	}
	// integer: finteger
	double get_double() { return finteger; }
	// integer: 0 or !0
	bool get_bool() { return finteger!=0; }

public: // usage

	VInt(Pool& apool, int ainteger) : VObject(apool, *int_class), 
		finteger(ainteger) {
	}

	int get_int() { return finteger; }

	void inc(int increment) { finteger+=increment; }

private:

	int finteger;

};

#endif

E-mail: