コード例 #1
0
void BinaryFilterCondition::bindQueryParams(QSqlQuery& query, 
    std::size_t baseParamNo, const DatabaseModel& databaseModel) const
{
  QVariant rightValue(rightValue_);
  QVariant::Type rightValueType = rightValue_.type();
  if (QVariant::Date == rightValueType)
  {
    rightValue = databaseModel.convertFromServer(rightValue_.value<QDate>());
  }
  else if (QVariant::DateTime == rightValueType)
  {
    rightValue = 
        databaseModel.convertFromServer(rightValue_.value<QDateTime>());
  }
  else if (QVariant::String == rightValueType)
  {
    if (likeCondition == conditionType_ || notLikeCondition == conditionType_)
    {
      QString str = rightValue_.value<QString>();          
      str.replace("\\", "\\\\");
      str.replace("%", "\\%");
      str.replace("_", "\\_");
      str.replace("*", "%");
      str.replace("?", "_");
      rightValue = str;          
    }
  }
  query.bindValue(boost::numeric_cast<int>(baseParamNo), rightValue);
}
コード例 #2
0
// CXX CLASS MEMBER CALL, with dot operator ('.')
bool SuperastCPP::TraverseCXXMemberCallExpr(
    clang::CXXMemberCallExpr* memberCall) {
  // Method Decl
  clang::CXXMethodDecl* methodDecl = memberCall->getMethodDecl();
  // Implicit obj
  clang::Expr* objectExpr = memberCall->getImplicitObjectArgument();
  // If this is an implicitCast, get the subExpr
  if (clang::ImplicitCastExpr* implicitExpr = 
      llvm::dyn_cast<clang::ImplicitCastExpr>(objectExpr)) {
    objectExpr = implicitExpr->getSubExpr();
  }

  const std::string& methodName = methodDecl->getNameInfo().getAsString();
  //const clang::Type* type = methodDecl->getReturnType().getTypePtr();

  rapidjson::Value rightValue(rapidjson::kObjectType);
  addId(rightValue);
  addPos(rightValue, memberCall);
  rightValue.AddMember("type", "function-call", allocator);
  rightValue.AddMember("name",
                      rapidjson::Value().SetString(methodName.c_str(),
                                                   methodName.size(),
                                                   allocator),
                      allocator);

  // For each argument
  rapidjson::Value arrayValue(rapidjson::kArrayType);
  for (auto arg : memberCall->arguments()) {
    TRY_TO(TraverseStmt(arg));
    arrayValue.PushBack(sonValue, allocator);
  }
  rightValue.AddMember("arguments", arrayValue, allocator);

  // Uncomment to add the type
  //rightValue.AddMember("return-type", createTypeValue(type), allocator);
  
  TRY_TO(TraverseStmt(objectExpr));
  // Object from which the method is called
  rapidjson::Value memberCallValue = createBinOpValue(".", sonValue, rightValue);
  addPos(memberCallValue, memberCall);

  sonValue = memberCallValue;
  return true;
}
コード例 #3
0
bool SuperastCPP::TraverseCXXOperatorCallExpr(clang::CXXOperatorCallExpr* operatorCallExpr) {
  // IF THERE IS A PRINT
  auto decl = llvm::dyn_cast<clang::FunctionDecl>(operatorCallExpr->getCalleeDecl());
  if (!decl) {
    std::cerr << "Unknown function in CXXOperatorCallExpr" << std::endl;
    return true;
  }
  const std::string functionName = decl->getNameInfo().getAsString();
  if (functionName == PRINT_NAME || functionName == READ_NAME) {
    bool isFirst = false;
    if (!iofunctionStarted) {
      isFirst = true;
      iofunctionStarted = true;
    }

    rapidjson::Value arrayValue(rapidjson::kArrayType);
    for (unsigned i = 0; i < operatorCallExpr->getNumArgs(); ++i) {
      TRY_TO(TraverseStmt(operatorCallExpr->getArg(i)));
      if (i == 0) {
        // If sonValue is not an array, is because it reached the begin of
        // call, which is the cout/cerr/stream class
        if (sonValue.IsArray()) {
          arrayValue = sonValue;
        }
      }
      else {
        arrayValue.PushBack(sonValue, allocator);
      }
    }
    
    if (!isFirst) {
      sonValue = arrayValue;
    }
    else {
      iofunctionStarted = false;

      rapidjson::Value functionValue(rapidjson::kObjectType);
      addId(functionValue);
      addPos(functionValue, operatorCallExpr);
      functionValue.AddMember("type", "function-call", allocator);
      if (functionName == PRINT_NAME) 
        functionValue.AddMember("name", "print", allocator);
      else functionValue.AddMember("name", "read", allocator);
      functionValue.AddMember("arguments", arrayValue, allocator);
      sonValue = functionValue;
    }
  }
  else if (functionName == VECTOR_POS_NAME) {
    // Operator []
    TRY_TO(TraverseStmt(operatorCallExpr->getArg(0)));
    rapidjson::Value leftValue(rapidjson::kObjectType);
    leftValue = sonValue;
    TRY_TO(TraverseStmt(operatorCallExpr->getArg(1)));
    rapidjson::Value rightValue(rapidjson::kObjectType);
    rightValue = sonValue;
    sonValue = createBinOpValue("[]", leftValue, rightValue);
  }
  else {
    std::cerr << "Operator call not defined: " << functionName << std::endl;
  }
    return true;
}