Esempio n. 1
0
 static void bind(statement& st, ColOrName col_or_name, const std::unique_ptr<T>& v)
 {
     if (v)
         st.bind(col_or_name, *v);
     else
         st.bind(col_or_name, null);
 }
Esempio n. 2
0
inline
bool
operator == (statement const & _lhs, statement const & _rhs)
{
    if (_lhs.which() != _rhs.which()) {
        return false;
    }
    if (!(*_lhs == *_rhs)) {
        return false;
    }
    return true;
}
Esempio n. 3
0
    /** @brief Deals with x = y  for a vector y */
    inline void execute_vector_inplace_add_vector(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      if (expr[0].lhs_type_ == VECTOR_FLOAT_TYPE && expr[0].rhs_type_ == VECTOR_FLOAT_TYPE)
      {
        viennacl::vector_base<float>       & x = *(expr[0].lhs_.vector_float_);
        viennacl::vector_base<float> const & y = *(expr[0].rhs_.vector_float_);
        viennacl::linalg::avbv(x,
                               x,  1.0, 1, false, false,
                               y,  1.0, 1, false, false);
      }
      else if (expr[0].lhs_type_ == VECTOR_DOUBLE_TYPE && expr[0].rhs_type_ == VECTOR_DOUBLE_TYPE)
      {
        viennacl::vector_base<double>       & x = *(expr[0].lhs_.vector_double_);
        viennacl::vector_base<double> const & y = *(expr[0].rhs_.vector_double_);
        viennacl::linalg::avbv(x,
                               x,  1.0, 1, false, false,
                               y,  1.0, 1, false, false);
      }
      else
        throw statement_not_supported_exception("Unsupported rvalue for inplace-add to vector");
    }
    /** @brief Deals with x = y  for a vector y */
    void execute_vector_inplace_sub_vector(statement const & s)
    {
      typedef typename statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      if (expr[0].lhs_type_ == VECTOR_FLOAT_TYPE && expr[0].rhs_type_ == VECTOR_FLOAT_TYPE)
      {
        viennacl::vector_base<float>       & x = *(expr[0].lhs_.vector_float_);
        viennacl::vector_base<float> const & y = *(expr[0].rhs_.vector_float_);
        viennacl::linalg::avbv(x,
                               x,  1.0, 1, false, false,
                               y, -1.0, 1, false, false);
      }
      else if (expr[0].lhs_type_ == VECTOR_DOUBLE_TYPE && expr[0].rhs_type_ == VECTOR_DOUBLE_TYPE)
      {
        viennacl::vector_base<double>       & x = *(expr[0].lhs_.vector_double_);
        viennacl::vector_base<double> const & y = *(expr[0].rhs_.vector_double_);
        viennacl::linalg::avbv(x,
                               x,  1.0, 1, false, false,
                               y, -1.0, 1, false, false);
      }
      else
        throw "not yet supported!";
    }
    /** @brief Deals with A -= B  for a matrix B */
    inline void execute_matrix_col_inplace_sub_matrix(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      if (expr[0].lhs_type_ == MATRIX_COL_FLOAT_TYPE && expr[0].rhs_type_ == MATRIX_COL_FLOAT_TYPE)
      {
        viennacl::matrix_base<float, viennacl::column_major>       & A = *(expr[0].lhs_.matrix_col_float_);
        viennacl::matrix_base<float, viennacl::column_major> const & B = *(expr[0].rhs_.matrix_col_float_);
        viennacl::linalg::ambm(A,
                               A,  1.0, 1, false, false,
                               B, -1.0, 1, false, false);
      }
      else if (expr[0].lhs_type_ == MATRIX_COL_DOUBLE_TYPE && expr[0].rhs_type_ == MATRIX_COL_DOUBLE_TYPE)
      {
        viennacl::matrix_base<double, viennacl::column_major>       & A = *(expr[0].lhs_.matrix_col_double_);
        viennacl::matrix_base<double, viennacl::column_major> const & B = *(expr[0].rhs_.matrix_col_double_);
        viennacl::linalg::ambm(A,
                               A,  1.0, 1, false, false,
                               B, -1.0, 1, false, false);
      }
      else
        throw "not yet supported!";
    }
