source: XIOS/trunk/src/uuid.cpp @ 1211

Last change on this file since 1211 was 1048, checked in by ymipsl, 7 years ago
  • Xios output now an uuid for each files.
  • 2 new file attribute to parametrize uuid output :
    • uuid_name (default is "uuid")
    • uuid_format : the substring "%uuid%" will replace by the uuid (default : no format)

YM

  • Property svn:eol-style set to native
File size: 626 bytes
Line 
1#include <boost/uuid/uuid.hpp>
2#include <boost/uuid/uuid_generators.hpp>
3#include <boost/uuid/uuid_io.hpp>
4
5namespace xios
6{
7 
8  std::string getUuidStr(void)
9  {
10    boost::uuids::random_generator gen;
11    boost::uuids::uuid u = gen();
12    return boost::uuids::to_string(u) ;
13  }
14 
15  std::string getUuidStr(const std::string& format)
16  {
17    size_t pos ;
18    std::string retStr(format) ;
19    std::string uuid(getUuidStr()) ;
20    std::string id("%uuid%");
21    pos=retStr.find(id) ;
22    while(pos!=std::string::npos)
23    {
24      retStr.replace(pos,id.size(),uuid) ;
25      pos=retStr.find(id) ;
26    }
27    return retStr;
28  }
29}
30
Note: See TracBrowser for help on using the repository browser.