本文整理汇总了C++中BasicVec::size方法的典型用法代码示例。如果您正苦于以下问题:C++ BasicVec::size方法的具体用法?C++ BasicVec::size怎么用?C++ BasicVec::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicVec
的用法示例。
在下文中一共展示了BasicVec::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
BasicVec<int> find_with_index(Sc2String name, BasicVec<Sc2String> list){
BasicVec<int> res; res.reserve(list.size());
for(unsigned i=0;i<list.size();i++){
if(name==list[i]){res.push_back(i);}
}
return res;
}
示例2: aaadd
void aaadd( BasicVec<String> var_templ, BasicVec<BasicVec<String,2> > rep ) {
if ( var_templ.size() ) {
BasicVec<String> t = tokenize( var_templ.back(), ' ' );
var_templ.pop_back();
for( int i = 1; i < t.size(); ++i ) {
rep.push_back( t[ 0 ], t[ i ] );
aaadd( var_templ, rep );
rep.pop_back();
}
} else
res << rep;
}
示例3: NEW
Ptr<CompilationTree> CompilationEnvironment::make_lnk_compilation_tree( const String &exe, const BasicVec<Ptr<CompilationTree> > &obj, bool lib, bool dyn ) {
Ptr<CompilationTree> &res = deepest_child()->cor_files[ exe ];
if ( not res ) {
res = NEW( CompilationTree, exe );
for( int i = 0; i < obj.size(); ++i )
res->add_child( obj[ i ] );
BasicVec<String> obj_str;
for( int i = 0; i < obj.size(); ++i )
obj_str << obj[ i ]->dst;
res->cmd = lnk_cmd( exe, obj_str, lib, dyn );
}
return res;
}
示例4: write_groups_attributs_datasets
void write_groups_attributs_datasets(std::ofstream &f,Sc2String input_hdf5, Sc2String name_elements, Sc2String name_fields, BasicVec<Sc2String> attributs, int time) {
Hdf hdf(input_hdf5);
BasicVec<Sc2String> lists;
lists=hdf.list_dir(name_elements);
#if DIM==2
BasicVec<Sc2String> tensor_comp("xx","yy","xy");
BasicVec<Sc2String> vector_comp("x","y");
#else
BasicVec<Sc2String> tensor_comp("xx","yy","zz","xy","xz","yz");
BasicVec<Sc2String> vector_comp("x","y","z");
#endif
BasicVec<Sc2String> list_fields_tensor_time("sigma","epsilon","sigma_skin", "epsilon_skin");
BasicVec<Sc2String> list_fields_vector_time("F", "W", "Fchap", "Wchap");
BasicVec<Sc2String> list_fields_scalar_time("sigma_von_mises","sigma_von_mises_skin");
BasicVec<Sc2String> list_fields_global("num_proc","material","num_group", "number", "nature");
for (unsigned i=0; i< lists.size(); i++) {
Sc2String name_list;
name_list << name_elements <<"/"<< lists[i];
Sc2String name_list_c0=name_list+"/mesh_c0";
int nb_elems;
hdf.read_size(name_list_c0,nb_elems);
//Ecriture des attributs en fonction de leur nom
for (unsigned attr=0;attr<attributs.size();attr++) {
if (find(attributs[attr], list_fields_tensor_time) ) {
for(unsigned d=0;d<tensor_comp.size();d++){
Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i]<<"/"<<tensor_comp[d];
f <<" <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field <<" </DataItem>" << endl;
}
}
else if (find(attributs[attr], list_fields_vector_time) ) {
for(unsigned d=0;d<DIM;d++){
Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i]<<"/"<<vector_comp[d];
f <<" <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field <<" </DataItem>" << endl;
}
}
else if (find(attributs[attr], list_fields_scalar_time) ) {
Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i];
f <<" <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field << " </DataItem>" << endl;
}
else if (find(attributs[attr], list_fields_global)) {
Sc2String name_field; name_field << name_elements << "/"<<lists[i]<<"/"<<attributs[attr];
f <<" <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field << " </DataItem>" << endl;
}
}
}
}
示例5: write_groups_datasets_2
void write_groups_datasets_2(std::ofstream &f,Sc2String input_hdf5, Sc2String name_group_elements){
//lecture des noms des listes d'elements
// int nb_elems_tot=0;
// int nb_nodes_elem_glob=4;
Hdf hdf(input_hdf5);
BasicVec<Sc2String> lists;
lists=hdf.list_dir(name_group_elements);
for (unsigned i=0; i< lists.size(); i++) {
Sc2String name_list; name_list << name_group_elements << "/"<<lists[i];
Sc2String name_list_c0=name_list+"/mesh_c0";
int nb_elems;
hdf.read_size(name_list_c0,nb_elems); //lecture du nombre d'elements dans la liste
//lecture du type d'elements
int nb_nodes_elem;
Metil::String base;
hdf.read_tag(name_list,"base",base,1);
if (base=="Bar") nb_nodes_elem=2; // Bar
else if (base=="Bar_3") nb_nodes_elem=2; // Bar_3, on ne prend que les 2 premiers noeuds
else if (base=="Triangle") nb_nodes_elem=3; // Triangle
else if (base=="Triangle_6") nb_nodes_elem=3; // Triangle_6, on ne prend que les 3 premiers noeuds
else if (base=="Quadrilateral") nb_nodes_elem=4; // quad
else if (base=="Tetrahedron") nb_nodes_elem=4; // Tetra
else if (base=="Tetrahedron_10") nb_nodes_elem=10; // Tetra_10, on ne prend que les 4 premiers noeuds
else if (base=="Hexahedron") nb_nodes_elem=8; // quad
else { std::cerr << "Type d'element non implementé - voir le tag \"base\" dans le fichier hdf5" ; assert(0);}
for (unsigned j=0;j<nb_nodes_elem ; j++) {
Sc2String data_item;
data_item << name_list << "/mesh_c" <<j ;
f <<" <DataItem Name=\"" << data_item << "\" Format=\"HDF\" NumberType=\"Int\" Dimensions=\" "<< nb_elems << " 1\">" << input_hdf5 <<":"<< data_item <<" </DataItem>" << endl;
}
}
}
示例6: find
bool find(Sc2String name, BasicVec<Sc2String> list){
bool res=0;
for(unsigned i=0;i<list.size();i++){
if(name==list[i]){res=1; break;}
}
return res;
}
示例7: make_lnk_compilation_tree
Ptr<CompilationTree> CompilationEnvironment::make_compilation_tree( const String &app, const String &cpp, bool lib, bool dyn, bool make_libs ) {
BasicVec<Ptr<CompilationTree> > obj;
parse_cpp( obj, cpp, dyn );
// sort by directory
if ( make_libs ) {
String base_dir = directory_of( cpp );
std::map<String,Lib> map_lib;
for( int i = 0; i < obj.size(); ++i ) {
String dir = directory_of( obj[ i ]->children[ 0 ]->dst );
if ( dir == base_dir )
continue;
map_lib[ dir ].obj << obj[ i ];
obj.remove( i-- );
}
// make dylibs
int cpt = 0;
for( std::map<String,Lib>::iterator iter = map_lib.begin(); iter != map_lib.end(); ++iter ) {
String name; name << app << "_" << cpt++;
obj << make_lnk_compilation_tree( lib_for( name, dyn ), iter->second.obj, true, dyn );
}
}
//
return make_lnk_compilation_tree( app, obj, lib, dyn );
}
示例8: find_src
String CompilationEnvironment::find_src( const String &filename, const String ¤t_dir, const BasicVec<String> &add_paths, bool allow_cur_dir ) const {
// absolute path ?
if ( filename[ 0 ] == '/' or filename[ 0 ] == '\\' )
return ( file_exists( filename ) ? filename : String() );
// try with current_dir
String trial = current_dir + filename;
if ( allow_cur_dir and file_exists( trial ) )
return trial;
// try with add_paths
for( int i = 0; i < add_paths.size(); ++i ) {
trial = add_paths[ i ] + filename;
if ( file_exists( trial ) )
return trial;
}
// try with inc_paths
for( int i = 0; i < inc_paths.size(); ++i ) {
trial = inc_paths[ i ] + filename;
if ( file_exists( trial ) )
return trial;
}
// try with inc_paths of child
if ( child )
return child->find_src( filename, current_dir );
// not found :(
return String();
}
示例9: write_nodes_attributs_datasets
void write_nodes_attributs_datasets(std::ofstream &f,Sc2String input_hdf5,int nb_nodes,Sc2String name_fields, BasicVec<Sc2String> attributs, int time, int i_proc) {
//ecriture des attributs aux noeuds
BasicVec<Sc2String> dimensions("x","y","z");
for (unsigned attr=0;attr<attributs.size();attr++) {
if (attributs[attr]=="displacements" or attributs[attr]=="displacements_skin")
for(unsigned d=0;d<DIM;d++){
Sc2String name_field; name_field << name_fields <<"/pt_"<<time<<"/"<<attributs[attr]<<"/"<<dimensions[d];
f <<" <DataItem Name=\""<<name_field<<"_proc_"<<i_proc<<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_nodes << " 1 \">" << input_hdf5 <<":"<< name_field<< " </DataItem>" << endl;
}
}
}
示例10: load_env_var
void CompilationEnvironment::load_env_var() {
if ( String str = get_env( "METIL_INC_PATHS" ) ) {
BasicVec<String> lst = tokenize( str, ';' );
for( int i = 0; i < lst.size(); ++i )
add_inc_path( lst[ i ] );
}
if ( String str = get_env( "METIL_LIB_PATHS" ) ) {
BasicVec<String> lst = tokenize( str, ';' );
for( int i = 0; i < lst.size(); ++i )
add_lib_path( lst[ i ] );
}
if ( String str = get_env( "METIL_LIB_NAMES" ) ) {
BasicVec<String> lst = tokenize( str, ';' );
for( int i = 0; i < lst.size(); ++i )
add_lib_name( lst[ i ] );
}
if ( String str = get_env( "METIL_PARSED" ) ) {
BasicVec<String> lst = tokenize( str, ';' );
for( int i = 0; i < lst.size(); ++i )
parsed << lst[ i ];
}
if ( String str = get_env( "METIL_COMP_DIR" ) ) _comp_dir = str;
if ( String str = get_env( "METIL_CXX" ) ) CXX = str;
if ( String str = get_env( "METIL_LD" ) ) LD = str;
if ( String str = get_env( "METIL_NVCC" ) ) NVCC = str;
if ( String str = get_env( "METIL_CPPFLAGS" ) ) CPPFLAGS = str;
if ( String str = get_env( "METIL_LDFLAGS" ) ) LDFLAGS = str;
if ( String str = get_env( "METIL_DEV_EMU" ) ) device_emulation = Val( str );
if ( String str = get_env( "METIL_REG_CNT" ) ) maxrregcount = Val( str );
if ( String str = get_env( "METIL_DBG_LEVEL" ) ) dbg_level = Val( str );
if ( String str = get_env( "METIL_OPT_LEVEL" ) ) opt_level = Val( str );
if ( String str = get_env( "METIL_CXX_NAME" ) ) cxx_name = str;
}
示例11: lnk_cmd
String CompilationEnvironment::lnk_cmd( const String &exe, const BasicVec<String> &obj, bool lib, bool dyn ) const {
String cmd = get_LD();
// basic flags
if ( lib )
cmd << ( dyn ? " -shared" : " -static" );
// input / output
cmd << " -o '" << exe << "'";
for( int i = 0; i < obj.size(); ++i )
cmd << " '" << obj[ i ] << "'";
// -L... -l...
extra_lnk_cmd( cmd, lib, dyn );
// dylibs
for (int i = 0; i < dylibs.size(); ++i)
cmd << " " << dylibs[ i ];
return cmd;
}
示例12: write_grids_2
void write_grids_2(std::ofstream &f,Sc2String name_hdf5, Sc2String name_elements, Sc2String name_nodes, Sc2String name_fields, Sc2String generic_grid_name, BasicVec<Sc2String> attributs, int time, int i_proc) {
Sc2String input_hdf5; input_hdf5 << name_hdf5 <<"_"<<i_proc<<".h5";
Hdf hdf(input_hdf5);
int nb_nodes;
Sc2String data_node_x = (name_nodes + "/x");
hdf.read_size(data_node_x,nb_nodes);
BasicVec<Sc2String> lists;
lists=hdf.list_dir(name_elements);
BasicVec<Sc2String> list_fields_tensor_time("sigma","epsilon","sigma_skin", "epsilon_skin");
BasicVec<Sc2String> list_fields_vector_time("F", "W", "Fchap", "Wchap");
BasicVec<Sc2String> list_fields_scalar_time("sigma_von_mises","sigma_von_mises_skin");
BasicVec<Sc2String> list_fields_global("num_proc","material","num_group", "number", "nature");
for (unsigned i=0; i< lists.size(); i++) {
Sc2String name_list; name_list << name_elements << "/" <<lists[i];
Sc2String num_list = Metil::String(lists[i]).end_from(5);
Sc2String name_list_c0=name_list +"/mesh_c0";
int nb_elems;
hdf.read_size(name_list_c0,nb_elems);
int nb_nodes_elem;
Sc2String JOIN, name_element_xdmf;
Metil::String base;
hdf.read_tag(name_list,"base",base);
if (base=="Bar" or base=="Bar_3") {
nb_nodes_elem=2;
JOIN="JOIN($0 , $1 )";
name_element_xdmf="Bar";
}
else if (base=="Triangle" or base=="Triangle_6") {
nb_nodes_elem=3;
JOIN="JOIN($0 , $1 , $2 )";
name_element_xdmf="Triangle";
}
else if (base=="Quadrilateral" ) {
nb_nodes_elem=4;
JOIN="JOIN($0 , $1 , $2, $3 )";
name_element_xdmf="Quadrilateral";
}
else if (base=="Tetrahedron" or base=="Tetrahedron_10") {
nb_nodes_elem=4;
JOIN="JOIN($0 , $1 , $2 , $3)";
name_element_xdmf="Tetrahedron";
}
else if (base=="Hexahedron" ) {
nb_nodes_elem=8;
JOIN="JOIN($0 , $1 , $2 , $3, $4 , $5 , $6 , $7 )";
name_element_xdmf="Hexahedron";
}
else {
std::cerr << "Type d'element non implementé - creation grids xdmf" ;
assert(0);
}
f<<" <Grid Name=\""<< generic_grid_name << "_" << num_list <<"\">" << endl;
//reference a la topology (connectivites)
f<<" <Topology Type=\""<<name_element_xdmf<<"\" NumberOfElements=\" "<< nb_elems << " \" >" << endl;
f<<" <DataItem Dimensions=\" "<< nb_elems << " " << nb_nodes_elem <<" \" ItemType=\"Function\" Function=\""<<JOIN<<"\"> " <<endl;
for (unsigned j=0;j<nb_nodes_elem ; j++) {
Sc2String data_item;
data_item << name_list << "/mesh_c" <<j ;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<< data_item <<"\"] </DataItem> " << endl;
}
f<<" </DataItem> " <<endl;
f<<" </Topology>" <<endl;
//reference aux noeuds
#if DIM==2
f<<" <Geometry Type=\"XY_Z\">"<<endl;
Sc2String JOIN_vector="JOIN($0 , $1 )";
#else
f<<" <Geometry Type=\"X_Y_Z\">"<<endl;
Sc2String JOIN_vector="JOIN($0 , $1 , $2)";
#endif
BasicVec<Sc2String> dimensions("x","y","z");
for(unsigned d=0;d<DIM;d++){
Sc2String name_coor_node; name_coor_node << name_nodes << "/"<< dimensions[d]<<"_proc_"<<i_proc;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<<name_coor_node<<"\"] </DataItem> " << endl;
}
f<<" </Geometry>" <<endl;
//reference aux attributs
for (unsigned attr=0;attr<attributs.size();attr++) {
if (attributs[attr]=="displacements" or attributs[attr]=="displacements_skin") {
f<<" <Attribute Name=\""<<attributs[attr]<<"\" AttributeType=\"Vector\" Center=\"Node\">" << endl;
f<<" <DataItem Dimensions=\" "<< nb_nodes << " "<< DIM <<" \" ItemType=\"Function\" Function=\""<<JOIN_vector<<"\"> " <<endl;
for(unsigned d=0;d<DIM;d++){
Sc2String name_field; name_field << name_fields <<"/pt_"<<time<<"/"<<attributs[attr]<<"/"<<dimensions[d]<<"_proc_"<<i_proc;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<<name_field<<"\"] </DataItem> " << endl;
}
f<<" </DataItem> " <<endl;
f<<" </Attribute>"<<endl;
}
else if (find(attributs[attr], list_fields_vector_time)) {
f<<" <Attribute Name=\""<<attributs[attr]<<"\" AttributeType=\"Vector\" Center=\"Cell\">" << endl;
f<<" <DataItem Dimensions=\" "<< nb_elems << " "<< DIM <<" \" ItemType=\"Function\" Function=\""<<JOIN_vector<<"\"> " <<endl;
for(unsigned d=0;d<DIM;d++){
Sc2String name_field; name_field << name_fields <<"/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i]<<"/"<<dimensions[d];
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<<name_field<<"\"] </DataItem> " << endl;
//.........这里部分代码省略.........
示例13: write_grids
void write_grids(std::ofstream &f,Sc2String input_hdf5, Sc2String name_group_elements, Sc2String name_nodes, BasicVec<int> list, int nb_nodes, Sc2String generic_grid_name, Sc2String name_fields, BasicVec<Sc2String> attributs, int nt, TYPE val_time, int type_element, int i_proc) {
Hdf hdf(input_hdf5);
for (unsigned i=0; i< list.size(); i++) {
Sc2String name_list;
name_list << name_group_elements << "/list_" << list[i];
Sc2String name_list_c0=name_list+"/mesh_c0";
int nb_elems;
hdf.read_size(name_list_c0,nb_elems);
int nb_nodes_elem;
Sc2String JOIN, name_element_xdmf;
if(type_element==0){
int pattern_id;
hdf.read_tag(name_list,"pattern_id",pattern_id);
if (pattern_id==0 or pattern_id==1) {
nb_nodes_elem=3;
JOIN="JOIN($0 , $1 , $2 )";
name_element_xdmf="Triangle";
}
else if (pattern_id==2 or pattern_id==3) {
nb_nodes_elem=4;
JOIN="JOIN($0 , $1 , $2 , $3)";
name_element_xdmf="Tetrahedron";
}
else {
std::cerr << "Type d'element enfant non implementé" ;
assert(0);
}
}else if(type_element==1){
int interface_id;
hdf.read_tag(name_list,"interface_id",interface_id);
if (interface_id==0 or interface_id==1) {
nb_nodes_elem=2;
JOIN="JOIN($0 , $1 )";
name_element_xdmf="Bar";
}
else if (interface_id==2 or interface_id==3) {
nb_nodes_elem=3;
JOIN="JOIN($0 , $1 , $2 )";
name_element_xdmf="Triangle";
}
else {
std::cerr << "Type d'element enfant non implementé" ;
assert(0);
}
}
f<<" <Grid Name=\""<< generic_grid_name << "_" << i <<"\">" << endl;
f<<" <Time Value=\""<<val_time<<"\" />" << endl;
f<<" <Topology Type=\""<<name_element_xdmf<<"\" NumberOfElements=\" "<< nb_elems << " \" >" << endl;
f<<" <DataItem Dimensions=\" "<< nb_elems << " " << nb_nodes_elem <<" \" ItemType=\"Function\" Function=\""<<JOIN<<"\"> " <<endl;
for (unsigned j=0;j<nb_nodes_elem ; j++) {
Sc2String data_item;
data_item << name_list << "/mesh_c" <<j ;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<< data_item <<"\"] </DataItem> " << endl;
}
f<<" </DataItem> " <<endl;
f<<" </Topology>" <<endl;
#if DIM==2
f<<" <Geometry Type=\"XY_Z\">"<<endl;
#else
f<<" <Geometry Type=\"X_Y_Z\">"<<endl;
#endif
BasicVec<Sc2String> dimensions("x","y","z");
for(unsigned d=0;d<DIM;d++){
Sc2String name_coor_node; name_coor_node << name_nodes << "/"<< dimensions[d]<<"_proc_"<<i_proc;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<<name_coor_node<<"\"] </DataItem> " << endl;
}
f<<" </Geometry>" <<endl;
for (unsigned attr=0;attr<attributs.size();attr++) {
if (attributs[attr]=="displacements") {
f<<" <Attribute Name=\"displacements\" AttributeType=\"Vector\" Center=\"Node\">" << endl;
f<<" <DataItem Dimensions=\" "<< nb_nodes << " "<< DIM <<" \" ItemType=\"Function\" Function=\""<<JOIN<<"\"> " <<endl;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\"dx_"<<nt<<"\"] </DataItem> " << endl;
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\"dy_"<<nt<<"\"] </DataItem> " << endl;
#if DIM==3
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\"dz_"<<nt<<"\"] </DataItem> " << endl;
#endif
f<<" </DataItem> " <<endl;
f<<" </Attribute>"<<endl;
}
else if(attributs[attr]=="sigma") {
#if DIM==2
int nb_comp_tensor=3;
Sc2String JOIN_tensor="JOIN($0 , $1 , $2 )";
BasicVec<Sc2String> tensor_comp_sigma=BasicVec<Sc2String>("sxx","syy","sxy");
#else
int nb_comp_tensor=6;
Sc2String JOIN_tensor="JOIN($0 , $1 , $2, $3 , $4 , $5 )";
BasicVec<Sc2String> tensor_comp_sigma=BasicVec<Sc2String>("sxx","syy","szz","sxy","sxz","syz");
#endif
f<<" <Attribute AttributeType=\"Tensor6\" Name=\"sigma\" Center=\"Cell\">" << endl;
f<<" <DataItem Dimensions=\" "<< nb_elems << " " << nb_comp_tensor << " \" ItemType=\"Function\" Function=\""<<JOIN_tensor<<"\"> " <<endl;
for(unsigned nc=0;nc<nb_comp_tensor;nc++)
f<<" <DataItem Reference=\"XML\"> /Xdmf/Domain/DataItem[@Name=\""<< name_group_elements << "_"<<tensor_comp_sigma[nc]<<"_"<<nt<<"\"] </DataItem> " << endl;
f<<" </DataItem> " <<endl;
f<<" </Attribute>"<<endl;
}
else if(attributs[attr]=="epsilon") {
//.........这里部分代码省略.........
示例14: save_dep_vec
static void save_dep_vec( String &fd, const BasicVec<String> &vec ) {
for( int i = 0; i < vec.size(); ++i )
fd << vec[ i ].size() << vec[ i ];
fd << "0\n";
}
示例15: init_using_dep
bool CompilationCppParser::init_using_dep( CompilationEnvironment &ce, const String &cpp_file, const String &dep_file ) {
SI64 date_cpp = last_modification_time_or_zero_of_file_named( cpp_file );
SI64 date_dep = last_modification_time_or_zero_of_file_named( dep_file );
if ( date_cpp > date_dep )
return false;
File fd( dep_file, "r" );
const char *c = fd.c_str();
// orig flags are conform ?
BasicVec<String> loc_inc_paths;
BasicVec<String> loc_def_procs;
load_dep_vec( c, loc_inc_paths );
load_dep_vec( c, loc_def_procs );
if ( ce_inc_paths.size() != loc_inc_paths.size() or ce_def_procs.size() != loc_def_procs.size() )
return false;
if ( any( ce_inc_paths != loc_inc_paths ) or any( ce_def_procs != loc_def_procs ) )
return false;
// include file are older than dep file ?
load_dep_vec( c, inc_files );
for( ST i = 0; i < inc_files.size(); ++i ) {
if ( last_modification_time_or_zero_of_file_named( inc_files[ i ] ) > date_dep ) {
inc_files.resize( 0 );
return false;
}
}
// -> OK
load_dep_vec( c, moc_files );
load_dep_vec( c, src_files );
load_dep_vec( c, lib_paths );
load_dep_vec( c, lib_names );
load_dep_vec( c, fra_names );
load_dep_vec( c, inc_paths );
load_dep_vec( c, cpp_flags );
load_dep_vec( c, lnk_flags );
load_dep_vec( c, gpu_flags );
load_dep_vec( c, var_templ );
load_dep_vec( c, cxx_name );
BasicVec<String> defs;
load_dep_vec( c, defs );
for( int i = 0; i < defs.size(); ++i )
defines[ defs[ i ] ];
// .h.py ?
for( int i = 0; i < inc_files.size(); ++i ) {
String inc_file = inc_files[ i ];
if ( inc_file.ends_with( ".h" ) ) {
String h_py = inc_file + ".py";
if ( file_exists( h_py ) ) {
if ( last_modification_time_or_zero_of_file_named( h_py ) >
last_modification_time_or_zero_of_file_named( inc_file ) )
make_h_py( h_py, inc_file );
}
}
}
return true;
}