Example #1
0
AB_ARG_CLASS
util_string_to_arg_class(STRING arg_class_string)
{
    arg_class_tab_check_init();
    return (AB_ARG_CLASS)convert_string_to_int(arg_class_string,
		arg_class_tab, ARRAY_SIZE(arg_class_tab), -1);
}
Example #2
0
AB_ARG_TYPE
util_string_to_arg_type(STRING arg_type_string)
{
    arg_type_tab_check_init();
    return (AB_ARG_TYPE)convert_string_to_int(arg_type_string,
		arg_type_tab, ARRAY_SIZE(arg_type_tab), -1);
}
Example #3
0
AB_LABEL_TYPE
util_string_to_label_type(STRING type_string)
{
	label_type_tab_check_init();
	return (AB_LABEL_TYPE)convert_string_to_int(type_string,
		label_type_tab, ARRAY_SIZE(label_type_tab), -1);
}
Example #4
0
AB_BUTTON_TYPE
util_string_to_button_type(STRING type_string)
{
    button_type_tab_check_init();
    return (AB_BUTTON_TYPE)convert_string_to_int(type_string,
		button_type_tab, ARRAY_SIZE(button_type_tab), -1);
}
Example #5
0
AB_BUILTIN_ACTION
util_string_to_builtin_action(STRING action)
{
	return (AB_BUILTIN_ACTION)convert_string_to_int(action,
			builtin_action_table, AB_BUILTIN_ACTION_NUM_VALUES,
			AB_STDACT_UNDEF);
}
Example #6
0
AB_ALIGNMENT
util_string_to_alignment(STRING align_string)
{
    align_tab_check_init();
    return (AB_ALIGNMENT)convert_string_to_int(align_string,
		align_tab, ARRAY_SIZE(align_tab), -1);
}
Example #7
0
static bool argument_ordinal (int argc, char **argv, int *argi, AppArgument *arguments, int *order)
{
        size_t i, digits;

        (void)argc;
        for (i = 0; arguments[i].type != AppArgumentTypeEnd; i++) {
                if (arguments[i].type != AppArgumentTypeOrdinal) {
                        continue;
                }
                if (arguments[i].object.ordinal.order != *order) {
                        continue;
                }
                switch (arguments[i].value_type) {
                case AppArgumentBoolean:
                        error (InvalidOperation);
                        return false;
                case AppArgumentInteger:
                        if (!convert_string_to_int (argv[*argi], arguments[i].value.integer, &digits)) {
                                print ("The value '%s' could not be converted to an integer value.\n", argv[*argi]);
                                error_code (FunctionCall, 1);
                                return false;
                        }
                        if (digits != string_length (argv[*argi])) {
                                print ("The value '%s' could not be converted to an integer value.\n", argv[*argi]);
                                error (AppArgumentInvalidIntegerValue);
                                return false;
                        }
                        arguments[i].have_value = true;
                        *argi += 1;
                        *order += 1;
                        return true;
                case AppArgumentUInt64:
                        if (!convert_string_to_unsigned_long_long (argv[*argi], 
                                                                   (unsigned long long *)arguments[i].value.uint64, 
                                                                   &digits)) {
                                print ("The value '%s' could not be converted to an UInt64 value.\n", argv[*argi]);
                                error_code (FunctionCall, 2);
                                return false;
                        }
                        if (digits != string_length (argv[*argi])) {
                                print ("The value '%s' could not be converted to an UInt64 value.\n", argv[*argi]);
                                error (AppArgumentInvalidUInt64Value);
                                return false;
                        }
                        arguments[i].have_value = true;
                        *argi += 1;
                        *order += 1;
                        return true;
                case AppArgumentString:
                        *arguments[i].value.string = argv[*argi];
                        arguments[i].have_value = true;
                        *argi += 1;
                        *order += 1;
                        return true;
                }
        }
        print ("Unrecognized argument '%s'.\n", argv[*argi]);
        error (AppArgumentUnknownOrdinalArgument);
        return false;
}
Example #8
0
AB_ITEM_TYPE
util_string_to_item_type(STRING item_string)
{
    item_tab_check_init();
    return
(AB_ITEM_TYPE)convert_string_to_int(item_string,
                item_tab, ARRAY_SIZE(item_tab), -1);
}
Example #9
0
AB_WHEN
util_string_to_when(STRING when_string)
{
	check_when_table_init();
	return (AB_WHEN)convert_string_to_int(
		when_string,
		when_table, AB_WHEN_NUM_VALUES, AB_WHEN_UNDEF);
}
Example #10
0
AB_OBJECT_TYPE
util_browser_string_to_object_type(STRING string_type)
{
	check_browser_obj_type_table_init();
	return (AB_OBJECT_TYPE)convert_string_to_int(
		string_type,
		browser_obj_type_table, AB_OBJECT_TYPE_NUM_VALUES, AB_TYPE_UNKNOWN);
}
Example #11
0
AB_CONTAINER_TYPE
util_string_to_container_type(STRING container_string)
{
    container_tab_check_init();
    return
(AB_CONTAINER_TYPE)convert_string_to_int(container_string,
                container_tab, ARRAY_SIZE(container_tab),
-1);
}
Example #12
0
static bool argument_named (int argc, char **argv, int *argi, AppArgument *arguments)
{
        size_t i, digits;

        for (i = 0; arguments[i].type != AppArgumentTypeEnd; i++) {
                if (arguments[i].type != AppArgumentTypeNamed) {
                        continue;
                }
                if (!((arguments[i].object.named.short_form && 
                       string_equals (argv[*argi], arguments[i].object.named.short_form)) ||
                      (arguments[i].object.named.long_form && 
                       string_equals (argv[*argi], arguments[i].object.named.long_form)))) {
                        continue;
                }
                if (arguments[i].have_value) {
                        print ("The argument ");
                        app_arguments_print_named_form (arguments[i]);
                        print (" is duplicated.\n");
                        error (AppArgumentDuplicate);
                        return false;
                }
                switch (arguments[i].value_type) {
                case AppArgumentBoolean:
                        *arguments[i].value.boolean = !arguments[i].value_default.boolean;
                        arguments[i].have_value = true;
                        *argi += 1;
                        return true;
                case AppArgumentInteger:
                        if (*argi + 1 == argc) {
                                print ("The argument ");
                                app_arguments_print_named_form (arguments[i]);
                                print (" is missing an integer value.\n");
                                error (AppArgumentMissingIntegerValue);
                                return false;
                        }
                        if (!convert_string_to_int (argv[*argi + 1], arguments[i].value.integer, &digits)) {
                                print ("The value '%s' for ", argv[*argi + 1]);
                                app_arguments_print_named_form (arguments[i]);
                                print (" could not be converted to an integer value.\n");
                                error_code (FunctionCall, 1);
                                return false;
                        }
                        if (digits != string_length (argv[*argi + 1])) {
                                print ("The value '%s' for ", argv[*argi + 1]);
                                app_arguments_print_named_form (arguments[i]);
                                print (" could not be converted to an integer value.\n");
                                error (AppArgumentInvalidIntegerValue);
                                return false;
                        }
                        arguments[i].have_value = true;
                        *argi += 2;
                        return true;
                case AppArgumentUInt64:
                        if (*argi + 1 == argc) {
                                print ("The argument ");
                                app_arguments_print_named_form (arguments[i]);
                                print (" is missing an UInt64 value.\n");
                                error (AppArgumentMissingUInt64Value);
                                return false;
                        }
                        if (!convert_string_to_unsigned_long_long (argv[*argi + 1], 
                                                                   (unsigned long long *)arguments[i].value.uint64, 
                                                                   &digits)) {
                                print ("The value '%s' for ", argv[*argi + 1]);
                                app_arguments_print_named_form (arguments[i]);
                                print (" could not be converted to an UInt64 value.\n");
                                error_code (FunctionCall, 2);
                                return false;
                        }
                        if (digits != string_length (argv[*argi + 1])) {
                                print ("The value '%s' for ", argv[*argi + 1]);
                                app_arguments_print_named_form (arguments[i]);
                                print (" could not be converted to an UInt64 value.\n");
                                error (AppArgumentInvalidUInt64Value);
                                return false;
                        }
                        arguments[i].have_value = true;
                        *argi += 2;
                        return true;
                case AppArgumentString:
                        if (*argi + 1 == argc) {
                                print ("The argument ");
                                app_arguments_print_named_form (arguments[i]);
                                print (" is missing a string value.\n");
                                error (AppArgumentMissingStringValue);
                                return false;
                        }
                        *arguments[i].value.string = argv[*argi + 1];
                        arguments[i].have_value = true;
                        *argi += 2;
                        return true;
                }
        }
        print ("Unrecognized argument '%s'.\n", argv[*argi]);
        error (AppArgumentUnknownNamedArgument);
        return false;
}
Example #13
0
void insert_from_file::insert_boost_file(aux_functions aquifer_reference,
		string elem_run_file, string type, aem_container & the_list,
		aem_container & the_u_list,vector<aux_polygon> &vec_polygon_ld) {
	double x1 = 0;
	double y1 = 0;
	double x2 = 0;
	double y2 = 0;
	double R = 0;
	double head = 0;
	int is_know = 0;
	double discharge = 0;
	double Qx = 0;
	double Qy = 0;
	int int_type = 0;
	double condutivity = 0;
	complex<double> set_previous;
	complex<double> set_next;
	double aq_conductivity = aquifer_reference.get_aquifer_conductivity();


	ifstream data_file;
	data_file.open(elem_run_file.c_str()); //this is c_str(), a f&$ing way to convert a string to char *.
	//const charT* c_str() const >> Returns a pointer to a null-terminated array of characters representing the string's contents.

	//checking for error
	if (!data_file) {
		cerr << "Error! Data file " << data_file << "file cannot be opened! \n"
				<< endl;
		exit(-1);
	}
	vector <line_doublet * >::iterator current;
	vector <line_doublet * >::iterator previous;
	vector <line_doublet * >::iterator next;
	vector <line_doublet * > ld_coords;

	complex<double> previous_coord(-1, -1);
	complex<double> ini;


	vector<point_2d> temp_ld_coords;
	polygon_2d temp_polygon_ld;
	aux_polygon temp_aux_polygon_ld;
	//vector<aux_polygon> vec_polygon_ld;

	int_type = convert_string_to_int(type);//convert the input string to the well_id line_sink_id line_doublet notation

	switch (int_type) {

	case kind_well:
		cout <<"Inserting Wells"<<endl;
		while (data_file >> x1 >> y1 >> R >> head >> discharge >> is_know) {
			complex<double> tp(x1, y1);
			if (is_know) {
				the_list.add_element(new well(is_know, head, discharge, tp, R,kind_well));
			} else {
				the_u_list.add_element(
						new well(is_know, head, discharge, tp, R, kind_well));
			}

		}
		break;
	case kind_ls:
		cout <<"Inserting Line Sinks"<<endl;
		while (data_file >> x1 >> y1 >> x2 >> y2 >> head >> discharge
				>> is_know) {
			complex<double> tp(x1, y1);
			complex<double> tp2(x2, y2);
			if (is_know) {
				the_list.add_element(new line_sink(is_know, head, discharge,
						tp, tp2, kind_ls));
			} else {
				the_u_list.add_element(new line_sink(is_know, head, discharge,
						tp, tp2, kind_ls));
			}

		}
		break;
	case kind_ld:
		cout <<"Inserting Line Doublets"<<endl;
		data_file >> condutivity;

		data_file.clear();
		data_file.seekg(0, ios::beg);
		data_file >> condutivity; //argh! but needed to jump the first line.


		while (data_file >> x1 >> y1) {

			complex<double> tp(x1, y1);


			ld_coords.push_back(new line_doublet(is_know, head, discharge, tp,
											condutivity, aq_conductivity, kind_ld));
			temp_ld_coords.push_back(make<point_2d> (x1, y1));

		}

		//calculates here part of the matrix, maybe adding to a list


		previous = ld_coords.end() - 1;
		current = ld_coords.begin();
		next = ld_coords.begin() + 1;

		for (; current != ld_coords.end(); ++next, ++current, ++previous) {

			if (next == ld_coords.end()) {
				next = ld_coords.begin();
			}
			if (previous == ld_coords.end()) {
				previous = ld_coords.begin();
			}
			(*current)->set_next(*next);
			(*current)->set_previous(*previous);
			the_u_list.add_element(*current);

		}
				assign(temp_polygon_ld, temp_ld_coords);
				correct(temp_polygon_ld);

				cout<< "area "<<area(temp_polygon_ld)<<endl;

				temp_aux_polygon_ld.set_conductivity(condutivity);
				temp_aux_polygon_ld.set_polygon(temp_polygon_ld);
				vec_polygon_ld.push_back(temp_aux_polygon_ld);
				//cout <<"id: "<<ld_counter_id<<endl;

				ld_counter_id++;

		break;

	case kind_cf:

		while (data_file >> Qx >> Qy) {
			complex<double> tp(0, 0);
			the_list.add_element(new constant_flux(0,0,0,tp,kind_cf,Qx,Qy));

		}
		break;

	default:
		cerr << "Element not valid! Wrong number or not implemented" << endl;
		exit(-1);
	}

	cout << "Exiting insert_elements" << endl;


}