예제 #1
0
  int CValEdit::edit(){
	  int key;
	  bool valid=false;
    if(container()){
      if(_help){
		_help(MessageStatus::SetMessage,*(container()));
	  }
	  key=CLineEdit::edit();
	  if ((key == UP || key == DOWN || key == TAB || key == ENTER)&&_validate){
		  
		  valid=_validate((char*)_data,*(container()));
		  while ((key == UP || key == DOWN || key == TAB || key == ENTER)&&!valid){
            key=CLineEdit::edit();
		    valid=_validate((char*)_data,*(container()));
		  }
		  	  
	  }
	  if(_help){
		_help(MessageStatus::ClearMessage,*(container()));
	  }
	}else{
	  key:CLineEdit::edit();
	}
	return key;
	}
예제 #2
0
파일: post.c 프로젝트: apprisi/illumos-gate
int
set_form_page(FORM *f, int page)
{
	if (!f || !ValidPage(f, page))
		return (E_BAD_ARGUMENT);

	if (!Status(f, POSTED)) {
		P(f) = page;
		C(f) = _first_active(f);
		return (E_OK);
	}
	if (Status(f, DRIVER))
		return (E_BAD_STATE);

	if (page != P(f)) {
		if (_validate(f)) {
			int v;

			term_field(f);
			term_form(f);
			v = _set_form_page(f, page, (FIELD *) 0);
			init_form(f);
			init_field(f);
			(void) _update_current(f);
			return (v);
		} else
			return (E_INVALID_FIELD);
	}
	return (E_OK);
}
예제 #3
0
파일: soctree.c 프로젝트: rubicks/soctree
/* guard predicate */
_node_t *_root(soctree_t *p) {
  if (p) {
    if (0 == (uintptr_t)p % sizeof(soctree_t)) {
      return _validate(p->root_);
    }
  }
  return NULL;
}
예제 #4
0
void ScriptCreateDialog::_create_new() {

	if (class_name->is_editable() && !_validate(class_name->get_text())) {
		alert->set_text(TTR("Class name is invalid!"));
		alert->popup_centered_minsize();
		return;
	}
	if (!_validate(parent_name->get_text())) {
		alert->set_text(TTR("Parent class name is invalid!"));
		alert->popup_centered_minsize();
		return;
	}

	String cname;
	if (class_name->is_editable())
		cname=class_name->get_text();

	Ref<Script> scr = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());

	String selected_language = language_menu->get_item_text(language_menu->get_selected());
	editor_settings->set_last_selected_language(selected_language);

	if (cname!="")
		scr->set_name(cname);

	if (!internal->is_pressed()) {
		String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
		scr->set_path(lpath);
		if (!path_valid) {
			alert->set_text(TTR("Invalid path!"));
			alert->popup_centered_minsize();
			return;
		}
		Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);
		if (err!=OK) {
			alert->set_text(TTR("Could not create script in filesystem."));
			alert->popup_centered_minsize();
			return;
		}
	}

	hide();
	emit_signal("script_created",scr);

}
예제 #5
0
void ScriptCreateDialog::_class_name_changed(const String &p_name) {

	if (_validate(class_name->get_text())) {
		is_class_name_valid = true;
	} else {
		is_class_name_valid = false;
	}
	_update_dialog();
}
예제 #6
0
파일: settings.cpp 프로젝트: queria/qsrun
bool Settings::_save()
{
    if(! _validate() ) {
        return false;
    }
    _settings.setValue("path/editor", _editorPath->text());
    _settings.setValue("time/refresh", _refreshSeconds->value());
    emit changed();
    return true;
}
예제 #7
0
void ScriptCreateDialog::_class_name_changed(const String& p_name) {

	if (!_validate(parent_name->get_text())) {
		error_label->set_text(TTR("Invalid parent class name"));
		error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
	} else if (class_name->is_editable()) {
		if (class_name->get_text()=="") {
		error_label->set_text(TTR("Valid chars:")+" a-z A-Z 0-9 _");
		error_label->add_color_override("font_color",Color(1,1,1,0.6));
		} else if (!_validate(class_name->get_text())) {
			error_label->set_text(TTR("Invalid class name"));
			error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8));
		} else {
			error_label->set_text(TTR("Valid name"));
			error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
		}
	} else {

		error_label->set_text(TTR("N/A"));
		error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
	}
}
예제 #8
0
void ScriptCreateDialog::_class_name_changed(const String& p_name) {

    if (!_validate(parent_name->get_text())) {
        error_label->set_text("INVALID PARENT CLASS NAME");
        error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
    } else if (class_name->is_editable()) {
        if (class_name->get_text()=="") {
            error_label->set_text("Valid Chars: a-z A-Z 0-9 _");
            error_label->add_color_override("font_color",Color(1,1,1,0.6));
        } else if (!_validate(class_name->get_text())) {
            error_label->set_text("INVALID CLASS NAME");
            error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8));
        } else {
            error_label->set_text("Name is Valid");
            error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
        }
    } else {

        error_label->set_text("N/A");
        error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
    }
}
예제 #9
0
void validate_files(char plaintext[], char key[])
{
    // validate plaintext and key
    int bool_plaintext = _validate(plaintext);
    if(bool_plaintext == 0)
    {
        printf("plaintext contains invalid characters.");
        exit(1);
    }

    int bool_key = _validate(key);
    if(bool_plaintext == 0)
    {
        printf("key has invalid characters.");
        exit(1);
    }


    if(bool_plaintext > bool_key)
    {
        printf("Error: key length insufficient");
        exit(1);
    }
}
예제 #10
0
INT32 _qgmOptiNLJoin::_extend( _qgmOptiTreeNode *&exNode )
{
    INT32 rc = SDB_OK ;
    SDB_ASSERT( 2 == _children.size(), "impossible" ) ;

    rc = _validate() ;
    if ( SDB_OK != rc )
    {
        goto error ;
    }

    exNode = this ;

done:
    return rc ;
error:
    goto done ;
}
예제 #11
0
파일: post.c 프로젝트: apprisi/illumos-gate
int
set_current_field(FORM *f, FIELD *c)
{
	if (!f || !c || c->form != f)
		return (E_BAD_ARGUMENT);

	if (!Opt(c, O_ACTIVE) || !Opt(c, O_VISIBLE))
		return (E_REQUEST_DENIED);

	if (!Status(f, POSTED)) {
		C(f) = c;
		P(f) = c->page;
		return (E_OK);
	}
	if (Status(f, DRIVER))
		return (E_BAD_STATE);

	if (c != C(f)) {
		if (_validate(f)) {
			int v;

			term_field(f);

			if (c -> page != P(f)) {	/* page change */
				term_form(f);
				v = _set_form_page(f, c->page, c);
				init_form(f);
			} else
				v = _set_current_field(f, c);

			init_field(f);
			(void) _update_current(f);
			return (v);
		} else
			return (E_INVALID_FIELD);
	}
	return (E_OK);
}
예제 #12
0
	glm::vec3 CameraOld::getUp()
	{
		_validate();
		return mCamMatrix[1].xyz;
	}
