field.h 1.5 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
羽飞's avatar
羽飞 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by Wangyunlai on 2022/07/05.
//

羽飞's avatar
羽飞 已提交
15 16
#pragma once

羽飞's avatar
羽飞 已提交
17 18
#include "storage/table/table.h"
#include "storage/field/field_meta.h"
羽飞's avatar
羽飞 已提交
19

羽飞's avatar
羽飞 已提交
20 21 22 23
/**
 * @brief 字段
 * 
 */
羽飞's avatar
羽飞 已提交
24 25
class Field 
{
羽飞's avatar
羽飞 已提交
26 27 28
public:
  Field() = default;
  Field(const Table *table, const FieldMeta *field) : table_(table), field_(field)
羽飞's avatar
羽飞 已提交
29
  {}
羽飞's avatar
羽飞 已提交
30
  Field(const Field &) = default;
羽飞's avatar
羽飞 已提交
31

L
Longda Feng 已提交
32 33 34 35 36 37 38 39
  const Table *table() const
  {
    return table_;
  }
  const FieldMeta *meta() const
  {
    return field_;
  }
羽飞's avatar
羽飞 已提交
40

羽飞's avatar
羽飞 已提交
41 42 43 44
  AttrType attr_type() const
  {
    return field_->type();
  }
羽飞's avatar
羽飞 已提交
45

L
Longda Feng 已提交
46 47 48 49 50 51 52 53
  const char *table_name() const
  {
    return table_->name();
  }
  const char *field_name() const
  {
    return field_->name();
  }
羽飞's avatar
羽飞 已提交
54

羽飞's avatar
羽飞 已提交
55 56 57 58 59 60 61 62
  void set_table(const Table *table)
  {
    this->table_ = table;
  }
  void set_field(const FieldMeta *field)
  {
    this->field_ = field;
  }
L
Longda Feng 已提交
63

羽飞's avatar
羽飞 已提交
64 65 66
  void set_int(Record &record, int value);
  int  get_int(const Record &record);

67 68
  const char *get_data(const Record &record);

羽飞's avatar
羽飞 已提交
69
private:
羽飞's avatar
羽飞 已提交
70 71
  const Table *table_ = nullptr;
  const FieldMeta *field_ = nullptr;
羽飞's avatar
羽飞 已提交
72
};