Esempio n. 6
0
	void do_bind(statement& st, int)
	{
		if ( this->pos_ < 0 )
		{
			this->pos_ = st.column_index(this->name_);
		}
	}
Esempio n. 7
0
bool branch::operator==(statement const& o) const {
  bool is_equal = false;
  statement_visitor v;
  v._([&](branch const* o) {
    is_equal = this->hint == o->hint && *this->target == *o->target;
  });
  o.accept(v);
  return is_equal;
}
Esempio n. 8
0
bool store::operator==(statement const& o) const {
  bool is_equal = false;
  statement_visitor v;
  v._([&](store const* o) {
    is_equal = this->size == o->size && *this->address_ == *o->address_ &&
               *this->rhs == *o->rhs;
  });
  o.accept(v);
  return is_equal;
}
Esempio n. 9
0
    /** @brief Generic dispatcher */
    inline void execute_scalar_assign(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      switch (expr[0].rhs_type_family_)
      {
        case COMPOSITE_OPERATION_FAMILY:
          execute_scalar_assign_composite(s);
          break;
        default:
          throw statement_not_supported_exception("Unsupported rvalue on root node for operation on scalar.");
      }
    }
    /** @brief Generic dispatcher */
    void execute_vector_assign(statement const & s)
    {
      typedef typename statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      switch (expr[0].rhs_type_family_)
      {
        case COMPOSITE_OPERATION_FAMILY:
          execute_vector_assign_composite(s);
          break;
        case VECTOR_TYPE_FAMILY:
          execute_vector_assign_vector(s);
          break;
        default:
          throw "invalid rvalue in vector assignment";
      }
    }
Esempio n. 11
0
    /** @brief Generic dispatcher */
    inline void execute_matrix_row_assign(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      switch (expr[0].rhs_type_family_)
      {
        case COMPOSITE_OPERATION_FAMILY:
          execute_matrix_row_assign_composite(s);
          break;
        case MATRIX_ROW_TYPE_FAMILY:
          execute_matrix_row_assign_matrix(s);
          break;
        default:
          throw statement_not_supported_exception("Invalid rvalue encountered in row-major matrix assignment");
      }
    }
    /** @brief Generic dispatcher */
    inline void execute_matrix_col_inplace_sub(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      switch (expr[0].rhs_type_family_)
      {
        case COMPOSITE_OPERATION_FAMILY:
          execute_matrix_col_inplace_sub_composite(s);
          break;
        case MATRIX_COL_TYPE_FAMILY:
          execute_matrix_col_inplace_sub_matrix(s);
          break;
        default:
          throw "invalid rvalue in vector assignment";
      }
    }
Esempio n. 13
0
    /** @brief Generic dispatcher */
    inline void execute_vector_inplace_add(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      switch (expr[0].rhs_type_family_)
      {
        case COMPOSITE_OPERATION_FAMILY:
          execute_vector_inplace_add_composite(s);
          break;
        case VECTOR_TYPE_FAMILY:
          execute_vector_inplace_add_vector(s);
          break;
        default:
          throw statement_not_supported_exception("Invalid rvalue encountered in vector inplace-add");
      }
    }
Esempio n. 14
0
    /** @brief Deals with A = B  for a matrix B */
    inline void execute_matrix_row_assign_matrix(statement const & s)
    {
      typedef statement::container_type   StatementContainer;

      StatementContainer const & expr = s.array();

      if (expr[0].lhs_type_ == MATRIX_ROW_FLOAT_TYPE && expr[0].rhs_type_ == MATRIX_ROW_FLOAT_TYPE)
      {
        viennacl::matrix_base<float, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_float_);
        viennacl::matrix_base<float, viennacl::row_major> const & B = *(expr[0].rhs_.matrix_row_float_);
        viennacl::linalg::am(A,
                             B, 1.0, 1, false, false);
      }
      else if (expr[0].lhs_type_ == MATRIX_ROW_DOUBLE_TYPE && expr[0].rhs_type_ == MATRIX_ROW_DOUBLE_TYPE)
      {
        viennacl::matrix_base<double, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_double_);
        viennacl::matrix_base<double, viennacl::row_major> const & B = *(expr[0].rhs_.matrix_row_double_);
        viennacl::linalg::am(A,
                             B, 1.0, 1, false, false);
      }
      else
        throw statement_not_supported_exception("Unsupported assignment to row-major matrix");
    }
