[0d0e60]: libpp / locate_images.h  Maximize  Restore  History

Download this file

76 lines (64 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* @file locate_images.h
* Location of binary images
*
* @remark Copyright 2002 OProfile authors
* @remark Read the file COPYING
*
* @author Philippe Elie
* @author John Levon
*/
#ifndef LOCATE_IMAGES_H
#define LOCATE_IMAGES_H
#include <string>
#include <map>
#include <vector>
#include "image_errors.h"
/**
* A class containing mappings from an image basename,
* such as 'floppy.ko', to locations in the paths passed
* in to populate().
*
* The name may exist multiple times; all locations are recorded
* in this container.
*/
class extra_images {
public:
/// add all filenames found in the given paths, recursively
void populate(std::vector<std::string> const & paths);
/// base class for matcher functors object
struct matcher {
std::string const & value;
public:
explicit matcher(std::string const & v) : value(v) {}
/// default functor allowing trivial match
virtual bool operator()(std::string const & str) const {
return str == value;
}
};
/**
* return a vector of all directories that match the functor
*/
std::vector<std::string> const find(matcher const & match) const;
/// return a vector of all directories that match the given name
std::vector<std::string> const find(std::string const & name) const;
private:
typedef std::multimap<std::string, std::string> images_t;
typedef images_t::value_type value_type;
typedef images_t::const_iterator const_iterator;
/// map from image basename to owning directory
images_t images;
};
/**
* @param extra_images container where all extra candidate filenames are stored
* @param image_name binary image name
* @param error errors are flagged in this passed enum ref
*
* Locate a (number of) matching absolute paths to the given image name.
* If we fail to find the file we fill in error and return the original string.
*/
std::string const
find_image_path(std::string const & image_name,
extra_images const & extra_images,
image_error & error);
#endif /* LOCATE_IMAGES_H */

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks