/*------------------------------------------------------------------------------
 src/lib/dj/djSerialize_.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

namespace dj {

template <class T>
inline const StrList deflateStr(const List<T> & in)
{
  return toStrList(in);
}

template <class T>
inline const StrList deflateStr(const T & in, const StrList & str)
{
  return StrList() + str[in];
}

template <class T>
inline bool inflateStr(StrList & in, T * out, const StrList & str)
{
  if (! in.size() || ! out) return false;

  //const int i = str.index(in[0]);
  const Str tmp = lowercase(in[0]);
  int i = 0;
  for (; i < str.size(); ++i)
    if (tmp == lowercase(str[i])) break;
  if (i == str.size()) return false;

  *out = T(i);
  in.pop();
  return true;
}

}
