Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

Utility.h

Go to the documentation of this file.
00001 // This file may be redistributed and modified under the terms of the
00002 // GNU Lesser General Public License (See COPYING for details).
00003 // Copyright (C) 2000 Stefanus Du Toit, Michael Day
00004 
00005 #ifndef ATLAS_CODECS_UTILITY_H
00006 #define ATLAS_CODECS_UTILITY_H
00007 
00018 #include <cstdio>
00019 #include <string>
00020 
00021 namespace Atlas { namespace Codecs {
00022 
00024 inline const std::string charToHex(char c)
00025 {
00026     char hex[3];
00027 #ifdef __MINGW32__
00028     // Perhaps this should #ifdef _WIN32 instead?    
00029     _snprintf(hex, 3, "%x", c);
00030 #else
00031     snprintf(hex, 3, "%x", c);
00032 #endif
00033     return hex;
00034 }
00035 
00037 inline char hexToChar(const std::string& hex)
00038 {
00039     int c;
00040     if (sscanf(hex.c_str(), "%x", &c) == 1) {
00041         return (char) c;
00042     } else {
00043         return (char) 0;
00044     }
00045 }
00046 
00047 const std::string hexEncodeWithPrefix(const std::string& prefix,
00048                                       const std::string& special,
00049                                       const std::string& message);
00050 
00051 const std::string hexDecodeWithPrefix(const std::string& prefix,
00052                                       const std::string& message);
00053 
00054 } } // namespace Atlas::Codecs
00055 
00056 #endif // ATLAS_CODECS_UTILITY_H

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.