libzypp  15.28.6
Random.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
10 #ifndef ZYPP_BASE_Random_H
11 #define ZYPP_BASE_Random_H
12 
13 #include <string>
14 
16 namespace zypp
17 {
18  namespace base
20  {
21  // Taken from KApplication
22  int random_int();
23  // Taken from KApplication
24  std::string random_string(int length);
25 
26 
28  inline unsigned random()
29  {
30  return random_int();
31  }
33  inline unsigned random( unsigned size_r )
34  {
35  return random_int() % size_r;
36  }
38  inline unsigned random( unsigned min_r, unsigned size_r )
39  {
40  return min_r + random( size_r );
41  }
42 
43 
44  } //ns base
45 } // ns zypp
46 
47 #endif
48 
int random_int()
Definition: Random.cc:10
std::string random_string(int length)
Definition: Random.cc:31
unsigned random()
Return a random number from [0,RAND_MAX[.
Definition: Random.h:28