Esempio n. 15
0
    /** @brief Deals with x = RHS where RHS is a vector expression */
    inline void execute_matrix_row_assign_composite(statement const & s)
    {
      statement::container_type const & expr = s.array();

      if (expr[1].op_type_  == OPERATION_BINARY_ADD_TYPE)
      {
        if (expr[0].lhs_type_ == MATRIX_ROW_FLOAT_TYPE
            && expr[1].lhs_type_ == MATRIX_ROW_FLOAT_TYPE
            && expr[1].rhs_type_ == MATRIX_ROW_FLOAT_TYPE)
        {
          viennacl::matrix_base<float, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_float_);
          viennacl::matrix_base<float, viennacl::row_major> const & B = *(expr[1].lhs_.matrix_row_float_);
          viennacl::matrix_base<float, viennacl::row_major> const & C = *(expr[1].rhs_.matrix_row_float_);
          viennacl::linalg::ambm(A,
                                 B, 1.0, 1, false, false,
                                 C, 1.0, 1, false, false);
        }
        else if (expr[0].lhs_type_ == MATRIX_ROW_DOUBLE_TYPE
                 && expr[1].lhs_type_ == MATRIX_ROW_DOUBLE_TYPE
                 && expr[1].rhs_type_ == MATRIX_ROW_DOUBLE_TYPE)
        {
          viennacl::matrix_base<double, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_double_);
          viennacl::matrix_base<double, viennacl::row_major> const & B = *(expr[1].lhs_.matrix_row_double_);
          viennacl::matrix_base<double, viennacl::row_major> const & C = *(expr[1].rhs_.matrix_row_double_);
          viennacl::linalg::ambm(A,
                                 B, 1.0, 1, false, false,
                                 C, 1.0, 1, false, false);
        }
        else
          throw statement_not_supported_exception("Cannot deal with addition of row-major matrix");
      }
      else if (expr[1].op_type_  == OPERATION_BINARY_SUB_TYPE)
      {
        if (expr[0].lhs_type_ == MATRIX_ROW_FLOAT_TYPE
            && expr[1].lhs_type_ == MATRIX_ROW_FLOAT_TYPE
            && expr[1].rhs_type_ == MATRIX_ROW_FLOAT_TYPE)
        {
          viennacl::matrix_base<float, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_float_);
          viennacl::matrix_base<float, viennacl::row_major> const & B = *(expr[1].lhs_.matrix_row_float_);
          viennacl::matrix_base<float, viennacl::row_major> const & C = *(expr[1].rhs_.matrix_row_float_);
          viennacl::linalg::ambm(A,
                                 B,  1.0, 1, false, false,
                                 C, -1.0, 1, false, false);
        }
        else if (expr[0].lhs_type_ == MATRIX_ROW_DOUBLE_TYPE
                 && expr[1].lhs_type_ == MATRIX_ROW_DOUBLE_TYPE
                 && expr[1].rhs_type_ == MATRIX_ROW_DOUBLE_TYPE)
        {
          viennacl::matrix_base<double, viennacl::row_major>       & A = *(expr[0].lhs_.matrix_row_double_);
          viennacl::matrix_base<double, viennacl::row_major> const & B = *(expr[1].lhs_.matrix_row_double_);
          viennacl::matrix_base<double, viennacl::row_major> const & C = *(expr[1].rhs_.matrix_row_double_);
          viennacl::linalg::ambm(A,
                                 B,  1.0, 1, false, false,
                                 C, -1.0, 1, false, false);
        }
        else
          throw statement_not_supported_exception("Cannot deal with subtraction of row-major matrix");
      }
      else
        throw statement_not_supported_exception("Unsupported binary operator for row-major matrix operations");
    }
