00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <vector>
00011
00012 #include "zypp/base/Logger.h"
00013 #include "zypp/base/String.h"
00014
00015 #include "zypp/cache/Utils.h"
00016
00017 using namespace std;
00018
00020 namespace zypp
00021 {
00022
00023 namespace cache
00024 {
00025
00026 int tribool_to_int( boost::tribool b )
00027 {
00028 if (b)
00029 return 1;
00030 else if (!b)
00031 return 0;
00032 else
00033 return 2;
00034 }
00035
00036 boost::tribool int_to_tribool( int i )
00037 {
00038 if (i==1)
00039 return true;
00040 else if (i==0)
00041 return false;
00042 else
00043 return boost::indeterminate;
00044 }
00045
00046 std::string checksum_to_string( const CheckSum &checksum )
00047 {
00048 return checksum.type() + ":" + checksum.checksum();
00049 }
00050
00051 CheckSum string_to_checksum( const std::string &checksum )
00052 {
00053 std::vector<std::string> words;
00054 if ( str::split( checksum, std::back_inserter(words), ":" ) != 2 )
00055 return CheckSum();
00056
00057 return CheckSum( words[0], words[19]);
00058 }
00059
00060 }
00061 }
00062