Exemple #1
0
char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, 
                unsigned long *res_length, char *is_null, char *error)
{
  char   *str;
  PJVAL   jvp;
  PJAR    arp;
  PGLOBAL g = (PGLOBAL)initid->ptr;

  PlugSubSet(g, g->Sarea, g->Sarea_Size);
  jvp = MakeValue(g, args, 0);

  if (jvp->GetValType() != TYPE_JAR) {
    arp = new(g) JARRAY;
    arp->AddValue(g, jvp);
  } else
    arp = jvp->GetArray();

  for (uint i = 1; i < args->arg_count; i++)
    arp->AddValue(g, MakeValue(g, args, i));

  arp->InitArray(g);

  if (!(str = Serialize(g, arp, NULL, 0)))
    str = strcpy(result, g->Message);

  *res_length = strlen(str);
  return str;
} // end of Json_Array_Add
Exemple #2
0
void DropGrid::UpdateValue()
{
	if(!list.IsCursor())
		return;

	value = MakeValue();
}
Exemple #3
0
Value DropGrid::FindValue(const Value& v) const
{
	int r = list.Find(v, key_col);
	if(r < 0)
		return Null;

	return MakeValue(r);
}
//----------------------------------------------------------------------------
//
//	ROUTINE:	RelationSet::RemoveARelation()
//
//	PURPOSE:	Removes a relation from the RelationSet
//
//----------------------------------------------------------------------------
void RelationSet::RemoveARelation(RelationTraits::eRelationTraits eTrait, const char* const pszValue )
{
    // Make sure that it is not already in the list
    _mapEnumStringsToAlignment::iterator it = GetRelationMap(eTrait).find( MakeValue(pszValue) );
    if ( it != GetRelationMap(eTrait).end() )
    {
        GetRelationMap(eTrait).erase( it );
    }
}
	TValueOrError<TArray<FCompiledToken>, FExpressionError> Compile()
	{
		auto Error = CompileGroup(nullptr, nullptr);
		if (Error.IsSet())
		{
			return MakeError(Error.GetValue());
		}
		return MakeValue(MoveTemp(Commands));
	}
//----------------------------------------------------------------------------
//
//	ROUTINE:	RelationData::AddRelation()
//
//	PURPOSE:
//
//----------------------------------------------------------------------------
void RelationSet::AddRelation(const RelationDescription& RD)
{
    // Make sure that this exact relationships is not already in the list
    // as we don't want to add a duplicate!
    UBER_ASSERT3( !HasSpecificRelation(RD), "Relation overwritting not supported for: %d, %s, %d", RD.eTrait, RD.szValue, RD.eAlignment );
    if ( !HasSpecificRelation(RD) )
    {
        GetRelationMap(RD.eTrait).insert(_mapEnumStringsToAlignment::value_type(MakeValue(RD.szValue), RD.eAlignment));
    }
}
Exemple #7
0
void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, 
                      char *is_null, char *error)
{
  PGLOBAL g = (PGLOBAL)initid->ptr;
  PJOB    objp = (PJOB)g->Activityp;

  if (g->N-- > 0)
    objp->SetValue(g, MakeValue(g, args, 0), MakePSZ(g, args, 1));

} // end of Json_Object_Grp_add
Exemple #8
0
void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, 
                      char *is_null, char *error)
{
  PGLOBAL g = (PGLOBAL)initid->ptr;
  PJAR    arp = (PJAR)g->Activityp;

  if (g->N-- > 0)
    arp->AddValue(g, MakeValue(g, args, 0));

} // end of Json_Array_Grp_add
	LexResultType Lex(const TCHAR* InExpression, const FTokenDefinitions& TokenDefinitions)
	{
		FExpressionTokenConsumer TokenConsumer(InExpression);
		
		TOptional<FExpressionError> Error = TokenDefinitions.ConsumeTokens(TokenConsumer);
		if (Error.IsSet())
		{
			return MakeError(Error.GetValue());
		}

		return MakeValue(TokenConsumer.Extract());
	}
