Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "Random.h"
00009 #include <time.h>
00010 #include <stdlib.h>
00011
00012 namespace dtn
00013 {
00014 namespace utils
00015 {
00016 Random::Random()
00017 {
00018
00019 srand(time(0));
00020 }
00021
00022 Random::~Random()
00023 {
00024 }
00025
00026 const std::string Random::gen_chars(size_t size) const
00027 {
00028 static const char text[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
00029 char dst[size];
00030 int i, len = size - 1;
00031 for ( i = 0; i < len; ++i )
00032 {
00033 dst[i] = text[rand() % (sizeof text - 1)];
00034 }
00035 dst[i] = '\0';
00036 return dst;
00037 };
00038 }
00039 }