~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/lib/std/shl/obj/Boolean.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - Boolean.hpp                                                             -
3
 
// - standard object library - boolean class definition                      -
4
 
// ---------------------------------------------------------------------------
5
 
// - This program is free software;  you can redistribute it  and/or  modify -
6
 
// - it provided that this copyright notice is kept intact.                  -
7
 
// -                                                                         -
8
 
// - This program  is  distributed in  the hope  that it will be useful, but -
9
 
// - without  any  warranty;  without  even   the   implied    warranty   of -
10
 
// - merchantability or fitness for a particular purpose.  In no event shall -
11
 
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
 
// - special damages arising in any way out of the use of this software.     -
13
 
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
15
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_BOOLEAN_HPP
18
 
#define  AFNIX_BOOLEAN_HPP
19
 
 
20
 
#ifndef  AFNIX_LITERAL_HPP
21
 
#include "Literal.hpp"
22
 
#endif
23
 
 
24
 
namespace afnix {
25
 
 
26
 
  /// The Boolean class is a builtin object for the boolean native type.
27
 
  /// The Boolean class accepts only two values (true or false) and is mostly
28
 
  /// used for binary testing. There is no automatic conversion from or to the
29
 
  /// boolean type - except for string representation.
30
 
  /// @author amaury darsch
31
 
 
32
 
  class Boolean : public Literal {
33
 
  private:
34
 
    /// the native boolean representation
35
 
    bool d_value;
36
 
 
37
 
  public:
38
 
    /// create a new default boolean - by default it is false
39
 
    Boolean (void);
40
 
 
41
 
    /// create a new boolean from a native boolean
42
 
    /// @param value the value to create
43
 
    Boolean (const bool value);
44
 
 
45
 
    /// create a new boolean from a string
46
 
    /// @param value the value to convert
47
 
    Boolean (const String& value);
48
 
 
49
 
    /// copy constructor for this boolean
50
 
    /// @param that the boolean class to copy
51
 
    Boolean (const Boolean& that);
52
 
 
53
 
    /// @return the class name
54
 
    String repr (void) const;
55
 
 
56
 
    /// @return a literal representation of this boolean
57
 
    String toliteral (void) const;
58
 
 
59
 
    /// @return a string representation of this boolean
60
 
    String tostring (void) const;
61
 
 
62
 
    /// @return a clone of this boolean
63
 
    Object* clone (void) const;
64
 
 
65
 
    /// @return the boolean serial code
66
 
    t_byte serialid (void) const;
67
 
 
68
 
    /// serialize this boolean to an output stream
69
 
    /// @param os the output stream to write
70
 
    void wrstream (class Output& os) const;
71
 
 
72
 
    /// deserialize a boolean from an input stream
73
 
    /// @param is the input steam to read in
74
 
    void rdstream (class Input& is);
75
 
 
76
 
    /// @return the boolean value of this boolean
77
 
    bool toboolean (void) const;
78
 
 
79
 
    /// assign a boolean with a native value
80
 
    /// @param value the value to assign
81
 
    Boolean& operator = (const bool value);
82
 
 
83
 
    /// assign a boolean with a boolean
84
 
    /// @param value the value to assign
85
 
    Boolean& operator = (const Boolean& value);
86
 
 
87
 
    /// compare this boolean with a native value
88
 
    /// @param value the value to compare
89
 
    /// @return true if they are equals
90
 
    bool operator == (const bool value) const;
91
 
 
92
 
    /// compare this boolean with a native value
93
 
    /// @param value the value to compare
94
 
    /// @return true if they are not equals
95
 
    bool operator != (const bool value) const;
96
 
 
97
 
    /// compare two booleans
98
 
    /// @param value the value to compare
99
 
    /// @return true if they are equals
100
 
    bool operator == (const Boolean& value) const;
101
 
 
102
 
    /// compare two boolean
103
 
    /// @param value the value to compare
104
 
    /// @return true if they are not equals
105
 
    bool operator != (const Boolean& value) const;
106
 
 
107
 
  public:
108
 
    /// evaluate an object to a boolean value
109
 
    /// @param robj the current runnable
110
 
    /// @param nset the current nameset
111
 
    /// @param object the object to evaluate
112
 
    static bool evalto (Runnable* robj, Nameset* nset, Object* object);
113
 
 
114
 
    /// create a new object in a generic way
115
 
    /// @param argv the argument vector
116
 
    static Object* mknew (Vector* argv);
117
 
 
118
 
    /// @return true if the given quark is defined
119
 
    bool isquark (const long quark, const bool hflg) const;
120
 
 
121
 
    /// operate this object with another object
122
 
    /// @param type   the operator type
123
 
    /// @param object the operand object
124
 
    Object* oper (t_oper type, Object* object);
125
 
 
126
 
    /// set an object to this boolean
127
 
    /// @param robj   the current runnable
128
 
    /// @param nset   the current nameset
129
 
    /// @param object the object to set
130
 
    Object* vdef (Runnable* robj, Nameset* nset, Object* object);
131
 
 
132
 
    /// apply this object with a set of arguments and a quark
133
 
    /// @param robj  the current runnable
134
 
    /// @param nset  the current nameset    
135
 
    /// @param quark the quark to apply these arguments
136
 
    /// @param argv  the arguments to apply
137
 
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
138
 
                   Vector* argv);
139
 
    
140
 
  public:
141
 
    // the memory allocation
142
 
    void* operator new    (const t_size size);
143
 
    void  operator delete (void* handle);
144
 
  };
145
 
}
146
 
 
147
 
#endif