Advertisement
WeltEnSTurm

Untitled

Jan 21st, 2012
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1.  
  2. template <typename T, T... Chars>
  3. class EncryptString {
  4.     private:
  5.  
  6.         template <T C>
  7.         struct EncryptChar {
  8.             static char const Value = (((C ^ 0x12) ^ 0x55) + 1);
  9.         };
  10.  
  11.         static std::size_t const Length = sizeof...(Chars);
  12.         T* Value;
  13.         std::size_t Current;
  14.  
  15.         template<typename... T_args>
  16.         void AddChar(T c, T_args... others){
  17.             AddChar(c);
  18.             AddChar(others...);
  19.         }
  20.  
  21.         void AddChar(T c){
  22.             Value[Current++] = c;
  23.         }
  24.  
  25.     public:
  26.  
  27.         EncryptString(){
  28.             Current = 0;
  29.             Value = new T[Length + 1];
  30.             AddChar(EncryptChar<Chars>::Value...);
  31.         }
  32.  
  33.         ~EncryptString(){
  34.             delete[] Value;
  35.         }
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement