Mike Dodd | 8cfa702 | 2010-11-17 11:12:26 -0800 | [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 | class extra_images; |
| 17 | |
| 18 | /** |
| 19 | * a convenience class to store result of parse_filename() |
| 20 | */ |
| 21 | struct parsed_filename |
| 22 | { |
| 23 | std::string image; |
| 24 | std::string lib_image; |
| 25 | /// destination image for call graph file, empty if this sample |
| 26 | /// file is not a callgraph file. |
| 27 | std::string cg_image; |
| 28 | std::string event; |
| 29 | std::string count; |
| 30 | std::string unitmask; |
| 31 | std::string tgid; |
| 32 | std::string tid; |
| 33 | std::string cpu; |
| 34 | |
| 35 | /// return true if the profile specification are identical. |
| 36 | bool profile_spec_equal(parsed_filename const & parsed); |
| 37 | |
| 38 | /** |
| 39 | * the original sample filename from which the |
| 40 | * above components are built |
| 41 | */ |
| 42 | std::string filename; |
| 43 | bool jit_dumpfile_exists; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | /// debugging helper |
| 48 | std::ostream & operator<<(std::ostream &, parsed_filename const &); |
| 49 | |
| 50 | |
| 51 | /** |
| 52 | * parse a sample filename |
| 53 | * @param filename in: a sample filename |
| 54 | * @param extra_found_images binary image location |
| 55 | * |
| 56 | * filename is split into constituent parts, the lib_image is optional |
| 57 | * and can be empty on successfull call. All other error are fatal. |
| 58 | * Filenames are encoded as according to PP:3.19 to PP:3.25 |
| 59 | * |
| 60 | * all errors throw an std::invalid_argument exception |
| 61 | */ |
| 62 | parsed_filename parse_filename(std::string const & filename, |
| 63 | extra_images const & extra_found_images); |
| 64 | |
| 65 | #endif /* !PARSE_FILENAME_H */ |