aboutsummaryrefslogtreecommitdiffstats
path: root/using.h
blob: ad73607e9a02cd7b934e6c56abaa77cb47af24b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef INCLUDE_BLASSIC_USING_H
#define INCLUDE_BLASSIC_USING_H

// using.h
// Revision 7-feb-2005

#include "error.h"
#include "file.h"

#include <iostream>
#include <string>


class Using {
protected:
	Using () { }
public:
	virtual ~Using ();
	virtual Using * clone () const= 0;
	virtual bool isliteral () const;
	virtual void putliteral (blassic::file::BlFile &) const= 0;
	virtual void putnumeric (blassic::file::BlFile &, BlNumber) const;
	virtual void putstring (blassic::file::BlFile &,
		const std::string &) const;
};

class UsingLiteral : public Using {
public:
	UsingLiteral (std::istream & is);
	UsingLiteral (std::istream & is, const std::string & strinit);
	UsingLiteral (const std::string & strinit);
	UsingLiteral * clone () const
	{ return new UsingLiteral (* this); }
	bool isliteral () const;
	const std::string & str () const { return s; }
	void addstr (const std::string & stradd);
	void putliteral (blassic::file::BlFile & out) const;
	void putnumeric (blassic::file::BlFile &, BlNumber) const;
	void putstring (blassic::file::BlFile &, const std::string &) const;
private:
	std::string s;
	void init (std::istream & is);
};

class UsingNumeric : public Using {
public:
	UsingNumeric (std::istream & is, std::string & tail);
	UsingNumeric * clone () const
	{ return new UsingNumeric (* this); }
	const std::string & str () const { return s; }
	bool isvalid () const { return ! invalid; }
	void putliteral (blassic::file::BlFile &) const;
	void putnumeric (blassic::file::BlFile & out, BlNumber n) const;
private:
	bool invalid;
	std::string s;
	size_t digit, decimal, scientific;
	bool milliards, putsign, signatend, blankpositive;
	bool asterisk, dollar, pound, euro;
};

class UsingString : public Using {
public:
	UsingString (std::istream & is);
	UsingString * clone () const
	{ return new UsingString (* this); }
	void putliteral (blassic::file::BlFile &) const;
	void putstring (blassic::file::BlFile & out,
		const std::string & str) const;
private:
	size_t n;
};

class VectorUsing
{
public:
	VectorUsing ();
	~VectorUsing ();
	size_t size () const { return v.size (); }
	bool empty () const { return v.empty (); }
	Using * & back () { return v.back (); }
	Using * & operator [] (size_t i) { return v [i]; }
	void push_back (const Using & u);
private:
	VectorUsing (const VectorUsing &); // Forbidden
	VectorUsing & operator = (const VectorUsing &); // Forbidden
	static void delete_it (const Using * u) { delete u; }

	std::vector <Using *>  v;
};

void parseusing (const std::string & str, VectorUsing & vu);

#endif

// End of using.h
Un proyecto texto-plano.xyz