//----------------------------------------------------------------------------
//
//	ROUTINE:	RelationSet::RemoveSpecificRelation()
//
//	PURPOSE:
//
//----------------------------------------------------------------------------
void RelationSet::RemoveSpecificRelation(const RelationDescription& RD)
{
    // Make sure that it is not already in the list
    _mapEnumStringsToAlignment::iterator it = GetRelationMap(RD.eTrait).find( MakeValue(RD.szValue) );
    if ( it != GetRelationMap(RD.eTrait).end() )
    {
        UBER_ASSERT( (*it).second == RD.eAlignment, "RelationSet::RemoveSpecificRelation: Attempted to remove unfound relation" );
        if ( (*it).second == RD.eAlignment )
        {
            GetRelationMap(RD.eTrait).erase( it );
        }
    }
}
Exemple #11
0
char *Json_Value(UDF_INIT *initid, UDF_ARGS *args, char *result, 
                unsigned long *res_length, char *is_null, char *error)
{
  char   *str;
  PJVAL   jvp;
  PGLOBAL g = (PGLOBAL)initid->ptr;

  PlugSubSet(g, g->Sarea, g->Sarea_Size);
  jvp = MakeValue(g, args, 0);

  if (!(str = Serialize(g, jvp, NULL, 0)))
    str = strcpy(result, g->Message);

  *res_length = strlen(str);
  return str;
} // end of Json_Value
//----------------------------------------------------------------------------
//
//	ROUTINE:	RelationSet::HasSpecificRelation()
//
//	PURPOSE:	Does this specific relation exist?
//
//----------------------------------------------------------------------------
bool RelationSet::HasSpecificRelation(const RelationDescription& RD) const
{
    // Make sure that it is not already in the list
    _mapEnumStringsToAlignment::const_iterator it = GetRelationMap(RD.eTrait).find( MakeValue(RD.szValue));

    // If there is no relation between this type, then there is no such relation.
    if ( it == GetRelationMap(RD.eTrait).end() )
    {
        return false;
    }

    // If the Alignment is not the same, then it is not a match.
    if ( (*it).second != RD.eAlignment )
    {
        return false;
    }

    return true;
}
Exemple #13
0
char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, 
                  unsigned long *res_length, char *is_null, char *error)
{
  char   *str;
  uint    i;
  PJOB    objp;
  PGLOBAL g = (PGLOBAL)initid->ptr;

  PlugSubSet(g, g->Sarea, g->Sarea_Size);
  objp = new(g) JOBJECT;

  for (i = 0; i < args->arg_count; i++)
    objp->SetValue(g, MakeValue(g, args, i), MakeKey(g, args, i));

  if (!(str = Serialize(g, objp, NULL, 0)))
    str = strcpy(result, g->Message);

  *res_length = strlen(str);
  return str;
} // end of Json_Object
int GetTheLargestPalindromerMadeFromTheProductOfTwo3DigitNumbers()
{
	for(int a = 9; a > 0; --a)
		for(int b = 9; b >= 0; --b)
			for(int c = 9; c >= 0; --c)
			{
				int v = MakeValue(a, b, c);
				
				for(int d = 90; d > 10; --d)
				{
					if(v % d == 0)
					{
						if(v / d > 999)	// 不是三位数。
							break;
						else
							return v * 11;
					}
				}
			}
	return -1;
}
Exemple #15
0
char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, 
                unsigned long *res_length, char *is_null, char *error)
{
  char   *str;
  uint    i;
  PJAR    arp;
  PGLOBAL g = (PGLOBAL)initid->ptr;

  PlugSubSet(g, g->Sarea, g->Sarea_Size);
  arp = new(g) JARRAY;

  for (i = 0; i < args->arg_count; i++)
    arp->AddValue(g, MakeValue(g, args, i));

  arp->InitArray(g);

  if (!(str = Serialize(g, arp, NULL, 0)))
    str = strcpy(result, g->Message);

  *res_length = strlen(str);
  return str;
} // end of Json_Array
Exemple #16
0
char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, 
                unsigned long *res_length, char *is_null, char *error)
{
  char   *str;
  int     n;
  PJVAL   jvp;
  PJAR    arp;
  PGLOBAL g = (PGLOBAL)initid->ptr;

  PlugSubSet(g, g->Sarea, g->Sarea_Size);
  jvp = MakeValue(g, args, 0);

  if (jvp->GetValType() != TYPE_JAR) {
    push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, 
                 "First argument is not an array");
    str = args->args[0];
  } else if (args->arg_type[1] != INT_RESULT) {
    push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, 
                 "Second argument is not an integer");
    str = args->args[0];
  } else {
    n = *(int*)args->args[1];
    arp = jvp->GetArray();
    arp->DeleteValue(n - 1);
    arp->InitArray(g);

    if (!(str = Serialize(g, arp, NULL, 0))) {
      str = strcpy(result, g->Message);
      push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, str);
      } // endif str

  } // endif's

  *res_length = strlen(str);
  return str;
} // end of Json_Array_Delete
Exemple #17
0
Value DropGrid::GetValue(int r) const
{
	return MakeValue(r);
}
Exemple #18
0
 static constexpr unsigned MakeValue(char const (&_fourCC)[N], int_<I>)
 {
     return (MakeValue(_fourCC, int_<I-1>()) << 8) | _fourCC[I-1];
 }
