int main(){ String s; char* str; init_string( &s ); copy_str( s, "Hello world..." ); print_string( s ); putchar( '\n' ); concat_str( s, " my name is Blur." ); print_string( s ); putchar( '\n' ); copy_str( s, "Hi" ); print_string( s ); putchar( '\n' ); printf( "Is it equal to hi? %d\n", compare_str( s, "hi" ) ); printf( "Is it equal to Hi? %d\n", compare_str( s, "Hi" ) ); printf( "Is it equal to hello? %d\n", compare_str( s, "hello" ) ); printf( "Is it equal to Hello? %d\n", compare_str( s, "Hello" ) ); str = to_c_str( s ); printf( "%s\n", str ); free( str ); clear_string( &s ); return 0; }
std::string libclang_vim::stringize_included_file(CXCursor const& cursor) { CXFile included_file = clang_getIncludedFile(cursor); if (included_file == nullptr) { return ""; } cxstring_ptr included_file_name = clang_getFileName(included_file); return std::string("'included_file':'") + to_c_str(included_file_name) + "',"; }
int main() { typedef quan::atomicstring<char> node; typedef quan::digraph<node > graph; graph g; g.insert("S","a"); g.insert("S","x"); g.insert("x","b"); g.insert("b","S"); show_nodes(g,std::cout); #if(1) bool f = create_dot_file("dot.txt",g, "test1"); if (f){ int res = system("dot -Tpng -o graph.png dot.txt"); if ( res == 0){ std::cout << "graph written successfully\n"; }else{ std::cout << "graph writing failed with " << res << "\n"; } } #endif graph::node_set_type roots = get_root_nodes(g); int num_roots = roots.size(); if ( num_roots ==1){ std::cout << "root is "<< *roots.begin() << "\n"; }else{ if ( num_roots == 0){ std::cout << "no root node found\n"; } else { std::string str = " multiple roots - {"; for ( auto i = roots.begin(), begin = i,end = roots.end(); i != end; ++i){ if ( i != begin){ str += ", "; } str += i->to_c_str(); } str += "}"; std::cout << str <<'\n'; } } if ( has_cycles(g)){ auto nodes = g.get_node_set(); for ( auto i = nodes.begin(),ei = nodes.end(); i!= ei; ++i){ quan::cycle_viewer<node> g1(g,*i); if( ! g1.g_out.get_node_set().empty()){ std::cout << "Have cycles\n "; quan::create_dot_file("cycles.txt" ,g1.g_out, i->to_c_str()); system("dot -Tpng -o cycles.png cycles.txt"); break; } } }else { std::cout << "no cycles\n"; // make empty dot file graph dummy; quan::create_dot_file("cycles.txt" ,dummy, "dummy"); system("dot -Tpng -o cycles.png cycles.txt"); } }
inline std::ostream& operator<<(std::ostream &out, API_shorten_long_name e) { return out << to_c_str(e); }
inline std::ostream& operator<<(std::ostream &out, API_second e) { return out << to_c_str(e); }
inline std::ostream& operator<<(std::ostream &out, API_with_assignments e) { return out << to_c_str(e); }
friend inline std::ostream& operator<<(std::ostream &out, some_other_class::SCOPED_first e) { return out << to_c_str(e); }
friend inline std::ostream& operator<<(std::ostream &out, some_other_class::SCOPED_shorten_long_name e) { return out << to_c_str(e); }
friend inline std::ostream& operator<<(std::ostream &out, some_other_class::SCOPED_with_assignments e) { return out << to_c_str(e); }
static i32 parse_adapt_result (struct app_options *opt, list<CfgEntry> *cfg, char *buf, ssize_t buf_len, vector<string> *lines) { char *end = buf, *start = buf; ssize_t size; i32 lnr = -1; u32 i, num_obj = 0; string *obj_name = NULL; u32 malloc_size = 0; ptr_t code_addr = 0; list<CfgEntry>::iterator it; DynMemEntry *tmp = NULL; bool found; end = strchr(start, ';'); if (end == NULL) goto parse_err; if (sscanf(start, "%u", &num_obj) != 1) goto parse_err; size = end - start; start += size + 1; for (i = 1; i <= num_obj; i++) { // get object name or reserved cfg entry for (;;) { if (parse_adp_string(&start, &obj_name)) goto parse_err; if (*obj_name == "proc_name") { lnr = 0; } else if (*obj_name == "game_binpath") { lnr = opt->binpath_line; if (lnr <= 0) { if (parse_adp_string(&start, &obj_name)) goto parse_err; lnr = -1; continue; } } if (lnr >= 0) { if (parse_adp_string(&start, &obj_name)) goto parse_err; if (lnr == 0) { if (strcmp(opt->game_call, opt->proc_name) == 0) opt->game_call = to_c_str(obj_name); opt->proc_name = to_c_str(obj_name); } else if ((u32) lnr == opt->binpath_line) { *obj_name = "game_binpath " + *obj_name; opt->game_binpath = to_c_str(obj_name); if (strcmp(basename(opt->game_binpath), opt->proc_name) != 0) goto parse_err; } lines->at(lnr) = *obj_name; lnr = -1; continue; } break; } if (sscanf(start, "%x", &malloc_size) != 1) goto parse_err; end = strchr(start, ';'); if (end == NULL) goto parse_err; size = end - start; start += size + 1; if (sscanf(start, SCN_PTR, &code_addr) != 1) goto parse_err; // find object and set adp_size and adp_addr found = false; list_for_each (cfg, it) { tmp = it->dynmem; if (tmp && !tmp->adp_addr && tmp->name == *obj_name) { tmp->adp_size = malloc_size; tmp->adp_addr = code_addr; cout << "Class " << tmp->name << ", old_size: " << tmp->mem_size << ", new_size: " << tmp->adp_size << endl; cout << "Class " << tmp->name << ", old_code: 0x" << hex << tmp->code_addr << ", new_code: 0x" << tmp->adp_addr << dec << endl; found = true; break; } } if (!found) goto parse_err; if (i == num_obj) break; end = strchr(start, ';'); if (end == NULL) goto parse_err; size = end - start; start += size + 1; }