Esempio n. 16
0
    /** @brief Deals with x = RHS where RHS is a vector expression */
    inline void execute_scalar_assign_composite(statement const & s)
    {
      statement::container_type const & expr = s.array();

      if (expr[1].op_type_  == OPERATION_BINARY_INNER_PROD_TYPE)
      {
        if (expr[0].lhs_type_ == SCALAR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE
            && expr[1].rhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::scalar<float>            & s = *(expr[0].lhs_.scalar_float_);
          viennacl::vector_base<float> const & y = *(expr[1].lhs_.vector_float_);
          viennacl::vector_base<float> const & z = *(expr[1].rhs_.vector_float_);
          viennacl::linalg::inner_prod_impl(y, z, s);
        }
        else if (expr[0].lhs_type_ == SCALAR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::scalar<double>            & s = *(expr[0].lhs_.scalar_double_);
          viennacl::vector_base<double> const & y = *(expr[1].lhs_.vector_double_);
          viennacl::vector_base<double> const & z = *(expr[1].rhs_.vector_double_);
          viennacl::linalg::inner_prod_impl(y, z, s);
        }
        else
          throw statement_not_supported_exception("Cannot deal with inner product of the provided arguments");
      }
      else if (expr[1].op_type_  == OPERATION_UNARY_NORM_1_TYPE)
      {
        if (expr[0].lhs_type_ == SCALAR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::scalar<float>            & s = *(expr[0].lhs_.scalar_float_);
          viennacl::vector_base<float> const & x = *(expr[1].lhs_.vector_float_);
          viennacl::linalg::norm_1_impl(x, s);
        }
        else if (expr[0].lhs_type_ == SCALAR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::scalar<double>            & s = *(expr[0].lhs_.scalar_double_);
          viennacl::vector_base<double> const & x = *(expr[1].lhs_.vector_double_);
          viennacl::linalg::norm_1_impl(x, s);
        }
        else
          throw statement_not_supported_exception("Cannot deal with norm_1 of the provided arguments");
      }
      else if (expr[1].op_type_  == OPERATION_UNARY_NORM_2_TYPE)
      {
        if (expr[0].lhs_type_ == SCALAR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::scalar<float>            & s = *(expr[0].lhs_.scalar_float_);
          viennacl::vector_base<float> const & x = *(expr[1].lhs_.vector_float_);
          viennacl::linalg::norm_2_impl(x, s);
        }
        else if (expr[0].lhs_type_ == SCALAR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::scalar<double>            & s = *(expr[0].lhs_.scalar_double_);
          viennacl::vector_base<double> const & x = *(expr[1].lhs_.vector_double_);
          viennacl::linalg::norm_2_impl(x, s);
        }
        else
          throw statement_not_supported_exception("Cannot deal with norm_2 of the provided arguments");
      }
      else if (expr[1].op_type_  == OPERATION_UNARY_NORM_INF_TYPE)
      {
        if (expr[0].lhs_type_ == SCALAR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::scalar<float>            & s = *(expr[0].lhs_.scalar_float_);
          viennacl::vector_base<float> const & x = *(expr[1].lhs_.vector_float_);
          viennacl::linalg::norm_inf_impl(x, s);
        }
        else if (expr[0].lhs_type_ == SCALAR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::scalar<double>            & s = *(expr[0].lhs_.scalar_double_);
          viennacl::vector_base<double> const & x = *(expr[1].lhs_.vector_double_);
          viennacl::linalg::norm_inf_impl(x, s);
        }
        else
          throw statement_not_supported_exception("Cannot deal with norm_inf of the provided arguments");
      }
      else
        throw statement_not_supported_exception("Unsupported operation for scalar.");
    }