Exemple #19
0
 constexpr FourCC(char const (&_fourCC)[N])
     : value(MakeValue(_fourCC, int_<N-1>()))
 {
     static_assert(N <= 5, "4 character code must contain at most 4 characters"); // plus null-terminator
 }
	FExpressionResult Evaluate(const TArray<FCompiledToken>& CompiledTokens, const IOperatorEvaluationEnvironment& InEnvironment)
	{
		// Evaluation strategy: the supplied compiled tokens are const. To avoid copying the whole array, we store a separate array of
		// any tokens that are generated at runtime by the evaluator. The operand stack will consist of indices into either the CompiledTokens
		// array, or the RuntimeGeneratedTokens (where Index >= CompiledTokens.Num())
		TArray<FExpressionToken> RuntimeGeneratedTokens;
		TArray<int32> OperandStack;

		/** Get the token pertaining to the specified operand index */
		auto GetToken = [&](int32 Index) -> const FExpressionToken& {
			if (Index < CompiledTokens.Num())
			{
				return CompiledTokens[Index];
			}

			return RuntimeGeneratedTokens[Index - CompiledTokens.Num()];
		};

		/** Add a new token to the runtime generated array */
		auto AddToken = [&](FExpressionToken&& In) -> int32 {
			auto Index = CompiledTokens.Num() + RuntimeGeneratedTokens.Num();
			RuntimeGeneratedTokens.Emplace(MoveTemp(In));
			return Index;
		};


		for (int32 Index = 0; Index < CompiledTokens.Num(); ++Index)
		{
			const auto& Token = CompiledTokens[Index];

			switch(Token.Type)
			{
			case FCompiledToken::Benign:
				continue;

			case FCompiledToken::Operand:
				OperandStack.Push(Index);
				continue;

			case FCompiledToken::BinaryOperator:
				if (OperandStack.Num() >= 2)
				{
					// Binary
					const auto& R = GetToken(OperandStack.Pop());
					const auto& L = GetToken(OperandStack.Pop());

					auto OpResult = InEnvironment.ExecBinary(Token, L, R);
					if (OpResult.IsValid())
					{
						// Inherit the LHS context
						OperandStack.Push(AddToken(FExpressionToken(L.Context, MoveTemp(OpResult.GetValue()))));
					}
					else
					{
						return MakeError(OpResult.GetError());
					}
				}
				else
				{
					FFormatOrderedArguments Args;
					Args.Add(FText::FromString(Token.Context.GetString()));
					return MakeError(FText::Format(LOCTEXT("SyntaxError_NotEnoughOperandsBinary", "Not enough operands for binary operator {0}"), Args));
				}
				break;
			
			case FCompiledToken::PostUnaryOperator:
			case FCompiledToken::PreUnaryOperator:

				if (OperandStack.Num() >= 1)
				{
					const auto& Operand = GetToken(OperandStack.Pop());

					FExpressionResult OpResult = (Token.Type == FCompiledToken::PreUnaryOperator) ?
						InEnvironment.ExecPreUnary(Token, Operand) :
						InEnvironment.ExecPostUnary(Token, Operand);

					if (OpResult.IsValid())
					{
						// Inherit the LHS context
						OperandStack.Push(AddToken(FExpressionToken(Operand.Context, MoveTemp(OpResult.GetValue()))));
					}
					else
					{
						return MakeError(OpResult.GetError());
					}			
				}
				else
				{
					FFormatOrderedArguments Args;
					Args.Add(FText::FromString(Token.Context.GetString()));
					return MakeError(FText::Format(LOCTEXT("SyntaxError_NoUnaryOperand", "No operand for unary operator {0}"), Args));
				}
				break;
			}
		}

		if (OperandStack.Num() == 1)
		{
			return MakeValue(GetToken(OperandStack[0]).Node.Copy());
		}

		return MakeError(LOCTEXT("SyntaxError_InvalidExpression", "Could not evaluate expression"));
	}
Exemple #21
0
#include "msgp.h"
#include "regp.h"
#include "winmsdp.h"
#include "printp.h"

#include <string.h>
#include <tchar.h>

//
// Name of Registry value that contains the paths for the paging files.
//

VALUE
MemValues[ ] = {

    MakeValue( PagingFiles, MULTI_SZ )

};

//
// Location of value that contains the paths for the paging files.
//

MakeKey(
    MemKey,
    HKEY_LOCAL_MACHINE,
    TEXT( "System\\CurrentControlSet\\Control\\Session Manager\\Memory Management" ),
    NumberOfEntries( MemValues ),
    MemValues
    );