RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* account_key.cc 00002 Jeremy Barnes, 24 November 2012 00003 Copyright (c) 2012 Datacratic. All rights reserved. 00004 00005 Account key functions. 00006 */ 00007 00008 #include "rtbkit/common/account_key.h" 00009 #include "jml/db/persistent.h" 00010 00011 using namespace std; 00012 using namespace ML; 00013 00014 00015 namespace RTBKIT { 00016 00017 void validateSlug(const std::string & slug) 00018 { 00019 if (slug.empty()) 00020 throw ML::Exception("campaign/strategy slug cannot be empty"); 00021 if (slug.size() > 256) 00022 throw ML::Exception("campaign/strategy slug has max length of 256"); 00023 00024 for (char c: slug) 00025 if (c != '_' && c != '.' && !isalnum(c)) 00026 throw ML::Exception("campaign/strategy slug has invalid ASCII code %c/%i: %s", c, c, slug.c_str()); 00027 } 00028 00029 00030 /*****************************************************************************/ 00031 /* ACCOUNT KEY */ 00032 /*****************************************************************************/ 00033 00034 void 00035 AccountKey:: 00036 serialize(ML::DB::Store_Writer & store) const 00037 { 00038 store << (unsigned char)0; 00039 store.save(static_cast<AccountKeyBase>(*this)); 00040 } 00041 00042 void 00043 AccountKey:: 00044 reconstitute(ML::DB::Store_Reader & store) 00045 { 00046 unsigned char version = 0; 00047 store >> version; 00048 if (version != 0) 00049 throw ML::Exception("invalid AccountKey version"); 00050 store.load(static_cast<AccountKeyBase &>(*this)); 00051 } 00052 00053 } // namespace RTBKIT