aboutsummaryrefslogtreecommitdiff
path: root/src/astleaf.h
blob: a2b5f393a4b8b580314f6656f1ae1a90605c2259 (plain)
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
/*
 * Copyright (C) 2007-2014 Xagasoft, All rights reserved.
 *
 * This file is part of the Xagasoft Build and is released under the
 * terms of the license contained in the file LICENSE.
 */

#ifndef AST_LEAF_H
#define AST_LEAF_H

#include "astnode.h"
#include "bu/string.h"
#include "bu/formatter.h"

class AstLeaf : public AstNode
{
public:
    AstLeaf( const Location &loc, Type eType );
    AstLeaf( const Location &loc, Type eType, int iNew );
    AstLeaf( const Location &loc, Type eType, float fNew );
    AstLeaf( const Location &loc, Type eType, bool bNew );
    AstLeaf( const Location &loc, Type eType, const Bu::String &sNew );
    AstLeaf( const Location &loc, Type eType, const char *sNew );
    virtual ~AstLeaf();

    void setIntValue( int iNew );
    void setFloatValue( float fNew );
    void setBoolValue( bool bNew );
    void setStrValue( const Bu::String &sNew );

    int getIntValue() const;
    float getFloatValue() const;
    bool getBoolValue() const;
    Bu::String &getStrValue() const;

private:
    union
    {
        int iVal;
        float fVal;
        bool bVal;
        Bu::String *sVal;
    };
};

Bu::Formatter &operator<<( Bu::Formatter &f, const AstLeaf &l );

#endif