Upstream | cc2ee17 | 1970-01-12 13:46:40 +0000 | [diff] [blame^] | 1 | /** |
| 2 | * @file parse_filename.h |
| 3 | * Split a sample filename into its constituent parts |
| 4 | * |
| 5 | * @remark Copyright 2003 OProfile authors |
| 6 | * @remark Read the file COPYING |
| 7 | * |
| 8 | * @author Philippe Elie |
| 9 | */ |
| 10 | |
| 11 | #ifndef PARSE_FILENAME_H |
| 12 | #define PARSE_FILENAME_H |
| 13 | |
| 14 | #include <string> |
| 15 | |
| 16 | /** |
| 17 | * a convenience class to store result of parse_filename() |
| 18 | */ |
| 19 | struct parsed_filename |
| 20 | { |
| 21 | std::string image; |
| 22 | std::string lib_image; |
| 23 | /// destination image for call graph file, empty if this sample |
| 24 | /// file is not a callgraph file. |
| 25 | std::string cg_image; |
| 26 | std::string event; |
| 27 | std::string count; |
| 28 | std::string unitmask; |
| 29 | std::string tgid; |
| 30 | std::string tid; |
| 31 | std::string cpu; |
| 32 | |
| 33 | /// return true if the profile specification are identical. |
| 34 | bool profile_spec_equal(parsed_filename const & parsed); |
| 35 | |
| 36 | /** |
| 37 | * the original sample filename from which the |
| 38 | * above components are built |
| 39 | */ |
| 40 | std::string filename; |
| 41 | }; |
| 42 | |
| 43 | |
| 44 | /// debugging helper |
| 45 | std::ostream & operator<<(std::ostream &, parsed_filename const &); |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * parse a sample filename |
| 50 | * @param filename in: a sample filename |
| 51 | * |
| 52 | * filename is split into constituent parts, the lib_image is optional |
| 53 | * and can be empty on successfull call. All other error are fatal. |
| 54 | * Filenames are encoded as according to PP:3.19 to PP:3.25 |
| 55 | * |
| 56 | * all errors throw an std::invalid_argument exception |
| 57 | */ |
| 58 | parsed_filename parse_filename(std::string const & filename); |
| 59 | |
| 60 | #endif /* !PARSE_FILENAME_H */ |