mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Updated the examples to use dlib::sa rather than string_cast.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403878
This commit is contained in:
parent
528005a159
commit
9cab0eca08
@ -661,7 +661,7 @@ on_sel_node_evidence_modified (
|
||||
{
|
||||
// get the numerical value of the new evidence value. Here we are taking
|
||||
// the string from the text field and casting it to an unsigned long.
|
||||
value = string_cast<unsigned long>(trim(sel_node_evidence.text()));
|
||||
value = sa = trim(sel_node_evidence.text());
|
||||
}
|
||||
catch (string_cast_error&)
|
||||
{
|
||||
@ -704,7 +704,7 @@ on_sel_node_num_values_modified (
|
||||
try
|
||||
{
|
||||
// get the number of values out of the text field.
|
||||
num_values = string_cast<unsigned long>(trim(sel_node_num_values.text()));
|
||||
num_values = sa = trim(sel_node_num_values.text());
|
||||
}
|
||||
catch (string_cast_error&)
|
||||
{
|
||||
@ -756,7 +756,7 @@ on_cpt_grid_modified(unsigned long row, unsigned long col)
|
||||
try
|
||||
{
|
||||
// get the new value out of the table
|
||||
prob = string_cast<double>(cpt_grid.text(row,col));
|
||||
prob = sa = cpt_grid.text(row,col);
|
||||
}
|
||||
catch (string_cast_error&)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
||||
parser.check_incompatible_options("c", "d");
|
||||
|
||||
// Here I'm checking that the argument to the l option is an integer in the range 1 to 3.
|
||||
// That is, it should be convertible to an int by dlib::string_cast<int>() and be either
|
||||
// That is, it should be convertible to an int by dlib::string_assign and be either
|
||||
// 1, 2, or 3. Note that if you wanted to allow floating point values in the range 1 to
|
||||
// 3 then you could give a range 1.0 to 3.0 or explicitly supply a type of float or double
|
||||
// to the template argument of the check_option_arg_range() function.
|
||||
@ -119,8 +119,10 @@ int main(int argc, char** argv)
|
||||
// Figure out what the compression level should be. The default is 2.
|
||||
int compression_level = 2;
|
||||
// If the user supplied the -l option then use whatever value they gave for the level.
|
||||
// Note that we use the string_assign object, sa, to convert the string returned
|
||||
// by argument() to an int.
|
||||
if (parser.option("l"))
|
||||
compression_level = string_cast<int>(parser.option("l").argument());
|
||||
compression_level = sa = parser.option("l").argument();
|
||||
|
||||
|
||||
|
||||
|
@ -99,11 +99,13 @@ int main()
|
||||
cout << cr.block("user1").block("details")["editor"] << endl;
|
||||
|
||||
|
||||
// Note that you can use the string_cast function to easily convert fields
|
||||
// Note that you can use the string_assign object, sa, to easily convert fields
|
||||
// into non-string types. For example, the config file has an integer id
|
||||
// field that could be converted into an int like so:
|
||||
int id = string_cast<int>(cr.block("user2")["id"]);
|
||||
cout << "user2's id is " << id << endl;
|
||||
int id1 = sa = cr.block("user1")["id"];
|
||||
int id2 = sa = cr.block("user2")["id"];
|
||||
cout << "user1's id is " << id1 << endl;
|
||||
cout << "user2's id is " << id2 << endl;
|
||||
|
||||
}
|
||||
catch (exception& e)
|
||||
|
Loading…
Reference in New Issue
Block a user