这篇教程C++ yes_no函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中yes_no函数的典型用法代码示例。如果您正苦于以下问题:C++ yes_no函数的具体用法?C++ yes_no怎么用?C++ yes_no使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了yes_no函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: yes_noconfig::attribute_value &config::attribute_value::operator=(const std::string &v){ // Handle some special strings. if (v.empty()) { value_ = v; return *this; } if ( v == s_yes ) { value_ = yes_no(true); return *this; } if ( v == s_no ) { value_ = yes_no(false); return *this; } if ( v == s_true ) { value_ = true_false(true); return *this; } if ( v == s_false ) { value_ = true_false(false); return *this; } // Attempt to convert to a number. char *eptr; double d = strtod(v.c_str(), &eptr); if ( *eptr == '/0' ) { // Possibly a number. See what type it should be stored in. // (All conversions will be from the string since the largest integer // type could have more precision than a double.) if ( d > 0.0 ) { // The largest type for positive integers is unsigned long long. unsigned long long ull = 0; if ( from_string_verify<unsigned long long>(v, ull) ) return *this = ull; } else { // The largest (variant) type for negative integers is int. int i = 0; if ( from_string_verify<int>(v, i) ) return *this = i; } // This does not look like an integer, so it should be a double. // However, make sure it can convert back to the same string (in // case this is a string that just looks like a numeric value). std::ostringstream tester; tester << d; if ( tester.str() == v ) { value_ = d; return *this; } } // No conversion possible. Store the string. value_ = v; return *this;}
开发者ID:AI0867,项目名称:wesnoth,代码行数:59,
示例2: emit_configurationstatic voidemit_configuration (MateRRConfig *config, GString *string){ int j; g_string_append_printf (string, " <configuration>/n"); g_string_append_printf (string, " <clone>%s</clone>/n", yes_no (config->clone)); for (j = 0; config->outputs[j] != NULL; ++j) { MateOutputInfo *output = config->outputs[j]; g_string_append_printf ( string, " <output name=/"%s/">/n", output->name); if (output->connected && *output->vendor != '/0') { g_string_append_printf ( string, " <vendor>%s</vendor>/n", output->vendor); g_string_append_printf ( string, " <product>0x%04x</product>/n", output->product); g_string_append_printf ( string, " <serial>0x%08x</serial>/n", output->serial); } /* An unconnected output which is on does not make sense */ if (output->connected && output->on) { g_string_append_printf ( string, " <width>%d</width>/n", output->width); g_string_append_printf ( string, " <height>%d</height>/n", output->height); g_string_append_printf ( string, " <rate>%d</rate>/n", output->rate); g_string_append_printf ( string, " <x>%d</x>/n", output->x); g_string_append_printf ( string, " <y>%d</y>/n", output->y); g_string_append_printf ( string, " <rotation>%s</rotation>/n", get_rotation_name (output->rotation)); g_string_append_printf ( string, " <reflect_x>%s</reflect_x>/n", get_reflect_x (output->rotation)); g_string_append_printf ( string, " <reflect_y>%s</reflect_y>/n", get_reflect_y (output->rotation)); g_string_append_printf ( string, " <primary>%s</primary>/n", yes_no (output->primary)); } g_string_append_printf (string, " </output>/n"); } g_string_append_printf (string, " </configuration>/n");}
开发者ID:dmashal,项目名称:mate-desktop,代码行数:55,
示例3: mainint main(){ char question[80]; char suspect[20]; node *start_node = create("Does suspect have a mustache"); start_node->no = create("Loretta Barnsworth"); start_node->yes = create("Vinny the Spoon"); node *current; do { current = start_node; while (1) { if (yes_no(current->question)) { if (current->yes) { current = current->yes; } else { printf("SUSPECT IDENTIFIED/n"); break; } } else if (current->no) { current = current->no; } else { /* Make the yes-node the new suspect name */ printf("Who's the suspect? "); fgets(suspect, 20, stdin); node *yes_node = create(suspect); current->yes = yes_node; /* Make the no-node a copy of this question */ node *no_node = create(current->question); current->no = no_node; /* Then replace this question with the new question */ printf("Give me a question that is TRUE for %s but not for %s? ", suspect, current->question); fgets(question, 80, stdin); free(current->question); current->question = strdup(question); break; } } }while(yes_no("Run again")); release(start_node); return 0;}
开发者ID:matt-song,项目名称:learning_c,代码行数:55,
示例4: kill_context_dumpvoid kill_context_dump(KillContext *c, FILE *f, const char *prefix) { assert(c); prefix = strempty(prefix); fprintf(f, "%sKillMode: %s/n" "%sKillSignal: SIG%s/n" "%sSendSIGKILL: %s/n" "%sSendSIGHUP: %s/n", prefix, kill_mode_to_string(c->kill_mode), prefix, signal_to_string(c->kill_signal), prefix, yes_no(c->send_sigkill), prefix, yes_no(c->send_sighup));}
开发者ID:dankor,项目名称:systemd,代码行数:15,
示例5: mainint main(int argc, char *argv[]) { int r; bool run_ambient; test_last_cap_file(); test_last_cap_probe(); log_parse_environment(); log_open(); log_info("have ambient caps: %s", yes_no(ambient_capabilities_supported())); if (getuid() != 0) return EXIT_TEST_SKIP; r = setup_tests(&run_ambient); if (r < 0) return -r; show_capabilities(); test_drop_privileges(); test_update_inherited_set(); fork_test(test_have_effective_cap); if (run_ambient) fork_test(test_set_ambient_caps); return 0;}
开发者ID:iamyooon,项目名称:systemd,代码行数:31,
示例6: show_single_input_argumentsvoid CommandGetParents::show_arguments() { show_single_input_arguments(m_vout); show_output_arguments(m_vout); m_vout << " other options:/n"; m_vout << " add self: " << yes_no(m_add_self); m_vout << " default object type: " << osmium::item_type_to_name(m_default_item_type) << "/n"; if (m_verbose_ids) { m_vout << " looking for these ids:/n"; m_vout << " nodes:"; for (osmium::object_id_type id : m_ids(osmium::item_type::node)) { m_vout << " " << id; } m_vout << "/n"; m_vout << " ways:"; for (osmium::object_id_type id : m_ids(osmium::item_type::way)) { m_vout << " " << id; } m_vout << "/n"; m_vout << " relations:"; for (osmium::object_id_type id : m_ids(osmium::item_type::relation)) { m_vout << " " << id; } m_vout << "/n"; } else { m_vout << " looking for " << m_ids(osmium::item_type::node).size() << " node ID(s), " << m_ids(osmium::item_type::way).size() << " way ID(s), and " << m_ids(osmium::item_type::relation).size() << " relation ID(s)/n"; }}
开发者ID:tomhughes,项目名称:osmium-tool,代码行数:30,
示例7: mainint main(int argc, char *argv[]) { uid_t shift, range; int r; log_set_max_level(LOG_DEBUG); log_parse_environment(); log_open(); if (argc != 4) { log_error("Expected PATH SHIFT RANGE parameters."); return EXIT_FAILURE; } r = parse_uid(argv[2], &shift); if (r < 0) { log_error_errno(r, "Failed to parse UID shift %s.", argv[2]); return EXIT_FAILURE; } r = parse_gid(argv[3], &range); if (r < 0) { log_error_errno(r, "Failed to parse UID range %s.", argv[3]); return EXIT_FAILURE; } r = path_patch_uid(argv[1], shift, range); if (r < 0) { log_error_errno(r, "Failed to patch directory tree: %m"); return EXIT_FAILURE; } log_info("Changed: %s", yes_no(r)); return EXIT_SUCCESS;}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:35,
示例8: print_sourcestatic void print_source(uint64_t flags, usec_t rtt) { char rtt_str[FORMAT_TIMESTAMP_MAX]; if (!arg_legend) return; if (flags == 0) return; fputs("/n-- Information acquired via", stdout); if (flags != 0) printf(" protocol%s%s%s%s%s", flags & SD_RESOLVED_DNS ? " DNS" :"", flags & SD_RESOLVED_LLMNR_IPV4 ? " LLMNR/IPv4" : "", flags & SD_RESOLVED_LLMNR_IPV6 ? " LLMNR/IPv6" : "", flags & SD_RESOLVED_MDNS_IPV4 ? "mDNS/IPv4" : "", flags & SD_RESOLVED_MDNS_IPV6 ? "mDNS/IPv6" : ""); assert_se(format_timespan(rtt_str, sizeof(rtt_str), rtt, 100)); printf(" in %s", rtt_str); fputc('.', stdout); fputc('/n', stdout); printf("-- Data is authenticated: %s/n", yes_no(flags & SD_RESOLVED_AUTHENTICATED));}
开发者ID:maurizio-lombardi,项目名称:systemd,代码行数:28,
示例9: mainint main(){ char question[80]; char suspect[20]; node *start_node = create("suspect have bear?"); start_node->no = create("loletta.barnsworse"); start_node->yes = create("benny.the.spoon"); node *current; do{ current = start_node; while(1){ if(yes_no(current->question)) { if(current->yes){ current = current->yes; }else{ printf("found!/n"); break; } }else if(current->no){ current = current->no; }else{ /*make yes->node name by suspect*/ printf("who is criminal?"); fgets(suspect,20,stdin); node *yes_node = create(suspect); current->yes = yes_node; /*cpoy no_node this question*/ node *no_node = create(current->question); current->no = no_node; /*change this question new question*/ printf("This is true in %s, that question does not apply to the %s?/n" ,suspect,current->question); fgets(question,80,stdin); current->question = strdup(question); break; } } }while(yes_no("one more?")); release(start_node); return 0;}
开发者ID:tmak1000,项目名称:HeadfirstC_mylesson,代码行数:47,
示例10: mainint main(){ char question[80]; char suspect[20]; node *start_node = create("容疑者はひげを生やしているか"); start_node->no = create("ロレッタ·バ C++ yesno函数代码示例 C++ yes函数代码示例
|