Sierra Toolkit Version of the Day
ci_string.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #include <iostream>
00010 
00011 #include <stk_util/util/ci_string.hpp>
00012 
00013 std::ostream &
00014 operator<<(
00015   std::ostream &        os,
00016   const ci_string &      s)
00017 {
00018   return os << std::string(s.data(),s.length());
00019 }
00020  
00021 
00022 std::istream &
00023 operator>>(
00024   std::istream &        is,
00025   ci_string &            s)
00026 {
00027   std::string t;
00028   is >> t;
00029   s = ci_string(t.begin(), t.end());
00030   
00031   return is;
00032 }
00033 
00034 std::string
00035 operator+(
00036   const std::string &   s1,
00037   const ci_string &      s2) 
00038 {
00039   std::string s(s1);
00040   
00041   return s.append(s2.begin(), s2.end());
00042 }
00043 
00044 
00045 ci_string
00046 operator+(
00047   const char *          s1,
00048   const ci_string &      s2) 
00049 {
00050   ci_string s(s1);
00051   
00052   return s.append(s2.begin(), s2.end());
00053 }
00054 
00055 
00056 ci_string
00057 operator+(
00058   const ci_string &      s1,
00059   const std::string &   s2) 
00060 {
00061   ci_string s(s1);
00062   
00063   return s.append(s2.begin(), s2.end());
00064 }
00065 
00066 
00067 // namespace boost {
00068 
00069 // std::size_t
00070 // hash<ci_string>::operator()(
00071 //   const ci_string &      s) const
00072 // {
00073 //   std::size_t seed = 0;
00074     
00075 //   for(ci_string::const_iterator first = s.begin(); first != s.end(); ++first) {
00076 //     std::tr1::hash<char> hasher;
00077 //     seed ^= hasher(std::tolower(*first)) + 0x9e3779b9 + (seed<<6) + (seed>>2);
00078 //   }
00079     
00080 //   return seed;
00081 // }
00082 
00083 // } // namespace boost
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines