@@ -443,7 +443,13 @@ target_link_libraries(hello_world ${CPPCMS_LIB}) | |||
add_executable(cppcms_scale src/cache_server_main.cpp) | |||
target_link_libraries(cppcms_scale ${CPPCMS_LIB}) | |||
add_executable(cppcms_config_find_param src/cppcms_config_find_param.cpp src/json.cpp) | |||
add_executable(cppcms_config_find_param src/cppcms_config_find_param.cpp src/json.cpp | |||
) | |||
if(DISABLE_SHARED) | |||
target_link_libraries(cppcms_config_find_param booster-static) | |||
else(DISABLE_SHARED) | |||
target_link_libraries(cppcms_config_find_param booster) | |||
endif(DISABLE_SHARED) | |||
######################################### | |||
# Tests | |||
@@ -10,6 +10,7 @@ | |||
#include <booster/config.h> | |||
#include <stdexcept> | |||
#include <typeinfo> | |||
#include <vector> | |||
#include <iosfwd> | |||
@@ -86,23 +87,70 @@ namespace booster { | |||
class exception : public std::exception, public backtrace { | |||
public: | |||
}; | |||
class bad_cast : public std::bad_cast, public backtrace { | |||
public: | |||
}; | |||
class runtime_error: public std::runtime_error, public backtrace { | |||
public: | |||
runtime_error(std::string const &s) : std::runtime_error(s) | |||
explicit runtime_error(std::string const &s) : std::runtime_error(s) | |||
{ | |||
} | |||
}; | |||
class range_error: public std::range_error, public backtrace { | |||
public: | |||
explicit range_error(std::string const &s) : std::range_error(s) | |||
{ | |||
} | |||
}; | |||
class overflow_error: public std::overflow_error, public backtrace { | |||
public: | |||
explicit overflow_error(std::string const &s) : std::overflow_error(s) | |||
{ | |||
} | |||
}; | |||
class underflow_error: public std::underflow_error, public backtrace { | |||
public: | |||
explicit underflow_error(std::string const &s) : std::underflow_error(s) | |||
{ | |||
} | |||
}; | |||
class logic_error: public std::logic_error, public backtrace { | |||
public: | |||
logic_error(std::string const &s) : std::logic_error(s) | |||
explicit logic_error(std::string const &s) : std::logic_error(s) | |||
{ | |||
} | |||
}; | |||
class domain_error: public std::domain_error, public backtrace { | |||
public: | |||
explicit domain_error(std::string const &s) : std::domain_error(s) | |||
{ | |||
} | |||
}; | |||
class length_error: public std::length_error, public backtrace { | |||
public: | |||
explicit length_error(std::string const &s) : std::length_error(s) | |||
{ | |||
} | |||
}; | |||
class invalid_argument : public std::invalid_argument, public backtrace { | |||
public: | |||
invalid_argument(std::string const &s) : std::invalid_argument(s) | |||
explicit invalid_argument(std::string const &s) : std::invalid_argument(s) | |||
{ | |||
} | |||
}; | |||
class out_of_range : public std::out_of_range, public backtrace { | |||
public: | |||
explicit out_of_range(std::string const &s) : std::out_of_range(s) | |||
{ | |||
} | |||
}; | |||
@@ -11,7 +11,7 @@ | |||
// http://www.boost.org/LICENSE_1_0.txt) | |||
// | |||
#include <exception> | |||
#include <booster/backtrace.h> | |||
#ifdef __BORLANDC__ | |||
# pragma warn -8026 // Functions with excep. spec. are not expanded inline | |||
@@ -33,7 +33,7 @@ namespace booster | |||
/// | |||
/// An exeption that is throws in case of creating of shared_ptr from expired weak_ptr | |||
/// | |||
class bad_weak_ptr: public std::exception | |||
class bad_weak_ptr: public booster::exception | |||
{ | |||
public: | |||
@@ -8,7 +8,7 @@ | |||
#ifndef BOOSTER_CALLBACK_H | |||
#define BOOSTER_CALLBACK_H | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <memory> | |||
#include <booster/intrusive_ptr.h> | |||
#include <booster/refcounted.h> | |||
@@ -24,10 +24,10 @@ namespace booster { | |||
/// \brief this exception is thrown in case of calling unassigned/empty | |||
/// function | |||
/// | |||
class bad_callback_call : public std::runtime_error { | |||
class bad_callback_call : public booster::runtime_error { | |||
public: | |||
bad_callback_call() : | |||
std::runtime_error("bad_callback_call") | |||
booster::runtime_error("bad_callback_call") | |||
{ | |||
} | |||
}; | |||
@@ -8,17 +8,17 @@ | |||
#ifndef BOOSTER_FUNCTION_H | |||
#define BOOSTER_FUNCTION_H | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <booster/clone_ptr.h> | |||
namespace booster { | |||
template<typename Type> | |||
class function; | |||
class bad_function_call : public std::runtime_error { | |||
class bad_function_call : public booster::runtime_error { | |||
public: | |||
bad_function_call() : | |||
std::runtime_error("bad_function_call") | |||
booster::runtime_error("bad_function_call") | |||
{ | |||
} | |||
}; | |||
@@ -21,7 +21,7 @@ | |||
#include <algorithm> | |||
#include <typeinfo> | |||
#include <iterator> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
@@ -607,14 +607,14 @@ namespace booster { | |||
/// | |||
/// Return the token the iterator points it. Iterator must not point to the | |||
/// end of the range. Throws std::out_of_range exception | |||
/// end of the range. Throws booster::out_of_range exception | |||
/// | |||
/// Note, returned value is not lvalue, you can't use this iterator to assign new values to text. | |||
/// | |||
ValueType operator*() const | |||
{ | |||
if(offset_ < 1 || offset_ >= map_->index_.size()) | |||
throw std::out_of_range("Invalid token iterator location"); | |||
throw booster::out_of_range("Invalid token iterator location"); | |||
unsigned pos=offset_-1; | |||
if(full_select_) | |||
while(!valid_offset(pos)) | |||
@@ -872,14 +872,14 @@ namespace booster { | |||
/// | |||
/// Return the underlying iterator that break_iterator points it. Iterator must not point to the | |||
/// end of the range, otherwise throws std::out_of_range exception | |||
/// end of the range, otherwise throws booster::out_of_range exception | |||
/// | |||
/// Note, returned value is not lvalue, you can't use this iterator to change underlying iterators. | |||
/// | |||
base_iterator operator*() const | |||
{ | |||
if(offset_ >=map_->index_.size()) | |||
throw std::out_of_range("Invalid position of break iterator"); | |||
throw booster::out_of_range("Invalid position of break iterator"); | |||
base_iterator p = map_->begin_; | |||
std::advance(p, map_->index_[offset_].offset); | |||
return p; | |||
@@ -18,7 +18,7 @@ | |||
#include <booster/locale/date_time_facet.h> | |||
#include <locale> | |||
#include <vector> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
namespace booster { | |||
@@ -34,12 +34,12 @@ namespace booster { | |||
/// | |||
/// \brief This error is thrown in case of invalid state that occurred | |||
/// | |||
class date_time_error : public std::runtime_error { | |||
class date_time_error : public booster::runtime_error { | |||
public: | |||
/// | |||
/// Constructor of date_time_error class | |||
/// | |||
date_time_error(std::string const &e) : std::runtime_error(e) {} | |||
date_time_error(std::string const &e) : booster::runtime_error(e) {} | |||
}; | |||
@@ -490,7 +490,7 @@ namespace booster { | |||
date_time_period const &operator[](unsigned n) const | |||
{ | |||
if(n >= size()) | |||
throw std::out_of_range("Invalid index to date_time_period"); | |||
throw booster::out_of_range("Invalid index to date_time_period"); | |||
if(n < 4) | |||
return basic_[n]; | |||
else | |||
@@ -15,7 +15,7 @@ | |||
#endif | |||
#include <booster/locale/info.h> | |||
#include <booster/cstdint.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
@@ -34,21 +34,21 @@ namespace booster { | |||
/// | |||
/// \brief The excepton that is thrown in case of conversion error | |||
/// | |||
class conversion_error : public std::runtime_error { | |||
class conversion_error : public booster::runtime_error { | |||
public: | |||
conversion_error() : std::runtime_error("Conversion failed") {} | |||
conversion_error() : booster::runtime_error("Conversion failed") {} | |||
}; | |||
/// | |||
/// \brief This exception is thrown in case of use of unsupported | |||
/// or invalid character set | |||
/// | |||
class invalid_charset_error : public std::runtime_error { | |||
class invalid_charset_error : public booster::runtime_error { | |||
public: | |||
/// Create an error for charset \a charset | |||
invalid_charset_error(std::string charset) : | |||
std::runtime_error("Invalid or unsupported charset:" + charset) | |||
booster::runtime_error("Invalid or unsupported charset:" + charset) | |||
{ | |||
} | |||
}; | |||
@@ -9,7 +9,7 @@ | |||
#define BOOSTER_LOCLAE_GNU_GETTEXT_HPP | |||
#include <booster/locale/message.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
namespace booster { | |||
namespace locale { | |||
@@ -2,7 +2,7 @@ | |||
#define BOOSTER_NOWIDE_CONVERT_H | |||
#include <booster/config.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) | |||
namespace booster { | |||
@@ -11,7 +11,7 @@ namespace booster { | |||
/// | |||
/// \brief This exception is thrown if invalid UTF-8 or UTF-16 is given as input | |||
/// | |||
class BOOSTER_API bad_utf : public std::runtime_error { | |||
class BOOSTER_API bad_utf : public booster::runtime_error { | |||
public: | |||
bad_utf(); | |||
}; | |||
@@ -12,15 +12,15 @@ | |||
#include <booster/copy_ptr.h> | |||
#include <string> | |||
#include <vector> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
namespace booster { | |||
/// | |||
/// \brief Exception that is thrown in case of creation of invalid regex | |||
/// | |||
class regex_error : public std::runtime_error { | |||
class regex_error : public booster::runtime_error { | |||
public: | |||
regex_error(std::string const &s) : std::runtime_error(s) | |||
regex_error(std::string const &s) : booster::runtime_error(s) | |||
{ | |||
} | |||
}; | |||
@@ -18,6 +18,7 @@ | |||
#include <memory> | |||
#include <cassert> | |||
#include <booster/backtrace.h> | |||
#include <booster/checked_delete.h> | |||
#include <booster/smart_ptr/shared_count.h> | |||
#include <booster/smart_ptr/sp_convertible.h> | |||
@@ -215,7 +216,7 @@ public: | |||
{ | |||
if(px == 0) | |||
{ | |||
throw std::bad_cast(); | |||
throw booster::bad_cast(); | |||
} | |||
} | |||
@@ -9,7 +9,7 @@ | |||
#define BOOSTER_SYSTEM_ERROR_H | |||
#include <string> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <functional> | |||
#include <booster/config.h> | |||
@@ -99,15 +99,15 @@ namespace system { | |||
return !(left==right); | |||
} | |||
class system_error : public std::runtime_error { | |||
class system_error : public booster::runtime_error { | |||
public: | |||
system_error(error_code const &e) : | |||
std::runtime_error(e.message()), | |||
booster::runtime_error(e.message()), | |||
error_(e) | |||
{ | |||
} | |||
system_error(error_code const &e,std::string const &message) : | |||
std::runtime_error(e.message()+": " + message), | |||
booster::runtime_error(e.message()+": " + message), | |||
error_(e) | |||
{ | |||
} | |||
@@ -118,7 +118,7 @@ public: | |||
void set_io_event(native_type fd,int event,event_handler const &h) | |||
{ | |||
if(event != in && event !=out) | |||
throw std::invalid_argument("Invalid argument to set_io_event"); | |||
throw booster::invalid_argument("Invalid argument to set_io_event"); | |||
io_event_setter setter = { fd,event,h,this }; | |||
set_event(setter); | |||
} | |||
@@ -692,7 +692,7 @@ namespace aio { | |||
WORD ver=MAKEWORD(2, 2); | |||
WSADATA data; | |||
if(WSAStartup(ver,&data) < 0) { | |||
throw std::runtime_error("Failed to init winsock"); | |||
throw booster::runtime_error("Failed to init winsock"); | |||
} | |||
} | |||
} instance; | |||
@@ -759,7 +759,7 @@ namespace aio { | |||
if(hint!=default_poll) | |||
hint=default_poll; | |||
else | |||
throw std::runtime_error("Internal error - no poller found"); | |||
throw booster::runtime_error("Internal error - no poller found"); | |||
} | |||
} | |||
@@ -7,11 +7,6 @@ | |||
// | |||
#define BOOSTER_SOURCE | |||
#include <booster/config.h> | |||
#if (!defined(BOOSTER_WIN_NATIVE) && !defined(BOOSTER_LOCALE_NO_ICONV)) | |||
# ifndef BOOSTER_LOCALE_WITH_ICONV | |||
# define BOOSTER_LOCALE_WITH_ICONV | |||
# endif | |||
#endif | |||
#if defined(BOOSTER_WIN_NATIVE) || defined(__CYGWIN__) | |||
#define BOOSTER_LOCALE_WITH_WCONV | |||
@@ -117,11 +117,11 @@ std::auto_ptr<icu::BreakIterator> get_iterator(boundary_type t,icu::Locale const | |||
bi.reset(icu::BreakIterator::createLineInstance(loc,err)); | |||
break; | |||
default: | |||
throw std::runtime_error("Invalid iteration type"); | |||
throw booster::runtime_error("Invalid iteration type"); | |||
} | |||
check_and_throw_icu_error(err); | |||
if(!bi.get()) | |||
throw std::runtime_error("Failed to create break iterator"); | |||
throw booster::runtime_error("Failed to create break iterator"); | |||
return bi; | |||
} | |||
@@ -145,7 +145,7 @@ index_type do_map(boundary_type t,CharType const *begin,CharType const *end,icu: | |||
check_and_throw_icu_error(err); | |||
err=U_ZERO_ERROR; | |||
if(!ut) throw std::runtime_error("Failed to create UText"); | |||
if(!ut) throw booster::runtime_error("Failed to create UText"); | |||
bi->setText(ut,err); | |||
check_and_throw_icu_error(err); | |||
index_type res=map_direct(t,bi.get(),end-begin); | |||
@@ -83,7 +83,7 @@ namespace booster { | |||
int res = do_real_compare(collate,level,b1,e1,b2,e2,status); | |||
if(U_FAILURE(status)) | |||
throw std::runtime_error(std::string("Collation failed:") + u_errorName(status)); | |||
throw booster::runtime_error(std::string("Collation failed:") + u_errorName(status)); | |||
if(res < 0) | |||
return -1; | |||
else if(res > 0) | |||
@@ -138,7 +138,7 @@ namespace booster { | |||
collates_[i].reset(icu::Collator::createInstance(d.locale,status)); | |||
if(U_FAILURE(status)) | |||
throw std::runtime_error(std::string("Creation of collate failed:") + u_errorName(status)); | |||
throw booster::runtime_error(std::string("Creation of collate failed:") + u_errorName(status)); | |||
collates_[i]->setStrength(levels[i]); | |||
} | |||
@@ -110,7 +110,7 @@ namespace impl_icu { | |||
map_ = ucasemap_open(locale_id.c_str(),0,&err); | |||
check_and_throw_icu_error(err); | |||
if(!map_) | |||
throw std::runtime_error("Failed to create UCaseMap"); | |||
throw booster::runtime_error("Failed to create UCaseMap"); | |||
} | |||
template<typename Conv> | |||
std::string convert(Conv func,char const *begin,char const *end) const | |||
@@ -56,7 +56,7 @@ namespace impl_icu { | |||
case week_of_year: return UCAL_WEEK_OF_YEAR; | |||
case week_of_month: return UCAL_WEEK_OF_MONTH; | |||
default: | |||
throw std::invalid_argument("Invalid date_time period type"); | |||
throw booster::invalid_argument("Invalid date_time period type"); | |||
} | |||
} | |||
@@ -154,13 +154,13 @@ namespace impl_icu { | |||
} | |||
virtual void set_option(calendar_option_type opt,int v) | |||
{ | |||
throw std::invalid_argument("There is no settable options for calendar"); | |||
throw booster::invalid_argument("There is no settable options for calendar"); | |||
} | |||
virtual int get_option(calendar_option_type opt) const | |||
{ | |||
if(opt==is_gregorian) | |||
return dynamic_cast<icu::GregorianCalendar const *>(calendar_.get())!=0; | |||
throw std::invalid_argument("Invalid option"); | |||
throw booster::invalid_argument("Invalid option"); | |||
} | |||
virtual void adjust_value(period_type p,update_type u,int difference) | |||
{ | |||
@@ -8,7 +8,7 @@ | |||
#ifndef BOOSTER_SRC_ICU_UTIL_HPP | |||
#define BOOSTER_SRC_ICU_UTIL_HPP | |||
#include <unicode/utypes.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
namespace booster { | |||
namespace locale { | |||
@@ -16,7 +16,7 @@ namespace impl_icu { | |||
inline void throw_icu_error(UErrorCode err) | |||
{ | |||
throw std::runtime_error(u_errorName(err)); | |||
throw booster::runtime_error(u_errorName(err)); | |||
} | |||
inline void check_and_throw_icu_error(UErrorCode err) | |||
@@ -171,6 +171,7 @@ private: | |||
*out++ = fill; | |||
on_right--; | |||
} | |||
ios.width(0); | |||
return out; | |||
} | |||
@@ -105,7 +105,7 @@ namespace locale { | |||
void test(UErrorCode err) | |||
{ | |||
if(U_FAILURE(err)) | |||
throw std::runtime_error("Failed to create a formatter"); | |||
throw booster::runtime_error("Failed to create a formatter"); | |||
} | |||
std::auto_ptr<icu::NumberFormat> number_format_; | |||
@@ -14,7 +14,7 @@ | |||
#include <errno.h> | |||
#include <algorithm> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <vector> | |||
#include "codecvt.h" | |||
@@ -40,7 +40,7 @@ namespace impl_posix { | |||
try { | |||
d = iconv_open(utf32_encoding(),encoding.c_str()); | |||
if(d == (iconv_t)(-1)) { | |||
throw std::runtime_error("Unsupported encoding" + encoding); | |||
throw booster::runtime_error("Unsupported encoding" + encoding); | |||
} | |||
for(unsigned c=0;c<256;c++) { | |||
char ibuf[2] = { char(c) , 0 }; | |||
@@ -11,7 +11,7 @@ | |||
#include <string.h> | |||
#include <wchar.h> | |||
#include <string> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <ios> | |||
#include <vector> | |||
#include <booster/locale/generator.h> | |||
@@ -8,7 +8,7 @@ | |||
#define BOOSTER_SOURCE | |||
#include <locale> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <booster/locale/generator.h> | |||
#include <booster/locale/conversion.h> | |||
#include <booster/locale/encoding.h> | |||
@@ -78,7 +78,7 @@ namespace impl_posix { | |||
tmp=newlocale(LC_ALL_MASK,"C",0); | |||
} | |||
if(!tmp) { | |||
throw std::runtime_error("newlocale failed"); | |||
throw booster::runtime_error("newlocale failed"); | |||
} | |||
locale_t *tmp_p = new locale_t(); | |||
*tmp_p = tmp; | |||
@@ -179,17 +179,17 @@ namespace booster { | |||
else if(magic == 0xde120495) | |||
native_byteorder_ = false; | |||
else | |||
throw std::runtime_error("Invalid file format"); | |||
throw booster::runtime_error("Invalid file format"); | |||
fseek(file,0,SEEK_END); | |||
long len=ftell(file); | |||
if(len < 0) { | |||
throw std::runtime_error("Wrong file object"); | |||
throw booster::runtime_error("Wrong file object"); | |||
} | |||
fseek(file,0,SEEK_SET); | |||
vdata_.resize(len+1,0); // +1 to make sure the vector is not empty | |||
if(fread(&vdata_.front(),1,len,file)!=unsigned(len)) | |||
throw std::runtime_error("Failed to read file"); | |||
throw booster::runtime_error("Failed to read file"); | |||
data_ = &vdata_[0]; | |||
file_size_ = len; | |||
} | |||
@@ -203,7 +203,7 @@ namespace booster { | |||
{ | |||
uint32_t tmp; | |||
if(offset > file_size_ - 4) { | |||
throw std::runtime_error("Bad file format"); | |||
throw booster::runtime_error("Bad file format"); | |||
} | |||
memcpy(&tmp,data_ + offset,4); | |||
convert(tmp); | |||
@@ -411,7 +411,7 @@ namespace booster { | |||
std::string mo_encoding = extract(mo->value(0).first,"charset="," \r\n;"); | |||
if(mo_encoding.empty()) | |||
throw std::runtime_error("Invalid mo-format, encoding is not specified"); | |||
throw booster::runtime_error("Invalid mo-format, encoding is not specified"); | |||
if(!plural.empty()) { | |||
std::auto_ptr<lambda::plural> ptr=lambda::compile(plural.c_str()); | |||
@@ -8,7 +8,7 @@ | |||
#define BOOSTER_SOURCE | |||
#include <locale> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <booster/locale/generator.h> | |||
#include <booster/locale/conversion.h> | |||
#include <booster/locale/encoding.h> | |||
@@ -204,12 +204,17 @@ namespace util { | |||
to_unicode_tbl_[i]=i; | |||
for(unsigned i=128;i<256;i++) { | |||
char buf[2] = { char(i) , 0 }; | |||
std::wstring const tmp = conv::to_utf<wchar_t>(buf,buf+1,encoding); | |||
if(tmp.size() != 1) { | |||
to_unicode_tbl_[i] = illegal; | |||
try { | |||
std::wstring const tmp = conv::to_utf<wchar_t>(buf,buf+1,encoding,conv::stop); | |||
if(tmp.size() == 1) { | |||
to_unicode_tbl_[i] = tmp[0]; | |||
} | |||
else { | |||
to_unicode_tbl_[i] = illegal; | |||
} | |||
} | |||
else { | |||
to_unicode_tbl_[i] = tmp[0]; | |||
catch(conv::conversion_error const &e) { | |||
to_unicode_tbl_[i] = illegal; | |||
} | |||
} | |||
from_unicode_tbl_.resize(256); | |||
@@ -301,7 +306,7 @@ namespace util { | |||
{ | |||
std::auto_ptr<base_converter> res; | |||
std::string norm = conv::impl::normalize_encoding(encoding.c_str()); | |||
if(std::binary_search<char const **>( simple_encoding_table, | |||
if(std::binary_search<char const **>( simple_encoding_table, | |||
simple_encoding_table + sizeof(simple_encoding_table)/sizeof(char const *), | |||
norm.c_str(), | |||
compare_strings)) | |||
@@ -76,9 +76,15 @@ private: | |||
switch(info.display_flags()) { | |||
case flags::posix: | |||
{ | |||
std::stringstream ss; | |||
typedef std::basic_ostringstream<char_type> sstream_type; | |||
sstream_type ss; | |||
ss.imbue(std::locale::classic()); | |||
return super::do_put(out,ss,fill,val); | |||
ss.flags(ios.flags()); | |||
ss.precision(ios.precision()); | |||
ss.width(ios.width()); | |||
iter_type ret_ptr = super::do_put(out,ss,fill,val); | |||
ios.width(0); | |||
return ret_ptr; | |||
} | |||
case flags::date: | |||
return format_time(out,ios,fill,static_cast<time_t>(val),'x'); | |||
@@ -284,6 +290,8 @@ private: | |||
{ | |||
std::stringstream ss; | |||
ss.imbue(std::locale::classic()); | |||
ss.flags(ios.flags()); | |||
ss.precision(ios.precision()); | |||
return super::do_get(in,end,ss,err,val); | |||
} | |||
case flags::currency: | |||
@@ -8,7 +8,7 @@ | |||
#define BOOSTER_SOURCE | |||
#include <locale> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <booster/locale/generator.h> | |||
#include <booster/locale/conversion.h> | |||
#include <booster/locale/encoding.h> | |||
@@ -14,6 +14,14 @@ | |||
#include "test_locale.h" | |||
#include "test_locale_tools.h" | |||
#ifndef BOOSTER_LOCALE_NO_POSIX_BACKEND | |||
# ifdef __APPLE__ | |||
# include <xlocale.h> | |||
# endif | |||
# include <locale.h> | |||
#endif | |||
bool test_iso; | |||
bool test_utf; | |||
bool test_sjis; | |||
@@ -253,19 +261,29 @@ void test_to() | |||
int main() | |||
{ | |||
try { | |||
std::string def[2] = { "icu" , "std" }; | |||
std::vector<std::string> def; | |||
#ifdef BOOSTER_LOCALE_WITH_ICU | |||
int start = 0; | |||
#else | |||
int start = 1; | |||
def.push_back("icu"); | |||
#endif | |||
#ifndef BOOSTER_LOCALE_NO_STD_BACKEND | |||
def.push_back("std"); | |||
#endif | |||
#ifndef BOOSTER_LOCALE_NO_WINAPI_BACKEND | |||
def.push_back("winapi"); | |||
#endif | |||
#ifndef BOOSTER_LOCALE_NO_POSIX_BACKEND | |||
def.push_back("posix"); | |||
#endif | |||
for(int type = start ; type < 2; type ++ ) { | |||
for(int type = 0; type < int(def.size()); type ++ ) { | |||
booster::locale::localization_backend_manager tmp_backend = booster::locale::localization_backend_manager::global(); | |||
tmp_backend.select(def[type]); | |||
booster::locale::localization_backend_manager::global(tmp_backend); | |||
if(def[type]=="std") { | |||
std::string bname = def[type]; | |||
if(bname=="std") { | |||
en_us_8bit = get_std_name("en_US.ISO8859-1"); | |||
he_il_8bit = get_std_name("he_IL.ISO8859-8"); | |||
ja_jp_shiftjis = get_std_name("ja_JP.SJIS"); | |||
@@ -279,15 +297,47 @@ int main() | |||
std::cout << "Testing for backend " << def[type] << std::endl; | |||
test_iso = true; | |||
if(def[type]=="std" && (he_il_8bit.empty() || en_us_8bit.empty())) { | |||
if(bname=="std" && (he_il_8bit.empty() || en_us_8bit.empty())) { | |||
std::cout << "no iso locales availible, passing" << std::endl; | |||
test_iso = false; | |||
} | |||
test_sjis = true; | |||
if(def[type]=="std" && ja_jp_shiftjis.empty()) { | |||
std::cout << "no ShiftJIS locales availible, passing" << std::endl; | |||
if(bname=="std" && ja_jp_shiftjis.empty()) { | |||
test_sjis = false; | |||
} | |||
if(bname=="winapi") { | |||
test_iso = false; | |||
test_sjis = false; | |||
} | |||
#ifndef BOOSTER_LOCALE_NO_POSIX_BACKEND | |||
if(bname=="posix") { | |||
{ | |||
locale_t l = newlocale(LC_ALL_MASK,he_il_8bit.c_str(),0); | |||
if(!l) | |||
test_iso = false; | |||
else | |||
freelocale(l); | |||
} | |||
{ | |||
locale_t l = newlocale(LC_ALL_MASK,en_us_8bit.c_str(),0); | |||
if(!l) | |||
test_iso = false; | |||
else | |||
freelocale(l); | |||
} | |||
#ifdef BOOSTER_LOCALE_WITH_ICONV | |||
{ | |||
locale_t l = newlocale(LC_ALL_MASK,ja_jp_shiftjis.c_str(),0); | |||
if(!l) | |||
test_sjis = false; | |||
else | |||
freelocale(l); | |||
} | |||
#else | |||
test_sjis = false; | |||
#endif | |||
} | |||
#endif | |||
test_utf = def[type]!="std" || (!get_std_name("en_US.UTF-8").empty() && !get_std_name("he_IL.UTF-8").empty()); | |||
@@ -299,12 +349,16 @@ int main() | |||
std::cout << " wchar_t" << std::endl; | |||
test_to<wchar_t>(); | |||
#ifdef BOOSTER_HAS_CHAR16_T | |||
std::cout << " char16_t" << std::endl; | |||
test_to<char16_t>(); | |||
if(bname == "icu" || bname == "std") { | |||
std::cout << " char16_t" << std::endl; | |||
test_to<char16_t>(); | |||
} | |||
#endif | |||
#ifdef BOOSTER_HAS_CHAR32_T | |||
std::cout << " char32_t" << std::endl; | |||
test_to<char32_t>(); | |||
if(bname == "icu" || bname == "std") { | |||
std::cout << " char32_t" << std::endl; | |||
test_to<char32_t>(); | |||
} | |||
#endif | |||
} | |||
} | |||
@@ -8,7 +8,7 @@ | |||
#ifndef BOOSTER_LOCALE_TEST_H | |||
#define BOOSTER_LOCALE_TEST_H | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <sstream> | |||
#include <iostream> | |||
#include <iomanip> | |||
@@ -22,7 +22,7 @@ int test_counter=0; | |||
#define THROW_IF_TOO_BIG(X) \ | |||
do { \ | |||
if((X) > 20) \ | |||
throw std::runtime_error("Error limits reached, stopping unit test"); \ | |||
throw booster::runtime_error("Error limits reached, stopping unit test"); \ | |||
}while(0) | |||
#define TEST(X) \ | |||
@@ -97,7 +97,7 @@ std::basic_string<Char> to(std::string const &utf8) | |||
if(sizeof(Char)==1 && point > 255) { | |||
std::ostringstream ss; | |||
ss << "Can't convert codepoint U" << std::hex << point <<"(" <<std::string(utf8.begin()+prev,utf8.begin()+i)<<") to Latin1"; | |||
throw std::runtime_error(ss.str()); | |||
throw booster::runtime_error(ss.str()); | |||
} | |||
else if(sizeof(Char)==2 && point >0xFFFF) { // Deal with surragates | |||
point-=0x10000; | |||
@@ -53,7 +53,10 @@ void test_char() | |||
std::cout << "Testing " << name << std::endl; | |||
std::locale l=gen(name); | |||
test_one<CharType>(l,"Hello World","hello world","HELLO WORLD"); | |||
test_one<CharType>(l,"Façade","façade","FAÇADE"); | |||
#ifdef __APPLE__ | |||
if(sizeof(CharType)!=1) | |||
#endif | |||
test_one<CharType>(l,"Façade","façade","FAÇADE"); | |||
} | |||
else { | |||
std::cout << "- en_US.ISO8859-1 is not supported, skipping" << std::endl; | |||
@@ -21,7 +21,7 @@ | |||
#include <stdio.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#ifdef BOOSTER_POSIX | |||
#include <syslog.h> | |||
@@ -242,7 +242,7 @@ namespace log { | |||
if(l=="notice") return notice; | |||
if(l=="info") return info; | |||
if(l=="debug") return debug; | |||
throw std::invalid_argument("Invalig logging level :" + l); | |||
throw booster::invalid_argument("Invalig logging level :" + l); | |||
} | |||
namespace sinks { | |||
@@ -306,7 +306,7 @@ namespace log { | |||
d->stream.open(file_name.c_str(),std::fstream::out); | |||
if(!d->stream) | |||
throw std::runtime_error("Failed to open file " + file_name); | |||
throw booster::runtime_error("Failed to open file " + file_name); | |||
} | |||
std::string file::format_file(std::string const &base,int n) | |||
{ | |||
@@ -21,8 +21,7 @@ | |||
#include <cppcms/defs.h> | |||
#include <string> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
namespace cppcms { | |||
/// | |||
@@ -31,7 +30,7 @@ namespace cppcms { | |||
/// Every exception that is thrown from CppCMS modules derived from this exception. | |||
/// | |||
class CPPCMS_API cppcms_error : public std::runtime_error { | |||
class CPPCMS_API cppcms_error : public booster::runtime_error { | |||
std::string strerror(int err); | |||
public: | |||
/// | |||
@@ -41,7 +40,7 @@ public: | |||
/// | |||
/// Create an object with message \a error | |||
/// | |||
cppcms_error(std::string const &error) : std::runtime_error(error) {}; | |||
cppcms_error(std::string const &error) : booster::runtime_error(error) {}; | |||
}; | |||
} | |||
@@ -21,12 +21,11 @@ | |||
#include <cppcms/defs.h> | |||
#include <booster/copy_ptr.h> | |||
#include <booster/backtrace.h> | |||
#include <vector> | |||
#include <map> | |||
#include <string> | |||
#include <iostream> | |||
#include <typeinfo> | |||
#include <limits> | |||
namespace cppcms { | |||
@@ -114,7 +113,7 @@ namespace json { | |||
/// When implementing json::traits for complex classes you are expected to throw this exception | |||
/// in case of invalid formatting | |||
/// | |||
class CPPCMS_API bad_value_cast : public std::bad_cast { | |||
class CPPCMS_API bad_value_cast : public booster::bad_cast { | |||
public: | |||
bad_value_cast(); | |||
bad_value_cast(std::string const &s); | |||
@@ -22,7 +22,7 @@ | |||
#include <cppcms/defs.h> | |||
#include <booster/copy_ptr.h> | |||
#include <string> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <booster/traits/enable_if.h> | |||
#include <booster/traits/is_base_of.h> | |||
@@ -57,9 +57,9 @@ namespace cppcms { | |||
/// | |||
/// Error thrown in case of serialization error | |||
/// | |||
class archive_error : public std::runtime_error { | |||
class archive_error : public booster::runtime_error { | |||
public: | |||
archive_error(std::string const &e) : std::runtime_error("cppcms::archive_error: " + e) | |||
archive_error(std::string const &e) : booster::runtime_error("cppcms::archive_error: " + e) | |||
{ | |||
} | |||
}; | |||
@@ -20,7 +20,7 @@ | |||
#include "aes.h" | |||
#include <cppcms/urandom.h> | |||
#include <cppcms/config.h> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include <string.h> | |||
@@ -162,26 +162,26 @@ namespace impl { | |||
virtual void encrypt(void const *in,void *out,unsigned len) | |||
{ | |||
if(len % 16 != 0) { | |||
throw std::invalid_argument("Invalid block size"); | |||
throw booster::invalid_argument("Invalid block size"); | |||
} | |||
if(gcry_cipher_encrypt(enc_,out,len,in,len)!=0) { | |||
throw std::runtime_error("Encryption failed"); | |||
throw booster::runtime_error("Encryption failed"); | |||
} | |||
} | |||
virtual void decrypt(void const *in,void *out,unsigned len) | |||
{ | |||
if(len % 16 != 0) { | |||
throw std::invalid_argument("Invalid block size"); | |||
throw booster::invalid_argument("Invalid block size"); | |||
} | |||
if(gcry_cipher_decrypt(enc_,out,len,in,len)!=0) { | |||
throw std::runtime_error("Decryption failed"); | |||
throw booster::runtime_error("Decryption failed"); | |||
} | |||
} | |||
private: | |||
void init(aes_type type,std::string const &key) | |||
{ | |||
if(key.size()*8!=unsigned(type)) { | |||
throw std::invalid_argument("Invalid key size"); | |||
throw booster::invalid_argument("Invalid key size"); | |||
} | |||
key_ = key; | |||
type_ = type; | |||
@@ -197,7 +197,7 @@ namespace impl { | |||
algo = GCRY_CIPHER_AES256; | |||
break; | |||
default: | |||
throw std::invalid_argument("Invalid encryption method"); | |||
throw booster::invalid_argument("Invalid encryption method"); | |||
} | |||
enc_ = 0; | |||
@@ -219,7 +219,7 @@ namespace impl { | |||
gcry_cipher_close(enc_); | |||
if(dec_) | |||
gcry_cipher_close(dec_); | |||
throw std::runtime_error("Failed to create AES encryptor"); | |||
throw booster::runtime_error("Failed to create AES encryptor"); | |||
} | |||
} | |||
@@ -247,7 +247,7 @@ namespace impl { | |||
openssl_aes_encryptor(aes_type type,std::string const &key) | |||
{ | |||
if(key.size()*8!=unsigned(type)) { | |||
throw std::invalid_argument("Invalid key size"); | |||
throw booster::invalid_argument("Invalid key size"); | |||
} | |||
AES_set_encrypt_key(reinterpret_cast<unsigned char const *>(key.c_str()), type, &key_enc_); | |||
AES_set_decrypt_key(reinterpret_cast<unsigned char const *>(key.c_str()), type, &key_dec_); | |||
@@ -261,7 +261,7 @@ namespace impl { | |||
virtual void encrypt(void const *in,void *out,unsigned len) | |||
{ | |||
if(len % 16 != 0) { | |||
throw std::invalid_argument("Invalid block size"); | |||
throw booster::invalid_argument("Invalid block size"); | |||
} | |||
AES_cbc_encrypt(reinterpret_cast<unsigned char const *>(in), | |||
reinterpret_cast<unsigned char *>(out), len, | |||
@@ -272,7 +272,7 @@ namespace impl { | |||
virtual void decrypt(void const *in,void *out,unsigned len) | |||
{ | |||
if(len % 16 != 0) { | |||
throw std::invalid_argument("Invalid block size"); | |||
throw booster::invalid_argument("Invalid block size"); | |||
} | |||
AES_cbc_encrypt(reinterpret_cast<unsigned char const *>(in), | |||
reinterpret_cast<unsigned char *>(out), len, | |||
@@ -142,7 +142,7 @@ | |||
// "multipart_form_data_limit" : 65536, // KB | |||
// "content_length_limit" : 1024, // KB | |||
// "uploads_path" : "" // temporary directory | |||
//"display_error_message" : true | |||
"display_error_message" : true | |||
} | |||
} |
@@ -30,7 +30,7 @@ using namespace std; | |||
namespace cppcms { | |||
cppcms_error::cppcms_error(int err,std::string const &error) : | |||
std::runtime_error(error+":" + strerror(err)) | |||
booster::runtime_error(error+":" + strerror(err)) | |||
{ | |||
} | |||
@@ -26,7 +26,7 @@ | |||
# include <openssl/sha.h> | |||
#endif | |||
#include <vector> | |||
#include <stdexcept> | |||
#include <booster/backtrace.h> | |||
#include "md5.h" | |||
#include "sha1.h" | |||
@@ -126,7 +126,7 @@ namespace cppcms { | |||
gcrypt_digets(int algorithm) | |||
{ | |||
if(gcry_md_open(&state_,algorithm,0)!=0) | |||
throw std::invalid_argument("gcrypt_digets - faled to create md"); | |||
throw booster::invalid_argument("gcrypt_digets - faled to create md"); | |||
algo_ = algorithm; | |||
} | |||
virtual unsigned digest_size() const | |||
@@ -290,7 +290,7 @@ namespace cppcms { | |||
hmac::hmac(std::auto_ptr<message_digest> digest,std::string const &key) | |||
{ | |||
if(!digest.get()) | |||
throw std::invalid_argument("Has algorithm is not provided"); | |||
throw booster::invalid_argument("Has algorithm is not provided"); | |||
md_ = digest; | |||
md_opad_.reset(md_->clone()); | |||
init(key); | |||
@@ -299,7 +299,7 @@ namespace cppcms { | |||
{ | |||
md_ = message_digest::create_by_name(name); | |||
if(!md_.get()) { | |||
throw std::invalid_argument("Invalid or unsupported hash function:" + name); | |||
throw booster::invalid_argument("Invalid or unsupported hash function:" + name); | |||
} | |||
md_opad_.reset(md_->clone()); | |||
init(key); | |||
@@ -333,14 +333,14 @@ namespace cppcms { | |||
unsigned hmac::digest_size() const | |||
{ | |||
if(!md_.get()){ | |||
throw std::runtime_error("Hmac can be used only once"); | |||
throw booster::runtime_error("Hmac can be used only once"); | |||
} | |||
return md_->digest_size(); | |||
} | |||
void hmac::append(void const *ptr,size_t size) | |||
{ | |||
if(!md_.get()){ | |||
throw std::runtime_error("Hmac can be used only once"); | |||
throw booster::runtime_error("Hmac can be used only once"); | |||
} | |||
md_->append(ptr,size); | |||
} | |||
@@ -477,6 +477,7 @@ int main(int argc,char **argv) | |||
} | |||
catch(std::exception const &e) { | |||
std::cerr<<"Catched exception: "<<e.what()<<std::endl; | |||
std::cerr<<booster::trace(e) << std::endl; | |||
return 1; | |||
} | |||
return 0; | |||
@@ -30,6 +30,7 @@ | |||
#include <cppcms/session_interface.h> | |||
#include <cppcms/cppcms_error.h> | |||
#include <booster/log.h> | |||
#include <booster/backtrace.h> | |||
#include "cached_settings.h" | |||
@@ -141,11 +142,15 @@ void context::dispatch(booster::intrusive_ptr<application> app,std::string url,b | |||
app->main(url); | |||
} | |||
catch(std::exception const &e){ | |||
BOOSTER_ERROR("cppcms") << "Caught exception ["<<e.what()<<"]"; | |||
BOOSTER_ERROR("cppcms") << "Caught exception ["<<e.what()<<"]\n" << booster::trace(e) ; | |||
if(app->get_context()) { | |||
if(!app->response().some_output_was_written()) { | |||
if(app->service().cached_settings().security.display_error_message) | |||
app->response().make_error_response(http::response::internal_server_error,e.what()); | |||
if(app->service().cached_settings().security.display_error_message) { | |||
std::ostringstream ss; | |||
ss << e.what() << '\n'; | |||
ss << booster::trace(e); | |||
app->response().make_error_response(http::response::internal_server_error,ss.str()); | |||
} | |||
else | |||
app->response().make_error_response(http::response::internal_server_error); | |||
} | |||
@@ -1,8 +1,8 @@ | |||
#!/bin/bash | |||
# | |||
# rm -fr trunk | |||
# svn export https://cppcms.svn.sourceforge.net/svnroot/cppcms/boost_locale/branches/rework trunk | |||
rm -fr trunk | |||
svn export https://cppcms.svn.sourceforge.net/svnroot/cppcms/boost_locale/trunk | |||
# | |||
rm -fr boost_locale | |||
@@ -13,12 +13,12 @@ cp -a trunk boost_locale | |||
# | |||
# Linux version | |||
# | |||
#find boost_locale -name '*.hpp' -exec rename 's/\.hpp/\.h/' '{}' \; | |||
find boost_locale -name '*.hpp' -exec rename 's/\.hpp/\.h/' '{}' \; | |||
# | |||
# Cygwin version | |||
# | |||
find boost_locale -name '*.hpp' -exec rename .hpp .h '{}' \; | |||
#find boost_locale -name '*.hpp' -exec rename .hpp .h '{}' \; | |||
# | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/_HPP_INCLUDED/_H_INCLUDED/' '{}' \; | |||
@@ -28,6 +28,10 @@ find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/BOOSTER_LOCALE_DECL/BOOSTER_API/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/BOOSTER_LOCALE_SOURCE/BOOSTER_SOURCE/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/BOOSTER_WINDOWS/BOOSTER_WIN_NATIVE/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/<stdexcept>/<booster\/backtrace.h>/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/std::runtime_error/booster::runtime_error/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/std::out_of_range/booster::out_of_range/' '{}' \; | |||
find boost_locale -regextype posix-extended -regex '.*\.(cpp|h)' -exec sed -i 's/std::invalid_argument/booster::invalid_argument/' '{}' \; | |||
sed -i 's/BOOST_VERSION >= 103600/0/' boost_locale/libs/locale/src/shared/message.cpp | |||