1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // Label.h --
|
---|
8 | //
|
---|
9 | // Author : Rob Schluntz
|
---|
10 | // Created On : Wed Jun 8 12:53:12 2016
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Sat Jul 22 09:52:44 2017
|
---|
13 | // Update Count : 3
|
---|
14 | //
|
---|
15 |
|
---|
16 | #pragma once
|
---|
17 |
|
---|
18 | #include <string>
|
---|
19 | #include <list>
|
---|
20 | #include <iostream>
|
---|
21 | #include "SynTree.h"
|
---|
22 |
|
---|
23 | class Label {
|
---|
24 | public:
|
---|
25 | Label( const std::string & name = "", Statement * labelled = 0, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : name( name ), labelled( labelled ), attributes( attributes ) {}
|
---|
26 | Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {}
|
---|
27 |
|
---|
28 | const std::string & get_name() const { return name; }
|
---|
29 | void set_name( const std::string & newValue ) { name = newValue; }
|
---|
30 |
|
---|
31 | Statement * get_statement() const { return labelled; }
|
---|
32 | void set_statement( Statement * newValue ) { labelled = newValue; }
|
---|
33 | std::list< Attribute * >& get_attributes() { return attributes; }
|
---|
34 |
|
---|
35 | operator std::string() const { return name; }
|
---|
36 | bool empty() { return name.empty(); }
|
---|
37 | private:
|
---|
38 | std::string name;
|
---|
39 | Statement * labelled;
|
---|
40 | std::list< Attribute * > attributes;
|
---|
41 | };
|
---|
42 |
|
---|
43 | inline bool operator==( Label l1, Label l2 ) { return l1.get_name() == l2.get_name(); }
|
---|
44 | inline bool operator!=( Label l1, Label l2 ) { return ! (l1 == l2); }
|
---|
45 | inline bool operator<( Label l1, Label l2 ) { return l1.get_name() < l2.get_name(); }
|
---|
46 | // inline Label operator+( Label l1, Label l2 ) { return l1.get_name() + l2.get_name(); }
|
---|
47 | // inline Label operator+( Label l1, const char * str ) { return l1.get_name() + Label( str ); }
|
---|
48 | inline std::ostream & operator<<( std::ostream & out, const Label & l ) { return out << l.get_name(); }
|
---|
49 |
|
---|
50 | static const std::list< Label > noLabels;
|
---|
51 |
|
---|
52 | // Local Variables: //
|
---|
53 | // tab-width: 4 //
|
---|
54 | // mode: c++ //
|
---|
55 | // compile-command: "make install" //
|
---|
56 | // End: //
|
---|