Esempio n. 17
0
QString toSQLParse::indentStatement(statement &stat, int level/*SQLITEMAN, toSyntaxAnalyzer &syntax*/)
{
	QString ret;

	switch (stat.Type)
	{
	default:
		{
			QMessageBox::warning(QApplication::activeWindow(), "Sqliteman",
								 "toSQLparse: Internal error in toSQLParse, should never get here");
		}
	case statement::Block:
	{
		ret = IndentComment(level, 0, stat.Comment, false);
		int exc = 0;
		for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin();
				i != stat.subTokens().end();
				i++)
		{
			int add
			= 0;
			std::list<toSQLParse::statement>::iterator j = i;
			j++;
			if (i != stat.subTokens().begin() &&
					j != stat.subTokens().end())
				add
				= Settings.IndentLevel;
			else
				exc = 0;

			QString t;
			if ((*i).subTokens().begin() != (*i).subTokens().
					end())
				t = (*(*i).subTokens().begin()).String.toUpper();
			if (t == ("BEGIN") || t == ("WHEN") || t == ("ELSE") || t == ("ELSIF"))
				add
				= 0;
			if ((*i).Type == statement::List)
				ret += indentString(level + add
									+ exc);
			ret += indentStatement(*i, level + add
								   + exc/*SQLITEMAN , syntax*/);
			if ((*i).Type == statement::List)
			{
				int i;
				for (i = ret.length() - 1;i >= 0 && ret[i].isSpace();i--)
					;
				ret = ret.mid(0, std::max(i + 1, 0));
				ret += ("\n");
				ret += indentString(level + exc);
			}
			if (t == ("EXCEPTION"))
				exc = Settings.IndentLevel * 2;
		}
		if (Settings.EndBlockNewline && level != 0)
			ret += ("\n");
	}
	break;
	case statement::List:
	case statement::Statement:
		int maxlev = 0;
		int maxlevorig = 0;
		bool useMaxLev = false;
		bool any = true;
		int current;
		bool first;
		bool noKeyBreak = false;
		bool lineList = false;
		QString comment;
		if (stat.Type == statement::Statement)
		{
			ret = IndentComment(level, 0, stat.Comment, false);
			useMaxLev = true;
			first = true;
			current = 0;
		}
		else
		{
			for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin();
					i != stat.subTokens().end();)
			{
				if ((*i).Type != statement::Keyword)
					noKeyBreak = true;
				else
					useMaxLev = true;
				break;
			}
			current = level;
			first = true;
		}
		if (useMaxLev)
		{
			int count = 0;
			for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin();
					i != stat.subTokens().end();
					i++)
			{
				if (any)
				{
					QString upp = (*i).String.toUpper();
					if ((*i).Type == statement::Keyword &&
							upp != ("LOOP") &&
							upp != ("DO") &&
							upp != ("THEN") &&
							upp != ("AS") &&
							upp != ("IS"))
					{
						if (int((*i).String.length()) + 1 > maxlev)
							maxlev = (*i).String.length() + 1;
						count++;
						any = false;
					}
					else if (i == stat.subTokens().begin())
					{
						noKeyBreak = true;
						break;
					}
				}
				else if ((*i).Type == statement::Token)
					any = true;
				if ((*i).Type == statement::List)
					count++;
			}
			if (count <= 1 && maxlev > 0)
				maxlev--;
			maxlevorig = maxlev;
			any = true;
		}

		for (std::list<toSQLParse::statement>::iterator i = stat.subTokens().begin();
				i != stat.subTokens().end();
				i++)
		{
			comment = AddComment(comment, (*i).Comment);
			QString upp = (*i).String.toUpper();

#ifdef TOPARSE_DEBUG
			printf("%s\n", (const char*)(*i).String.toUtf8());
#endif

			if ((*i).Type == statement::List)
			{
				if (Settings.OperatorSpace)
				{
					ret += (" ");
					current++;
				}
				QString t = indentStatement(*i, current/*SQLITEMAN, syntax*/);
				if (t.indexOf(("\n")) >= 0)
					current = CurrentColumn(t);
				else
					current += CurrentColumn(t);
				ret += t;
				any = true;
			}
			else if ((*i).String == (","))
			{
				if (Settings.CommaBefore)
				{
					ret += IndentComment(Settings.CommentColumn, current, comment, true);
					comment = QString::null;
					ret += indentString(level + maxlev - (Settings.OperatorSpace ? 2 : 1));
					ret += (",");
				}
				else
				{
					ret += (",");
					ret += IndentComment(Settings.CommentColumn, current + 1, comment, true);
					comment = QString::null;
					ret += indentString(level + maxlev);
				}
				current = level + maxlev;
				any = false;
				lineList = true;
			}
			else if ((*i).Type == statement::Keyword && (upp == ("LOOP") ||
					 upp == ("DO") ||
					 upp == ("THEN") ||
					 upp == ("AS") ||
					 upp == ("IS")))
			{
				if (!Settings.BlockOpenLine)
				{
					if (ret.length() > 0)
					{
						if (toIsIdent(ret.at(ret.length() - 1)) ||
								ret.at(ret.length() - 1) == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ ||
								ret.at(ret.length() - 1) == '\'' ||
								Settings.OperatorSpace)
						{
							ret += (" ");
							current++;
						}
					}
					ret += Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String;
					current += (*i).String.length();
				}
				else
				{
					ret += IndentComment(Settings.CommentColumn, current, comment, true);
					comment = QString::null;
					ret += indentString(level);
					ret += Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String;
					current = level + (*i).String.length();
				}
				any = false;
			}
			else if (any && (*i).Type == statement::Keyword && !noKeyBreak)
			{
				if (first)
					first = false;
				else
				{
					ret += IndentComment(Settings.CommentColumn, current, comment, true);
					current = 0;
					comment = QString::null;
				}
				if (current == 0)
				{
					ret += indentString(level);
					current = level;
				}
				else
					while (current < level)
					{
						ret += (" ");
						current++;
					}
				maxlev = maxlevorig;
				QString word = Settings.KeywordUpper ? (*i).String.toUpper() : (*i).String;
				if (ret.length())
				{
					ret += QString("%1").arg(word,
											 Settings.RightSeparator ? maxlev - 1 : 1 - maxlev);
					current = level + std::max(int(word.length()), maxlev - 1);
				}
				else
				{
					ret += word;
					current = level + word.length();
				}
				any = false;
				lineList = false;
			}
			else
			{
				QString t = (*i).String;
				bool add
				= false;
				if ((*i).Type == statement::Keyword)
				{
					if (!lineList &&
							!any &&
							(*i).Type == statement::Keyword &&
							!noKeyBreak &&
							upp == ("BY"))
						add
						= true;
				}
				else
				{
					any = true;
				}
				if (isKeyword(upp) /*SQLITEMAN syntax.reservedWord(upp)*/ && Settings.KeywordUpper)
					t = upp;

				int extra;
				if (first)
				{
					first = false;
					any = false;
					extra = 0;
				}
				else
				{
					if (ret.length() > 0 &&
							!ret.at(ret.length() - 1).isSpace() &&
							(Settings.OperatorSpace || ((toIsIdent(t[0]) ||
														 t[0] == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ || t[0] == '\'') &&
														(toIsIdent(ret.at(ret.length() - 1)) ||
														 ret.at(ret.length() - 1) == QUOTE_CHARACTER /*SQLITEMAN syntax.quoteCharacter()*/ ||
														 ret.at(ret.length() - 1) == '\'')
													   )
							)
					   )
					{
						if (t != (";") &&
								t != (".") &&
								ret.at(ret.length() - 1) != '.' &&
								current != 0)
						{
							current++;
							ret += (" ");
						}
					}
					else if (ret.length() > 2 && ret.at(ret.length() - 2) == '*' && ret.at(ret.length() - 1) == '/')
					{
						current++;
						ret += (" ");
					}
					extra = maxlev;
				}
				if (current < level + maxlev)
				{
					if (current == 0)
						ret += indentString(level + maxlev);
					else
						while (current < level + maxlev)
						{
							ret += (" ");
							current++;
						}
					current = level + maxlev;
				}
				ret += t;
				current += t.length();
				if (t.startsWith(("<<")))
				{
					ret += ("\n");
					current = 0;
				}

				if (add
				   )
					maxlev += t.length() + 1;
			}
		}
		if (stat.Type == statement::Statement)
		{
			ret += IndentComment(Settings.CommentColumn, current, comment, true);
			comment = QString::null;
			if (Settings.EndBlockNewline &&
					level == 0 &&
					stat.subTokens().begin() != stat.subTokens().end() &&
					(*stat.subTokens().rbegin()).String == (";"))
				ret += ("\n");
		}
		else if (!comment.isEmpty())
		{
			ret += IndentComment(Settings.CommentColumn, current, comment, true);
			comment = QString::null;
			ret += indentString(level - (Settings.OperatorSpace ? 2 : 1));
		}
		break;
	}
	return ret;
}
Esempio n. 18
0
 static void bind(statement& st, ColOrName col_or_name, const boost::posix_time::ptime& v)
 {
     st.bind(col_or_name, boost::posix_time::to_tm(v));
 }
