Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

double_star_io.C

Go to the documentation of this file.
00001 //
00002 // base_element_io.C
00003 //
00004 
00005 #include "double_star.h"
00006 #include "util_io.h"
00007 
00008 //#include "hdyn.h"
00009 
00010 istream & double_star::scan_star_story(istream& s) {
00011 
00012     char input_line[MAX_INPUT_LINE_LENGTH];
00013 
00014     while(get_line(s,input_line), strcmp(END_STAR, input_line)){
00015         char keyword[MAX_INPUT_LINE_LENGTH];
00016         getequals(input_line, keyword); // demand "="
00017     }
00018 
00019     return s;
00020 }
00021 
00022 #if 0
00023         real number;
00024         if(0){   // trick to keep the if() statement, for the else below
00025         }else if(!strcmp("Type",keyword)){
00026             char type_string[MAX_INPUT_LINE_LENGTH];
00027             sscanf(input_line,"%*s%*s%s",type_string);
00028             set_bin_type(extract_binary_type_string(type_string));
00029         }else if(!strcmp("semi",keyword)){
00030             sscanf(input_line,"%*s%*s%lf",&number);
00031             set_semi(semi);
00032         }else if(!strcmp("ecc",keyword)){
00033             sscanf(input_line,"%*s%*s%lf",&number);
00034             set_eccentricity(number);
00035         }else{
00036             add_story_line(star_story, input_line);
00037         }
00038     }
00039 #endif
00040 
00041 ostream& double_star::print_star_story(ostream& s,
00042                                        int short_output) { // default = 0
00043 
00044     put_story_header(s, STAR_ID);
00045 //    put_story_header(s, "Binary");
00046 //cerr<<"addresses: "<<this<<" "<<primary<<" "<<secondary<<endl;
00047 //cerr<<get_primary()<<" "<<get_secondary()<<endl;
00048 //cerr<<primary->get_root()<<" "<<secondary->get_root()<<endl;
00049 //cerr<<get_primary()->get_root()<<" "<<get_secondary()->get_root()<<endl;
00050 //cerr<<get_secondary()->get_companion()<<" "<<get_primary()->get_companion()<<endl;
00051 
00052 
00053 //    put_string(s, "  Type  =  ", type_string(get_bin_type()));
00054 //    put_real_number(s, "  semi  =  ", get_semi());
00055 //    put_real_number(s, "  ecc   =  ", get_eccentricity());
00056     
00057     if (star_story)
00058         put_story_contents(s, *star_story);
00059 
00060     put_story_footer(s, STAR_ID);
00061 
00062     return s;
00063 }
00064 
00065 void extract_line_text(binary_type& type, real& semi, real& ecc, story& s) {
00066 
00067         char keyword[MAX_INPUT_LINE_LENGTH];
00068         char should_be_equal_sign[MAX_INPUT_LINE_LENGTH];
00069         char line [MAX_INPUT_LINE_LENGTH];
00070         char type_string[MAX_INPUT_LINE_LENGTH];
00071 
00072         strcpy(line, s.get_text());
00073         sscanf(line,"%s%s",keyword,should_be_equal_sign);
00074         if(strcmp("=",should_be_equal_sign)){
00075             cerr << "Expected '=', but got '"<< should_be_equal_sign <<"'\n";
00076             exit(1);
00077         }
00078 
00079         real number;
00080         if(0){   // trick to keep the if() statement, for the else below
00081        }else if(!strcmp("Type",keyword)){
00082             char str_tpe[MAX_INPUT_LINE_LENGTH];
00083             sscanf(line,"%*s%*s%s",type_string);
00084             type = extract_binary_type_string(type_string);
00085         }else if(!strcmp("semi",keyword)){
00086             sscanf(line,"%*s%*s%lf",&semi);
00087         }else if(!strcmp("ecc",keyword)){
00088             sscanf(line,"%*s%*s%lf",&ecc);
00089         }
00090     }
00091 
00092 void extract_story_chapter(binary_type& type, real& sma, real& ecc, story& s) {
00093 
00094     if (!s.get_chapter_flag()) {
00095         cerr << "extract_story_chapter: not a story\n";
00096         exit(1);
00097     }
00098     for (story * d = s.get_first_daughter_node(); d != NULL;
00099                  d = d->get_next_story_node()) {
00100         if (d->get_chapter_flag())
00101             extract_story_chapter(type, sma, ecc, *d);
00102         else
00103             extract_line_text(type, sma, ecc, *d);
00104     }
00105  }
00106 
00107 

Generated at Sun Feb 24 09:56:58 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001