3939const size_t kCompressedUidLength = 32 ;
4040const size_t kUidLength = 38 ;
4141
42+
43+ enum UidFormat
44+ {
45+ RAW, PYLONG
46+ };
47+
4248// Public struct used in Python.
4349struct UserInfo
4450{
@@ -95,13 +101,23 @@ struct UserInfo
95101
96102
97103 // Throw away useless characters and convert to char array (fixed size - no null-termination needed).
98- void setUid (std::string const & uid, bool compress ) noexcept (false )
104+ void setUid (std::string const & uid, uint8_t format ) noexcept (false )
99105 {
100- std::string cUid = uid ;
101- if (compress )
106+ std::string cUid;
107+ switch (format )
102108 {
103- cUid = this ->compressUid (uid);
104- }
109+ case RAW:
110+ {
111+ cUid = uid;
112+ break ;
113+ }
114+ case PYLONG:
115+ {
116+ cUid = this ->compressUid (uid);
117+ break ;
118+ }
119+ };
120+
105121 std::memcpy (this ->raw_uid , cUid.c_str (), sizeof (char ) * cUid.size ());
106122 }
107123
@@ -155,12 +171,12 @@ NOTE: We need a C interface, so prepare yourself for C-style structures in the p
155171this function (called from a Python code with a ctypes wrapper) and
156172callback function (actual Python function - also a ctypes wrapper).
157173*/
158- EXPORT void Iterate (TCallback callback, char const ** eventNames, int numEventNames, int eventsLimit, bool compress_uid )
174+ EXPORT void Iterate (TCallback callback, char const ** eventNames, int numEventNames, int eventsLimit, uint8_t uid_format )
159175{
160176 std::set<std::string> processKeys (eventNames, eventNames + numEventNames);
161177
162178 alohalytics::Processor (
163- [&callback, &processKeys, &compress_uid ](AlohalyticsIdServerEvent const * idEvent, AlohalyticsKeyEvent const * event)
179+ [&callback, &processKeys, &uid_format ](AlohalyticsIdServerEvent const * idEvent, AlohalyticsKeyEvent const * event)
164180 {
165181 if (!processKeys.empty () && !processKeys.count (event->key ))
166182 return ;
@@ -174,7 +190,7 @@ EXPORT void Iterate(TCallback callback, char const ** eventNames, int numEventNa
174190
175191 try
176192 {
177- userInfo.setUid (idEvent->id , compress_uid );
193+ userInfo.setUid (idEvent->id , uid_format );
178194 }
179195 catch (std::logic_error const & e)
180196 {
0 commit comments