Esempio n. 19
0
	void statement_visitor::visit(statement &statement)
	{
		statement.visit(*this);
	}
    /** @brief Deals with x = RHS where RHS is a vector expression */
    void execute_vector_assign_composite(statement const & s)
    {
      typename statement::container_type const & expr = s.array();

      if (expr[1].op_type_  == OPERATION_BINARY_ADD_TYPE)
      {
        if (expr[0].lhs_type_ == VECTOR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE
            && expr[1].rhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::vector_base<float>       & x = *(expr[0].lhs_.vector_float_);
          viennacl::vector_base<float> const & y = *(expr[1].lhs_.vector_float_);
          viennacl::vector_base<float> const & z = *(expr[1].rhs_.vector_float_);
          viennacl::linalg::avbv(x,
                                 y, 1.0, 1, false, false,
                                 z, 1.0, 1, false, false);
        }
        else if (expr[0].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::vector_base<double>       & x = *(expr[0].lhs_.vector_double_);
          viennacl::vector_base<double> const & y = *(expr[1].lhs_.vector_double_);
          viennacl::vector_base<double> const & z = *(expr[1].rhs_.vector_double_);
          viennacl::linalg::avbv(x,
                                 y, 1.0, 1, false, false,
                                 z, 1.0, 1, false, false);
        }
        else
          throw "TODO";
      }
      else if (expr[1].op_type_  == OPERATION_BINARY_SUB_TYPE)
      {
        if (expr[0].lhs_type_ == VECTOR_FLOAT_TYPE
            && expr[1].lhs_type_ == VECTOR_FLOAT_TYPE
            && expr[1].rhs_type_ == VECTOR_FLOAT_TYPE)
        {
          viennacl::vector_base<float>       & x = *(expr[0].lhs_.vector_float_);
          viennacl::vector_base<float> const & y = *(expr[1].lhs_.vector_float_);
          viennacl::vector_base<float> const & z = *(expr[1].rhs_.vector_float_);
          viennacl::linalg::avbv(x,
                                 y,  1.0, 1, false, false,
                                 z, -1.0, 1, false, false);
        }
        else if (expr[0].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].lhs_type_ == VECTOR_DOUBLE_TYPE
                 && expr[1].rhs_type_ == VECTOR_DOUBLE_TYPE)
        {
          viennacl::vector_base<double>       & x = *(expr[0].lhs_.vector_double_);
          viennacl::vector_base<double> const & y = *(expr[1].lhs_.vector_double_);
          viennacl::vector_base<double> const & z = *(expr[1].rhs_.vector_double_);
          viennacl::linalg::avbv(x,
                                 y,  1.0, 1, false, false,
                                 z, -1.0, 1, false, false);
        }
        else
          throw "TODO";
      }
      else
        throw "TODO";
    }
Esempio n. 21
0
	void do_bind(statement& st, int)
	{
		st.use_value(st.use_pos(this->name_), converter<T>::from(this->value_));
	}
Esempio n. 22
0
	void do_bind(statement& st, int pos)
	{
		st.use_value(pos, converter<T>::from(this->value_));
	}
Esempio n. 23
0
	void do_update(statement& st)
	{
		typename converter<T>::base_type t;
		st.column_value(this->pos_, t);
		this->value_ = converter<T>::to(t);
	}