Skip to content

Commit

Permalink
include cstdint for gcc13 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
toge committed Jun 26, 2024
1 parent 1969a3c commit fb5a4ed
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
9 changes: 5 additions & 4 deletions src/sql/ColumnType.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SQLPARSER_COLUMN_TYPE_H

#include <ostream>
#include <cstdint>

namespace hsql {
enum class DataType {
Expand All @@ -26,11 +27,11 @@ enum class DataType {
// Represents the type of a column, e.g., FLOAT or VARCHAR(10)
struct ColumnType {
ColumnType() = default;
ColumnType(DataType data_type, int64_t length = 0, int64_t precision = 0, int64_t scale = 0);
ColumnType(DataType data_type, std::int64_t length = 0, std::int64_t precision = 0, std::int64_t scale = 0);
DataType data_type;
int64_t length; // Used for, e.g., VARCHAR(10)
int64_t precision; // Used for, e.g., DECIMAL (6, 4) or TIME (5)
int64_t scale; // Used for DECIMAL (6, 4)
std::int64_t length; // Used for, e.g., VARCHAR(10)
std::int64_t precision; // Used for, e.g., DECIMAL (6, 4) or TIME (5)
std::int64_t scale; // Used for DECIMAL (6, 4)
};

bool operator==(const ColumnType& lhs, const ColumnType& rhs);
Expand Down
9 changes: 5 additions & 4 deletions src/sql/Expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include <stdio.h>
#include <string.h>
#include "SelectStatement.h"
#include <cstdint>

namespace hsql {

FrameBound::FrameBound(int64_t offset, FrameBoundType type, bool unbounded)
FrameBound::FrameBound(std::int64_t offset, FrameBoundType type, bool unbounded)
: offset{offset}, type{type}, unbounded{unbounded} {}

FrameDescription::FrameDescription(FrameType type, FrameBound* start, FrameBound* end)
Expand Down Expand Up @@ -140,7 +141,7 @@ Expr* Expr::makeCase(Expr* expr, Expr* caseList, Expr* elseExpr) {
return e;
}

Expr* Expr::makeLiteral(int64_t val) {
Expr* Expr::makeLiteral(std::int64_t val) {
Expr* e = new Expr(kExprLiteralInt);
e->ival = val;
return e;
Expand Down Expand Up @@ -176,7 +177,7 @@ Expr* Expr::makeDateLiteral(char* string) {
return e;
}

Expr* Expr::makeIntervalLiteral(int64_t duration, DatetimeField unit) {
Expr* Expr::makeIntervalLiteral(std::int64_t duration, DatetimeField unit) {
Expr* e = new Expr(kExprLiteralInterval);
e->ival = duration;
e->datetimeField = unit;
Expand Down Expand Up @@ -222,7 +223,7 @@ Expr* Expr::makeArray(std::vector<Expr*>* exprList) {
return e;
}

Expr* Expr::makeArrayIndex(Expr* expr, int64_t index) {
Expr* Expr::makeArrayIndex(Expr* expr, std::int64_t index) {
Expr* e = new Expr(kExprArrayIndex);
e->expr = expr;
e->ival = index;
Expand Down
14 changes: 7 additions & 7 deletions src/sql/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ enum DatetimeField {
// Description of the frame clause within a window expression.
enum FrameBoundType { kFollowing, kPreceding, kCurrentRow };
struct FrameBound {
FrameBound(int64_t offset, FrameBoundType type, bool unbounded);
FrameBound(std::int64_t offset, FrameBoundType type, bool unbounded);

int64_t offset;
std::int64_t offset;
FrameBoundType type;
bool unbounded;
};
Expand Down Expand Up @@ -135,8 +135,8 @@ struct Expr {
char* table;
char* alias;
double fval;
int64_t ival;
int64_t ival2;
std::int64_t ival;
std::int64_t ival2;
DatetimeField datetimeField;
ColumnType columnType;
bool isBoolLiteral;
Expand Down Expand Up @@ -176,7 +176,7 @@ struct Expr {

static Expr* makeCase(Expr* expr, Expr* when, Expr* elseExpr);

static Expr* makeLiteral(int64_t val);
static Expr* makeLiteral(std::int64_t val);

static Expr* makeLiteral(double val);

Expand All @@ -188,7 +188,7 @@ struct Expr {

static Expr* makeDateLiteral(char* val);

static Expr* makeIntervalLiteral(int64_t duration, DatetimeField unit);
static Expr* makeIntervalLiteral(std::int64_t duration, DatetimeField unit);

static Expr* makeColumnRef(char* name);

Expand All @@ -202,7 +202,7 @@ struct Expr {

static Expr* makeArray(std::vector<Expr*>* exprList);

static Expr* makeArrayIndex(Expr* expr, int64_t index);
static Expr* makeArrayIndex(Expr* expr, std::int64_t index);

static Expr* makeParameter(int id);

Expand Down
3 changes: 2 additions & 1 deletion src/sql/statements.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "statements.h"
#include "AlterStatement.h"
#include <cstdint>

namespace hsql {

Expand All @@ -23,7 +24,7 @@ ColumnDefinition::~ColumnDefinition() {
delete column_constraints;
}

ColumnType::ColumnType(DataType data_type, int64_t length, int64_t precision, int64_t scale)
ColumnType::ColumnType(DataType data_type, std::int64_t length, std::int64_t precision, std::int64_t scale)
: data_type(data_type), length(length), precision(precision), scale(scale) {}

bool operator==(const ColumnType& lhs, const ColumnType& rhs) {
Expand Down
7 changes: 4 additions & 3 deletions src/util/sqlhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <map>
#include <sstream>
#include <string>
#include <cstdint>

namespace hsql {

Expand All @@ -15,7 +16,7 @@ std::ostream& operator<<(std::ostream& os, const DatetimeField& datetime);
std::ostream& operator<<(std::ostream& os, const FrameBound& frame_bound);

std::string indent(uintmax_t num_indent) { return std::string(num_indent, '\t'); }
void inprint(int64_t val, uintmax_t num_indent) { std::cout << indent(num_indent).c_str() << val << " " << std::endl; }
void inprint(std::int64_t val, uintmax_t num_indent) { std::cout << indent(num_indent).c_str() << val << " " << std::endl; }
void inprint(double val, uintmax_t num_indent) { std::cout << indent(num_indent).c_str() << val << std::endl; }
void inprint(const char* val, uintmax_t num_indent) { std::cout << indent(num_indent).c_str() << val << std::endl; }
void inprint(const char* val, const char* val2, uintmax_t num_indent) {
Expand Down Expand Up @@ -452,7 +453,7 @@ std::ostream& operator<<(std::ostream& os, const OperatorType& op) {

const auto found = operatorToToken.find(op);
if (found == operatorToToken.cend()) {
return os << static_cast<uint64_t>(op);
return os << static_cast<std::uint64_t>(op);
} else {
return os << (*found).second;
}
Expand All @@ -465,7 +466,7 @@ std::ostream& operator<<(std::ostream& os, const DatetimeField& datetime) {

const auto found = operatorToToken.find(datetime);
if (found == operatorToToken.cend()) {
return os << static_cast<uint64_t>(datetime);
return os << static_cast<std::uint64_t>(datetime);
} else {
return os << (*found).second;
}
Expand Down

0 comments on commit fb5a4ed

Please sign in to comment.