Expr.cc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright: All Rights Reserved
  2. // Author: egametang@gmail.com (tanghai)
  3. #include <boost/lexical_cast.hpp>
  4. #include <glog/logging.h>
  5. #include "Orm/Column.h"
  6. #include "Orm/Expr.h"
  7. namespace Egametang {
  8. Expr::~Expr()
  9. {
  10. }
  11. Expr& Expr::operator=(const Expr& expr)
  12. {
  13. exprStr = expr.exprStr;
  14. return *this;
  15. }
  16. bool Expr::Empty() const
  17. {
  18. return exprStr.empty();
  19. }
  20. std::string Expr::ToString() const
  21. {
  22. return exprStr;
  23. }
  24. Not::Not(const Expr& expr)
  25. {
  26. exprStr = "not (" + expr.ToString() + ") ";
  27. }
  28. And::And(const Expr& left, const Expr& right)
  29. {
  30. exprStr = "(" + left.ToString() + ") and" + " (" + right.ToString() + ") ";
  31. }
  32. Or::Or(const Expr& left, const Expr& right)
  33. {
  34. exprStr = "(" + left.ToString() + ") or" + " (" + right.ToString() + ") ";
  35. }
  36. Oper::Oper(const Column& left, const std::string& op, const std::string& right)
  37. {
  38. exprStr = left.ToString() + " " + op + " '" + right + "'";
  39. }
  40. Oper::Oper(const Column& left, const std::string& op, const Column& right)
  41. {
  42. exprStr = left.ToString() + " " + op + " " + right.ToString();
  43. }
  44. Oper::Oper(const Column& left, const std::string& op, int right)
  45. {
  46. exprStr = left.ToString() + " " + op + " " + boost::lexical_cast<std::string>(right);
  47. }
  48. Oper::Oper(const Column& left, const std::string& op, double right)
  49. {
  50. exprStr = left.ToString() + " " + op + " " + boost::lexical_cast<std::string>(right);
  51. }
  52. } // namespace Egametang