Atlas-C++
Utility.h
Go to the documentation of this file.
1 // This file may be redistributed and modified under the terms of the
2 // GNU Lesser General Public License (See COPYING for details).
3 // Copyright (C) 2000 Stefanus Du Toit, Michael Day
4 
5 // $Id$
6 
7 #ifndef ATLAS_CODECS_UTILITY_H
8 #define ATLAS_CODECS_UTILITY_H
9 
20 #include <cstdio>
21 #include <string>
22 
23 namespace Atlas { namespace Codecs {
24 
26 inline const std::string charToHex(char c)
27 {
28  char hex[3];
29 #ifdef __MINGW32__
30  // Perhaps this should #ifdef _WIN32 instead?
31  _snprintf(hex, 3, "%x", c);
32 #else
33  snprintf(hex, 3, "%x", c);
34 #endif
35  return hex;
36 }
37 
39 inline char hexToChar(const std::string& hex)
40 {
41  int c;
42  if (sscanf(hex.c_str(), "%x", &c) == 1) {
43  return (char) c;
44  } else {
45  return (char) 0;
46  }
47 }
48 
49 const std::string hexEncodeWithPrefix(const std::string& prefix,
50  const std::string& special,
51  const std::string& message);
52 
53 const std::string hexDecodeWithPrefix(const std::string& prefix,
54  const std::string& message);
55 
56 } } // namespace Atlas::Codecs
57 
58 #endif // ATLAS_CODECS_UTILITY_H
The Atlas namespace.
Definition: Bridge.h:20

Copyright 2000-2004 the respective authors.

This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.