~raghavendra-prabhu/percona-xtradb-cluster/release-5.5.30-galera-2.x

« back to all changes in this revision

Viewing changes to galerautils/src/gu_utils.hpp

  • Committer: Ignacio Nin
  • Date: 2012-10-31 22:57:41 UTC
  • mfrom: (95.2.11 2.x)
  • Revision ID: ignacio.nin@percona.com-20121031225741-kzcz6072mwzfpaiw
MergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
/**
4
4
 * @file General-purpose functions and templates
5
5
 *
6
 
 * $Id: gu_utils.hpp 2272 2011-07-28 23:24:41Z alex $
 
6
 * $Id: gu_utils.hpp 2875 2012-10-10 16:59:04Z alex $
7
7
 */
8
8
 
9
9
#ifndef _gu_utils_hpp_
63
63
    std::istringstream iss(s);
64
64
    T                  ret;
65
65
 
66
 
    if ((iss >> f >> ret).fail()) throw NotFound();
67
 
 
 
66
    try
 
67
    {
 
68
        if ((iss >> f >> ret).fail()) throw NotFound();
 
69
    }
 
70
    catch (gu::Exception& e)
 
71
    {
 
72
        throw NotFound();
 
73
    }
68
74
    return ret;
69
75
}
70
76
 
90
96
    return ret;
91
97
}
92
98
 
93
 
extern bool _to_bool (const std::string& s) throw (NotFound);
 
99
extern "C" const char* gu_str2bool (const char* str, bool*   bl);
 
100
//extern bool _to_bool (const std::string& s) throw (NotFound);
94
101
 
95
102
/*! Specialized template for reading bool. Tries both 1|0 and true|false */
96
103
template <> inline bool from_string<bool> (const std::string& s,
97
104
                                           std::ios_base& (*f)(std::ios_base&))
98
105
    throw(NotFound)
99
106
{
100
 
    return _to_bool(s);
 
107
    const char* const str(s.c_str());
 
108
    bool ret;
 
109
    const char* endptr(gu_str2bool(str, &ret));
 
110
    if (endptr == 0 || *endptr != '\0') throw NotFound();
 
111
    return ret;
 
112
//    return _to_bool(s);
101
113
}
102
114
 
103
 
/*! 
 
115
/*!
104
116
 * Substitute for the Variable Length Array on the stack from C99.
105
117
 * Provides automatic deallocation when out of scope:
106
118
 *