ATLAS Offline Software
Loading...
Searching...
No Matches
CoWLibrary.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <memory>
7
8namespace CoWTools{
9 void CoWLibrary::parseRecord(std::istream &in){
10 //std::cout<<"Got record line "<<line<<std::endl;
11 auto mr=std::make_shared<CoWRecord>(m_summary);
12 mr->parseRecord(in);
13 m_ms+=mr->m_ms;
14 }
15
16 // std::ostream & operator<<(std::ostream &out, const CoWLibrary &l){
17 // out<<"library = "<<l.m_libName<<std::endl;
18 // out<<l.m_ms<<std::endl;
19 // out<<"-------------------------------------------------------"<<std::endl;
20 // return out;
21 // }
22
23 std::shared_ptr<CoWLibrary> CoWLibrary::fromRecord(std::istream &in, bool summary){
24 std::string libLine;
25 if(std::getline(in,libLine).eof()){
26 //std::cerr<<libLine<<std::endl;
27 std::cerr<<"Returning 0"<<std::endl;
28 return 0;
29 }
30 int len=0;
31 int nfields=0;
32 std::string libName="Anonymous";
33 char buff[2048];
34 //std::cerr<<"LibLine="<<libLine<<std::endl;
35 sscanf(libLine.c_str(),"%*s %*s %*s %*s %*s%n",
36 &len
37 );
38 if(libLine.size()>(uint)(len+1)){
39 nfields=sscanf(libLine.substr(len+1).c_str(),"%2047s",buff);
40 if(nfields>0){
41 libName=buff;
42 //std::cout<<"Found lib "<<libName<<std::endl;
43 }
44 }else{
45 libName="Anonymous";
46 }
47 auto lib=std::make_shared<CoWTools::CoWLibrary>(libName,summary);
48 CoWRecordStats r(summary);
49 r.parseRecord(in);
50 lib->m_ms+=r;
51 return lib;
52 }
53
54 std::ostream & operator<<(std::ostream &os, const CoWTools::CoWLibrary &l){
55 // char buff[1024];
56 // snprintf(buff,1024,"Library= %s"
57 // );
58 // out<<buff;
59
60 os<<" Lib= "<<l.m_libName<<" "<<l.m_ms;
61 return os;
62 }
63}
unsigned int uint
CoWRecordStats m_ms
Definition CoWLibrary.h:23
static std::shared_ptr< CoWLibrary > fromRecord(std::istream &in, bool summary)
void parseRecord(std::istream &in)
Definition CoWLibrary.cxx:9
int r
Definition globals.cxx:22
std::ostream & operator<<(std::ostream &os, const CoWTools::CoWLibrary &l)