susumu.yata
null+****@clear*****
Tue Jul 8 16:01:31 JST 2014
susumu.yata 2014-07-08 16:01:31 +0900 (Tue, 08 Jul 2014) New Revision: e8657eb465a2fcb0952e6f620cc2be247d95a323 https://github.com/groonga/grnxx/commit/e8657eb465a2fcb0952e6f620cc2be247d95a323 Message: Add Expression and ExpressionBuilder. Added files: include/grnxx/expression.hpp lib/grnxx/expression.cpp Modified files: include/grnxx/Makefile.am include/grnxx/types.hpp lib/grnxx/Makefile.am Modified: include/grnxx/Makefile.am (+1 -0) =================================================================== --- include/grnxx/Makefile.am 2014-07-08 13:10:16 +0900 (427658d) +++ include/grnxx/Makefile.am 2014-07-08 16:01:31 +0900 (09ba824) @@ -4,6 +4,7 @@ pkginclude_HEADERS = \ datum.hpp \ db.hpp \ error.hpp \ + expression.hpp \ index.hpp \ library.hpp \ table.hpp \ Added: include/grnxx/expression.hpp (+90 -0) 100644 =================================================================== --- /dev/null +++ include/grnxx/expression.hpp 2014-07-08 16:01:31 +0900 (5d635f9) @@ -0,0 +1,90 @@ +#ifndef GRNXX_EXPRESSION_HPP +#define GRNXX_EXPRESSION_HPP + +#include "grnxx/types.hpp" + +namespace grnxx { + +enum OperatorType { + // TODO +}; + +class Expression { + public: + Table *table() const { + return table_; + } + DataType data_type() const { + return data_type_; + } + + friend class ExpressionBuilder; + + private: + Table *table_; + DataType data_type_; +}; + +class ExpressionBuilder { + public: + // Create an object for building expressons. + // + // Returns a poitner to the builder on success. + // On failure, returns nullptr and stores error information into "*error" if + // "error" != nullptr. + static unique_ptr<ExpressionBuilder> create(Error *error, + const Table *table); + + ~ExpressionBuilder(); + + Table *table() const { + return table_; + } + + // Push a datum. + // + // Returns true on success. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_datum(Error *error, const Datum &datum); + + // Push a column. + // + // If "name" == "_id", pushes a pseudo column associated with row IDs. + // If "name" == "_score", pushes a pseudo column associated with scores. + // + // Returns true on success. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_column(Error *error, String name); + + // Push an operator. + // + // Pops operands and pushes an operator. + // Fails if there are not enough operands. + // Fails if the combination of operands are invalid. + // + // Returns true on success. + // On failure, returns false and stores error information into "*error" if + // "error" != nullptr. + bool push_operator(Error *error, OperatorType operator_type); + + // Clear the builder. + void clear(); + + // Complete building an expression and clear the builder. + // + // Returns a poitner to the expression on success. + // On failure, returns nullptr and stores error information into "*error" if + // "error" != nullptr. + unique_ptr<Expression> release(Error *error); + + private: + Table *table_; + + explicit ExpressionBuilder(Table *table); +}; + +} // namespace grnxx + +#endif // GRNXX_EXPRESSION_HPP Modified: include/grnxx/types.hpp (+1 -0) =================================================================== --- include/grnxx/types.hpp 2014-07-08 13:10:16 +0900 (dd3660f) +++ include/grnxx/types.hpp 2014-07-08 16:01:31 +0900 (e0d5b73) @@ -316,6 +316,7 @@ enum OrderType { class Datum; class Cursor; class RecordSet; +class Expression; class ExpressionBuilder; // Database temporary object option types. Modified: lib/grnxx/Makefile.am (+1 -0) =================================================================== --- lib/grnxx/Makefile.am 2014-07-08 13:10:16 +0900 (d809770) +++ lib/grnxx/Makefile.am 2014-07-08 16:01:31 +0900 (05be14a) @@ -13,6 +13,7 @@ libgrnxx_la_SOURCES = \ cursor.cpp \ db.cpp \ error.cpp \ + expression.cpp \ index.cpp \ library.cpp \ name.cpp \ Added: lib/grnxx/expression.cpp (+47 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/expression.cpp 2014-07-08 16:01:31 +0900 (7bd70f6) @@ -0,0 +1,47 @@ +#include "grnxx/expression.hpp" + +#include "grnxx/error.hpp" + +namespace grnxx { + +unique_ptr<ExpressionBuilder> ExpressionBuilder::create(Error *error, + const Table *table) { + // TODO: Not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return nullptr; +} + +ExpressionBuilder::~ExpressionBuilder() {} + +bool ExpressionBuilder::push_datum(Error *error, const Datum &datum) { + // TODO: Not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return false; +} + +bool ExpressionBuilder::push_column(Error *error, String name) { + // TODO: Not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return false; +} + +bool ExpressionBuilder::push_operator(Error *error, + OperatorType operator_type) { + // TODO: Not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return false; +} + +void ExpressionBuilder::clear() { + // TODO: Not supported yet. +} + +unique_ptr<Expression> ExpressionBuilder::release(Error *error) { + // TODO: Not supported yet. + GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet"); + return nullptr; +} + +ExpressionBuilder::ExpressionBuilder(Table *table) : table_(table) {} + +} // namespace grnxx -------------- next part -------------- HTML����������������������������... 下载