Expr.cc 1.3 KB

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