|
MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
属性的值 更多...
#include <value.h>
类 | |
| union | Val |
Public 成员函数 | |
| Value (AttrType attr_type, char *data, int length=4) | |
| Value (int val) | |
| Value (float val) | |
| Value (bool val) | |
| Value (const char *s, int len=0) | |
| Value (const string_t &val) | |
| Value (const Value &other) | |
| Value (Value &&other) | |
| Value & | operator= (const Value &other) |
| Value & | operator= (Value &&other) |
| void | reset () |
| void | set_type (AttrType type) |
| void | set_data (char *data, int length) |
| void | set_data (const char *data, int length) |
| void | set_value (const Value &value) |
| void | set_boolean (bool val) |
| string | to_string () const |
| int | compare (const Value &other) const |
| char * | data () const |
| int | length () const |
| AttrType | attr_type () const |
| int | get_int () const |
| float | get_float () const |
| string | get_string () const |
| string_t | get_string_t () const |
| bool | get_boolean () const |
| void | set_int (int val) |
| void | set_float (float val) |
| void | set_string (const char *s, int len=0) |
| void | set_empty_string (int len) |
| void | set_string_from_other (const Value &other) |
静态 Public 成员函数 | |
| static RC | add (const Value &left, const Value &right, Value &result) |
| static RC | subtract (const Value &left, const Value &right, Value &result) |
| static RC | multiply (const Value &left, const Value &right, Value &result) |
| static RC | divide (const Value &left, const Value &right, Value &result) |
| static RC | negative (const Value &value, Value &result) |
| static RC | cast_to (const Value &value, AttrType to_type, Value &result) |
Private 属性 | |
| AttrType | attr_type_ = AttrType::UNDEFINED |
| int | length_ = 0 |
| union Value::Val | value_ = {.int_value_ = 0} |
| bool | own_data_ = false |
| 是否申请并占有内存, 目前对于 CHARS 类型 own_data_ 为true, 其余类型 own_data_ 为false | |
友元 | |
| class | DataType |
| class | IntegerType |
| class | FloatType |
| class | BooleanType |
| class | CharType |
| class | VectorType |
属性的值
与DataType,就是数据类型,配套完成各种算术运算、比较、类型转换等操作。这里同时记录了数据的值与类型。 当需要对值做运算时,建议使用类似 Value::add 的操作而不是 DataType::add。在进行运算前,应该设置好结果的类型, 比如进行两个INT类型的除法运算时,结果类型应该设置为FLOAT。
| int Value::get_int | ( | ) | const |
获取对应的值 如果当前的类型与期望获取的类型不符,就会执行转换操作