Пример #1
0
int Cvfgk::Compress(FILE* fin, FILE* fout) {
  unsigned char ch;
  int ret;
  if((fin==NULL)||(fout==NULL)) return 1;
  if(!feof(fin)) ch = ValidateInput((unsigned char)fgetc(fin));
  while(!feof(fin)) {
    if(Encode(fout,ch)) return 1;
    Update(ch);
    ch = ValidateInput((unsigned char)fgetc(fin));
  }
  if(Encode(fout,ctEndChar)) return 1;
  if(Flush(fout)) return 1;
  return 0;
}
Пример #2
0
//Edit the recipe or price of the lemonade
void EditRecipeAndPrice()
{
	int iChoice = 0;

	while (iChoice != 3)
	{
		DisplayRecipeAndPriceMenu();						//display edit menu

		while (iChoice < 1 || iChoice > 3)					//prompt until valid input
		{
			DisplayRecipeAndPriceMenu();					//display edit menu
			iChoice = ValidateInput();						//check if input is valid
		}
		switch (iChoice)
		{
		case 1:
			EditRecipe();									//edit recipe
			break;
		case 2:
			EditPrice();									//edit price
			break;
		case 3:
			system("cls");									//clear screen and
			return;											//go back
		}
		iChoice = 0;
	}
}
Пример #3
0
//prepare lemonade
void MakeLemonade()
{
	bool isLemonadeRoomInit = true;								//make lemonade is starting
	
	int iChoice = 0;

	while (iChoice != 2)
	{
		cout << "WELCOME TO THE LEMONADE MAKING ROOM\n\n";
		if (isLemonadeRoomInit)
		{
			RandomStockLoss();									//lose random supplies
			isLemonadeRoomInit = false;							//make lemonade already started
		}
		DisplayStock();											//show curren stock

		while (iChoice < 1 || iChoice > 2)					//prompt until valid input
		{
			DisplayLemonadeRoomMenu();						//display menu
			iChoice = ValidateInput();						//check if input is valid
		}
		switch (iChoice)
		{
		case 1:
			PromptLemonade();								//ask how many lemonades to make
			break;
		case 2:
			system("cls");									//clear screen and
			return;											//go back
		}
		iChoice = 0;
	}
}
Пример #4
0
void CDlgLogin::OnOK() 
{
	if (!ValidateInput()) 
		return;
	
	EndDialog(IDOK);
}
Пример #5
0
// return 1 if error
int Cvfgk::CompressNextByte(char ch){
  int ret;
  ch=ValidateInput((unsigned char)ch);
  if(Encode(fByteOut,ch)) return 1;
  Update(ch);
  return 0;
}
Пример #6
0
void NewClassDlg::OnButtonOK(wxCommandEvent& e)
{
    wxUnusedVar(e);
    if(!ValidateInput()) {
        return;
    }

    // Save the check boxes ticked
    size_t flags(0);

    if(m_checkBoxCopyable->IsChecked()) flags |= NewClassDlgData::NonCopyable;

    if(m_checkBoxImplPureVirtual->IsChecked()) flags |= NewClassDlgData::ImplAllPureVirtualFuncs;

    if(m_checkBoxImplVirtual->IsChecked()) flags |= NewClassDlgData::ImplAllVirtualFuncs;

    if(m_checkBoxInline->IsChecked()) flags |= NewClassDlgData::FileIniline;

    if(m_checkBoxHpp->IsChecked()) flags |= NewClassDlgData::HppHeader;

    if(m_checkBoxSingleton->IsChecked()) flags |= NewClassDlgData::Singleton;

    if(m_checkBoxVirtualDtor->IsChecked()) flags |= NewClassDlgData::VirtualDtor;

    NewClassDlgData data;
    data.SetFlags(flags);
    EditorConfigST::Get()->WriteObject(wxT("NewClassDlgData"), &data);

    EndModal(wxID_OK);
}
Пример #7
0
void ParseAsync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 2) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }
  if (!args[1]->IsFunction()) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Second parameter must be a callback")));
    return;
  }

  Nan::Callback *callback = new Nan::Callback(args[1].As<Function>());
  anitomyJs::Worker *worker = new anitomyJs::Worker(callback);

  if (args_length >= 3) {
    Local<Value> options = args[2];
    if (!ValidateOptions(options, isolate) ||
        !worker->GetAnitomy()->SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  worker->GetAnitomy()->SetInput(input, isolate);
  Nan::AsyncQueueWorker(worker);
  args.GetReturnValue().Set(Nan::Undefined());
}
Пример #8
0
void ParseSync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 1) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }

  anitomyJs::AnitomyJs anitomy;
  if (args_length >= 2) {
    Local<Value> options = args[1];
    if (!ValidateOptions(options, isolate) ||
        !anitomy.SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  anitomy.SetInput(input, isolate);
  anitomy.Parse();

  args.GetReturnValue().Set(anitomy.ParsedResult(isolate));
}
Пример #9
0
int Cvfgk::Compress(FILE* fin, FILE* fout, char byTermChar) {
  unsigned char ch;
  int ret;
  if((fin==NULL)||(fout==NULL)) return 1;
  if(!feof(fin)) ch = ValidateInput((unsigned char)fgetc(fin));
  while(!feof(fin)) {
    if(Encode(fout,ch)) return 1;
    Update(ch);
    ch = ValidateInput((unsigned char)fgetc(fin));
    if(ch==byTermChar){
      fseek(fin,-1,SEEK_CUR);
      break;
    }
  }
  if(Encode(fout,ctEndChar)) return 1;
  if(Flush(fout)) return 1;
  return 0;
}
void NewClassDlg::OnButtonOK(wxCommandEvent& e)
{
    wxUnusedVar(e);
    if(!ValidateInput()) {
        return;
    }
    DoSaveOptions();
    EndModal(wxID_OK);
}
Пример #11
0
void CGUIEditControl::SetInputValidation(StringValidation::Validator inputValidator, void *data /* = NULL */)
{
  if (m_inputValidator == inputValidator)
    return;
  
  m_inputValidator = inputValidator;
  m_inputValidatorData = data;
  // the input validator has changed, so re-validate the current data
  ValidateInput();
}
Пример #12
0
//============================
// SenosorWait
//
// Wait for an input on sensorNum 
// then wait waitTime until exiting 
// function
//============================
void SensorWait( int sensorNum ) {
	ValidateInput( sensorNum );
#ifdef NOT_ROBOTC
	printf("SensorWait: sensorNum %d\n", sensorNum);
	sleep( 2 );
	printf("SensorWait: got a signal on %d!\n", sensorNum);
#else
	while ( SensorValue[sensorNum] ) {}
#endif
}
Пример #13
0
ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) {
    ValidationError error;
    if ((error = ValidateInput(text)) != ValidationError::None) {
        return error;
    }
    if ((error = ValidateButton(button)) != ValidationError::None) {
        return error;
    }
    data = {text, button};
    return ValidationError::None;
}
Пример #14
0
int Cvfgk::CompressFasta(FILE* fin, FILE* fout, char byRecStartChar) {
  unsigned char ch;
  int ret;
  fEndOfLineReach=false;
  if((fin==NULL)||(fout==NULL)) return 1;
  if(!feof(fin)) ch = ValidateInput((unsigned char)fgetc(fin));
  while(!feof(fin)) {
    if(Encode(fout,ch)) return 1;
    Update(ch);
    ch = ValidateInput((unsigned char)fgetc(fin));
    if((ch==byRecStartChar)&&fEndOfLineReach){
      fseek(fin,-1,SEEK_CUR);
      break;
    }
    fEndOfLineReach=(ch=='\n')?true:false;
  }
  if(Encode(fout,ctEndChar)) return 1;
  if(Flush(fout)) return 1;
  return 0;
}
Пример #15
0
void CGUIEditControl::UpdateText(bool sendUpdate)
{
  m_smsTimer.Stop();
  if (sendUpdate)
  {
    ValidateInput();

    SEND_CLICK_MESSAGE(GetID(), GetParentID(), 0);

    m_textChangeActions.ExecuteActions(GetID(), GetParentID());
  }
  SetInvalid();
}
Пример #16
0
void _ValidateInput( void ) {
	int inputNum = 0;

	printf("Enter an input number:\n"
                "(1 -> 6) = (in1 -> in6)\n"
                "(7 -> 12) = (dgtl1 -> dgtl6)\n");
	scanf("%d", &inputNum);

	inputNum = NumtoIO( inputNum, INPUT );

	printf("Validating input number %d.\n", inputNum);
	ValidateInput( inputNum );
}
Пример #17
0
void CGUIEditControl::SetLabel2(const std::string &text)
{
  m_edit.clear();
  std::wstring newText;
  g_charsetConverter.utf8ToW(text, newText);
  if (newText != m_text2)
  {
    m_isMD5 = (m_inputType == INPUT_TYPE_PASSWORD_MD5 || m_inputType == INPUT_TYPE_PASSWORD_NUMBER_VERIFY_NEW);
    m_text2 = newText;
    m_cursorPos = m_text2.size();
    ValidateInput();
    SetInvalid();
  }
}
Пример #18
0
void CDlgLogin::OnChgpwd() 
{
	if (!ValidateInput()) 
		return;

	if (!m_csUID.IsEmpty())
	{
		CDlgChgInfo dlg(m_csUID, this);
		dlg.DoModal();
	}
	else
	{
		MessageBox("请先填写用户名!", "注意");
	}
}
Пример #19
0
void CGUIEditControl::ValidateInput()
{
  // validate the input
  bool invalid = !ValidateInput(m_text2);
  // nothing to do if still valid/invalid
  if (invalid != m_invalidInput)
  {
    // the validity state has changed so we need to update the control
    m_invalidInput = invalid;

    // let the window/dialog know that the validity has changed
    CGUIMessage msg(GUI_MSG_VALIDITY_CHANGED, GetID(), GetID(), m_invalidInput ? 0 : 1);
    SendWindowMessage(msg);

    SetInvalid();
  }
}
Пример #20
0
//{Events
void avVersionEditorDlg::OnAcceptClick(wxCommandEvent&)
{
    tmrValidateInput.Stop();
    ValidateInput();

    txtMajorVersion->GetValue().ToLong(&m_major);
    txtMinorVersion->GetValue().ToLong(&m_minor);
    txtBuildNumber->GetValue().ToLong(&m_build);
    txtRevisionNumber->GetValue().ToLong(&m_revision);
    txtBuildCount->GetValue().ToLong(&m_count);

    m_autoMajorMinor = chkAutoIncrement->IsChecked();
    m_dates = chkDates->IsChecked();
    m_svn = chkSvn->IsChecked();
    m_svnDirectory = txtSvnDir->GetValue();
    m_commit = chkCommit->IsChecked();
    m_askCommit = chkAskCommit->IsChecked();
    m_language = rbHeaderLanguage->GetStringSelection();
    m_headerPath = txtHeaderPath->GetValue();

    m_status = cmbStatus->GetValue();
    m_statusAbbreviation = cmbAbbreviation->GetValue();

    txtMinorMaximun->GetValue().ToLong(&m_minorMaximun);
    txtBuildNumberMaximun->GetValue().ToLong(&m_buildMaximun);
    txtRevisionMax->GetValue().ToLong(&m_revisionMaximun);
    txtRevisionRandom->GetValue().ToLong(&m_revisionRandomMaximun);
    txtBuildTimes->GetValue().ToLong(&m_buildTimesToMinorIncrement);

    m_changes = chkChanges->IsChecked();
    m_changesTitle = txtChangesTitle->GetValue();
    m_changesLogPath = txtChangesLogPath->GetValue();

    m_headerGuard = txtHeaderGuard->GetValue();
    m_namespace = txtNameSpace->GetValue();
    m_prefix = txtPrefix->GetValue();

    EndModal(0);
}
Пример #21
0
//buy ingredients
void BuyStock()
{
	SetRandomCosts(currentCosts);
	int iChoice = 0;
	
	while (iChoice!=4)
	{
		cout << "WELCOME TO THE SHOP\n\n";
		DisplayCosts(currentCosts);
		DisplayRecipe(currentRecipe);
		DisplayStock();
		DisplayMoneyLeft();

		while (iChoice < 1 || iChoice > 5)
		{
			DisplayShopMenu();
			iChoice = ValidateInput();
		}
		switch (iChoice)
		{
			//HANDLE PURCHASE
		case 1:
			BuyLemons();
			break;
		case 2:
			BuySugar();
			break;
		case 3:
			BuyIce();
			break;
		case 4:
			system("cls");
			return;
		}
		iChoice = 0;
	}
}
Пример #22
0
void avVersionEditorDlg::OnTmrValidateInputTrigger(wxTimerEvent& event)
{
    ValidateInput();
}
Пример #23
0
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[] )
{
    int32_T offset;
    int32_T numBytes;
    FILE *fp;
    mxArray *A;
    mxArray *Atmp;
    mxArray *count;
    int outputSize[2];
    uint8_T *prA;
    uint8_T *prAtmp;
    size_t readCount = 0;
    int k;

    ValidateInput(nlhs, nrhs, prhs, &fp, &offset, &numBytes);

    /* Initialize output */
    outputSize[0] = numBytes;
    outputSize[1] = 1;
    A = mxCreateNumericArray(2, outputSize, mxUINT8_CLASS, mxREAL);
    prA = (uint8_T *) mxGetPr(A);
    
    /* Seek to starting offset */
    if (fseek(fp, offset, SEEK_SET) != 0)
    {
        fclose(fp);
        mexErrMsgTxt(strerror(errno));
    }

    /* Read data */
    readCount = fread((void *) prA, sizeof(uint8_T), (size_t) numBytes, fp);
    if (ferror(fp))
    {
        fclose(fp);
        mexErrMsgTxt(strerror(errno));
    }

    /* Did we read as much data as requested? */
    if (readCount < numBytes)
    {
        /* We must reallocate the output matrix with the correct size */
        outputSize[0] = readCount;
        outputSize[1] = 1;
        Atmp = mxCreateNumericArray(2, outputSize, mxUINT8_CLASS, mxREAL);
        prAtmp = (uint8_T *) mxGetPr(Atmp);
        for (k = 0; k < readCount; k++)
        {
            *prAtmp = *prA;
            prAtmp++;
            prA++;
        }
        mxDestroyArray(A);
        A = Atmp;
        Atmp = NULL;
    }

    /* Return the first output argument and clean up */
    plhs[0] = A;

    fclose(fp);
}
void ClientGameSession::handleEvent( const Event& _theEvent )
{
    if( _theEvent.getType() == EventType::GAMEPLAY )
    {
        const GameplayEvent& gpEvent = static_cast<const GameplayEvent&>( _theEvent );
        switch( gpEvent.getType() )
        {
            case GameEvent::MATCHED:
                {
                    const MatchedGameplayEvent& m = static_cast<const MatchedGameplayEvent&>( _theEvent );
                    mIsPlayer0 = m.GetIsPlayer0();
                    mOpponentName = m.GetOpponentName();
                    mMatched = true;
                }
                break;
            case GameEvent::VALID_TURN:
                {
                    const ValidTurnGameplayEvent& vt = static_cast<const ValidTurnGameplayEvent&>( _theEvent );
                    AddDisc( vt.GetColumn(), mIsPlayer0Turn );
                    IntegrateInput( vt.GetColumn(), mIsPlayer0Turn );
                }
                break;
        }
    }
    else if( _theEvent.getType() == EventType::KEYBOARD )
    {
        const KeyboardEvent& kbEvent = static_cast<const KeyboardEvent&>( _theEvent );

        if( kbEvent.getKey() == Key::KEY_LEFT && kbEvent.getKeyState() == KeyState::KEYSTATE_DOWN )
        {
            if( mGameState == GameState::MY_TURN )
            {
                mpSoundProvider->playSound( "assets/woosh1.wav" );
                mSelectedColumn = ( mSelectedColumn + COLUMN_COUNT - 1 ) % COLUMN_COUNT;
            }
        }
        else if( kbEvent.getKey() == Key::KEY_RIGHT && kbEvent.getKeyState() == KeyState::KEYSTATE_DOWN )
        {
            if( mGameState == GameState::MY_TURN )
            {
                mpSoundProvider->playSound( "assets/woosh1.wav" );
                mSelectedColumn = ( mSelectedColumn + 1 ) % COLUMN_COUNT;
            }
        }
        else if( kbEvent.getKey() == Key::KEY_SPACE && kbEvent.getKeyState() == KeyState::KEYSTATE_DOWN )
        {
            if( ValidateInput( mSelectedColumn, mIsPlayer0 ) )
            {
                mpSoundProvider->playSound( "assets/woosh3.wav" );
                mpNetworkPeer->SendTurnPropose( mSelectedColumn );
            }
        }

        if( kbEvent.getKey() == Key::KEY_ESCAPE )
        {
            exit();
        }

        if( kbEvent.getKey() == Key::KEY_Z )
        {
            mpSoundProvider->stopAllSounds();
        }
    }
}
Пример #25
0
int DruckerPrager::Check( const Properties& props, const GeometryType& geom, const ProcessInfo& CurrentProcessInfo )
{
    if ( ValidateInput( props ) )
        return 0;
    return -1;
}