libzypp  10.5.0
Random.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00009 
00010 #ifndef ZYPP_BASE_Random_H
00011 #define ZYPP_BASE_Random_H
00012 
00013 #include <string>
00014 
00016 namespace zypp
00017 { 
00018 
00019   namespace base
00020   { 
00021     // Taken from KApplication
00022     int random_int();
00023     // Taken from KApplication
00024     std::string random_string(int length);
00025 
00026 
00028     inline unsigned random()
00029     {
00030       return random_int();
00031     }
00033     inline unsigned random( unsigned size_r )
00034     {
00035       return random_int() % size_r;
00036     }
00038     inline unsigned random( unsigned min_r, unsigned size_r )
00039     {
00040       return min_r + random( size_r );
00041     }
00042 
00043 
00044   } //ns base
00045 } // ns zypp
00046 
00047 #endif
00048