MTK++ Latest version: 0.2.0

printHeader.h
Go to the documentation of this file.
00001 
00020 #ifndef PRINT_HEADER_H
00021 #define PRINT_HEADER_H
00022 
00023 #include "copyright.h"
00024 #include <vector>
00025 namespace MTKpp
00026 {
00027 
00031 void printHeader(std::ostream& os, std::string prog_name, std::vector<std::string> authors) {
00032     copyright(os);
00033     os << "|                                                                              |" << std::endl;
00034     std::string outline = "                                                                              ";
00035 
00036     if (prog_name.size() > outline.size()+2) {
00037       os << " Error in printHeader: Program name is too long ... exiting " << std::endl;
00038       exit(0);
00039     }
00040 
00041     for (unsigned int i = 0; i < authors.size(); i++) {
00042       if (authors[i].size() > outline.size()+2) {
00043         os << " Error in printHeader: Author name is too long ... exiting " << std::endl;
00044         exit(0);
00045       }
00046     }
00047 
00048     unsigned int s = outline.size() - prog_name.size();
00049     int odd = 0;
00050     if (s % 2) {
00051       odd = 1;
00052       s--;
00053     }
00054     unsigned int w = s/2;
00055     std::string sub1 = outline.substr(0,w);
00056     std::string sub2 = outline.substr(0,w+odd);
00057     std::string sub = "|" + sub1 + prog_name + sub2 + "|";
00058     if (sub.size() > 80) {
00059       os << " Error in printHeader ... exiting " << std::endl;
00060       exit(0);
00061     }
00062     os << sub << std::endl;
00063 
00064     for (unsigned int i = 0; i < authors.size(); i++) {
00065       s = 0;
00066       w = 0;
00067       odd = 0;
00068       sub1 = "";
00069       sub2 = "";
00070       sub = "";
00071       s = outline.size() - authors[i].size();
00072       if (s % 2) {
00073         odd = 1;
00074         s--;
00075       }
00076       w = s/2;
00077       sub1 = outline.substr(0,w);
00078       sub2 = outline.substr(0,w+odd);
00079       sub = "|" + sub1 + authors[i] + sub2 + "|";
00080       if (sub.size() > 80) {
00081         os << " Error in printHeader ... exiting " << std::endl;
00082         exit(0);
00083       }
00084       os << sub << std::endl;
00085     }
00086     os << "|                            Copyright (c) 2005-2011                           |" << std::endl;
00087     os << "|                              All Rights Reserved.                            |" << std::endl;
00088     os << "|                                                                              |" << std::endl;
00089     os << "+------------------------------------------------------------------------------+" << std::endl;
00090 };
00091 
00092 } // MTKpp namespace
00093 
00094 #endif // PRINT_HEADER_H

Generated on Fri Dec 23 2011 09:28:51 for MTK++ by Doxygen 1.7.5.1