예제 #13
0
파일: utf8.hpp 프로젝트: Extrunder/oglplus
	bool operator()(const char* begin, const char* end) const
	{
		return _validate(begin, end) == end;
	}
예제 #14
0
파일: soctree.c 프로젝트: rubicks/soctree
static bool _has_children(_node_t *o) { return _validate(_children(o)); }
예제 #15
0
	const glm::mat4& CameraOld::getViewMatrix()
	{
		_validate();
		return mViewMatrix;
	}
예제 #16
0
int main(int argc, char ** argv)
{
    // process options
    if(argc == 1 || (argc > 1 && strcmp(argv[1],"-h") == 0) ) {
        help(argv[0]);
        exit(0);
    }

    // Since the output of this program will be compared with
    // a master output file, turn off ICU message loading.
    MessageLoader::_useDefaultMsg = true;

    String testOption;
    String className;
    String nameSpace;

    for(int i = 0; i < argc; i++) {
        if((strcmp(argv[i],"-test") == 0) && (i+1 < argc))
            testOption = argv[i+1];
        if((strcmp(argv[i],"-className") == 0) && (i+1 < argc))
            className = argv[i+1];
        if((strcmp(argv[i],"-nameSpace") == 0) && (i+1 < argc))
            nameSpace = argv[i+1];
    }

    String lang("WQL");
    Array<CQLSelectStatement> _statements;

    // setup test environment
    // get the configuration variable PEGASUS_HOME
    const char* peg_home = getenv("PEGASUS_HOME");

    // get the makefile build config variable REPOSITORY_NAME
    const char* repo_name = getenv("REPOSITORY_NAME");


    if (peg_home == NULL)
        exit(-1);

    if (repo_name == NULL)
        repo_name = "repository";


    String repositoryDir(peg_home);
    repositoryDir.append("/");
    repositoryDir.append(repo_name);

    CIMNamespaceName _ns;
    if(nameSpace != String::EMPTY) {
        _ns = nameSpace;
    } else {
        cout << "Using root/SampleProvider as default namespace." << endl;
        _ns = String("root/SampleProvider");
    }

    CIMRepository* _rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _ctx(_ns, _rep);

    char text[1024];
    char* _text;

    // setup Test Instances
    Array<CIMInstance> _instances;
    if(className != String::EMPTY) {
        try {
            const CIMName _testclass(className);
            _instances = _rep->enumerateInstances( _ns, _testclass, true );  // deep inh true
        } catch(Exception& e) {
            cout << endl << endl
                 << "Exception: Invalid namespace/class: "
                 << e.getMessage() << endl << endl;
        }
    } else { // load default class names
        cout << endl << "Using default class names to test queries. " << endl << endl;
        const CIMName _testclass(String("QExpr_TestPropertyTypes"));
        const CIMName _testclass2(String("QExpr_TestElement"));
        try {
            _instances = _rep->enumerateInstances( _ns, _testclass, true ); // deep inh true
            _instances.appendArray(_rep->enumerateInstances( _ns, _testclass2, true )); // deep inh true
        } catch(Exception& e) {
            cout << endl << endl << "Exception: Invalid namespace/class: " << e.getMessage() << endl << endl;
        }
    }

    // setup input stream
    if(argc >= 2) {
        ifstream queryInputSource(argv[1]);
        if(!queryInputSource) {
            cout << "Cannot open input file.\n" << endl;
            return 1;
        }
        int cnt = 0;
        while(!queryInputSource.eof()) {
            queryInputSource.getline(text, 1024);
            char* _ptr = text;
            _text = strcat(_ptr,"\n");
            // check for comments and ignore
            // a comment starts with a # as the first non whitespace character on the line
            char _comment = '#';
            int i = 0;
            while(text[i] == ' ' || text[i] == '\t') i++; // ignore whitespace
            if(text[i] != _comment)
            {
                if(!(strlen(_text) < 2))
                {
                    String query(text);
                    if(query == "WQL:\n") lang = "WQL";
                    else if(query == "CQL:\n") lang = "CIM:CQL";
                    else
                    {
                        try
                        {
                            QueryExpression qexpr;

                            if(cnt % 2)
                            {
                                qexpr = QueryExpression(lang,query);
                                qexpr.setQueryContext(_ctx);
                            }
                            else
                            {
                                qexpr = QueryExpression(lang,query,_ctx);
                            }

                            cnt++;

                            SelectStatement* ss = qexpr.getSelectStatement();

                            String returnQuery = qexpr.getQuery();
                            PEGASUS_ASSERT(returnQuery == query);

                            String returnLang = qexpr.getQueryLanguage();
                            PEGASUS_ASSERT(returnLang == lang);

                            QueryExpression copy(qexpr);
                            PEGASUS_ASSERT(copy.getQuery() == qexpr.getQuery());
                            PEGASUS_ASSERT(copy.getQueryLanguage() == qexpr.getQueryLanguage());

                            _applyProjection(qexpr,_instances, testOption, lang);
                            _getPropertyList(qexpr,_instances, _ns, testOption,lang);
                            _validate(qexpr,lang, testOption);
                            _evaluate(qexpr,_instances, testOption,lang);
                        }
                        catch(Exception& e) {
                            cout << e.getMessage() << endl;
                        }
                        catch(...) {
                            cout << "CAUGHT ... BADNESS HAPPENED!!!" << endl;
                        }
                    }
                }
            }

            // while (!eof) behaves differently on HP-UX, seems
            // like it takes an extra iteration to hit eof.  This
            // leaves "text" with the previous value from
            // getline(..), which causes a duplicate parse of
            // the last select statement in the query file,
            // FIX: we clear text before doing another getline(..)
            text[0] = 0;
        }
        queryInputSource.close();
    } else {
        cout << "Invalid number of arguments.\n" << endl;
    }
    delete _rep;
    return 0;
}
예제 #17
0
void ScriptCreateDialog::ok_pressed() {

	if (class_name->is_editable() && !_validate(class_name->get_text())) {

		alert->set_text("Class Name is Invalid!");
		alert->popup_centered_minsize();
		return;
	}
	if (!_validate(parent_name->get_text())) {
		alert->set_text("Parent Class Name is Invalid!");
		alert->popup_centered_minsize();

		return;

	}


	String cname;
	if (class_name->is_editable())
		cname=class_name->get_text();



	String text = ScriptServer::get_language( language_menu->get_selected() )->get_template(cname,parent_name->get_text());
	Script *script = ScriptServer::get_language( language_menu->get_selected() )->create_script();
	script->set_source_code(text);
	if (cname!="")
		script->set_name(cname);


	Ref<Script> scr(script);

	if (!internal->is_pressed()) {


		String lpath = Globals::get_singleton()->localize_path(file_path->get_text());
		script->set_path(lpath);
		if (!path_valid) {

			alert->set_text("Path is Invalid!");
			alert->popup_centered_minsize();
			return;

		}
		Error err = ResourceSaver::save(lpath,scr,ResourceSaver::FLAG_CHANGE_PATH);		
		if (err!=OK) {

			alert->set_text("Could not create script in filesystem: "+String(""));
			alert->popup_centered_minsize();
			return;
		}
		scr->set_path(lpath);
	//EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());


	}

	hide();
	emit_signal("script_created",scr);

}
예제 #18
0
	const glm::mat4& CameraOld::getProjMatrix()
	{
		_validate();
		return mProjMatrix;
	}
예제 #19
0
	const glm::mat4& CameraOld::getCamMatrix()
	{
		_validate();
		return mCamMatrix;
	}
예제 #20
0
	glm::vec3 CameraOld::getForward()
	{
		_validate();
		return mCamMatrix[2].xyz;
	}
예제 #21
0
	glm::vec3 CameraOld::getRight()
	{
		_validate();
		return mCamMatrix[0].xyz;
	}