예제 #1
0
static bool 
validateDateFormat(const String& relDate)
{
	bool result = false;
	boost::smatch what;
	//static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");
	try {
		const boost::regex e("(\\d{1,4})([Y|y|M|m|W|w|D|d])");
		

		result =  boost::regex_match(relDate, what, e);
	}
	catch (std::exception& ex)
	{
		THROW_MSG(DateTimeText::instance().invalidDateString(relDate, ex.what()));
	}
	if (result){
		CPPUNIT_ASSERT(3 == what.size());
		String whole = what[0];
		String quantity = what[1];
		String unit = what[2];
	 
		std::cout << "whole: " << whole <<
			" qauntity: " << quantity << 
			" unit: " << unit << std::endl;
      
	  

	}
	return result;
}
예제 #2
0
void
ProgramOptions::validate() const
{
	SetString missing;
	 
	for (OptionGroupMap::const_iterator it = groups.begin();
		it != groups.end();
		++it){
			findMissingOptions(it->second, missing);
			 
	}
	Size sz = missing.size();
	if (sz  > 0 )
	{
		String buffer;
		std::stringstream ss(buffer);
		Size index = 0;
		for (SetString::const_iterator it = missing.begin(); it != missing.end(); ++it){
			ss << *it;
			if (index + 1 < sz)
				ss << ",";
			++index;
		}

		THROW_MSG(CoreText::instance().missingOption(ss.str()));
	}

}
예제 #3
0
// throw if out of int range
inline unsigned strtou_complete_exact(char const* s, int base = 10) {
  unsigned long l = strtoul_complete(s, base);
  if (l < std::numeric_limits<unsigned>::min() || l > std::numeric_limits<unsigned>::max())
    THROW_MSG(string_to_exception, "Out of range for unsigned " UINTRANGE_STR ": '" << s << "'");
  CLANG_DIAG_ON(tautological-compare)
  return l;
}
예제 #4
0
void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) {
  RawBytecodeStream bcs(method);
  while (!bcs.is_last_bytecode()) {
    Bytecodes::Code opcode = bcs.raw_next();
    switch (opcode) {
      case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break;

      case Bytecodes::_istore:
      case Bytecodes::_lstore:
      case Bytecodes::_fstore:
      case Bytecodes::_dstore:
      case Bytecodes::_astore:
        if (bcs.get_index() != 0) continue;

        // fall through
      case Bytecodes::_istore_0:
      case Bytecodes::_lstore_0:
      case Bytecodes::_fstore_0:
      case Bytecodes::_dstore_0:
      case Bytecodes::_astore_0:
        THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
                  "can't overwrite local 0 in Object.<init>");
        break;
    }
  }
}
예제 #5
0
const OptionGroup&
ProgramOptions::getGroup(const String& groupName) const
{
	OptionGroupMap::const_iterator it = groups.find(groupName);
	if (it != groups.end()){
		return it->second;
	}
	THROW_MSG(CoreText::instance().objectNotFound(groupName));
}
예제 #6
0
inline I atoi_fast_complete(It begin, It end) {
  It i = begin;
  I r = atoi_fast_advance<I>(i, end);
  if (i != end)
    THROW_MSG(string_to_exception, "ascii to int incomplete - only used first "
                                       << i - begin << " characters of '" << putChars(begin, end) << "' => "
                                       << r << " - trim whitespace too");
  return r;
}
예제 #7
0
void
ProgramOptions::remove(const String& groupName)
{
	OptionGroupMap::iterator it = groups.find(groupName);
	if (it != groups.end()){
		groups.erase(it);
		return;
	}
	THROW_MSG(CoreText::instance().objectNotFound(groupName));
}
예제 #8
0
Float parse_real(char const* cstr, bool require_complete = true) {
  CstrCursor str(cstr);
  if (require_complete) {
    Float r = scan_real<Float>(str);
    if (str)
      THROW_MSG(string_to_exception, "conversion to real number from '"
                                         << cstr << "' leaves unused characters " << str.p);
    return r;
  } else
    return scan_real<Float>(str);
}
예제 #9
0
Float parse_real(char const* p, char const* end, bool require_complete = true) {
  StrCursor str(p, end);
  if (require_complete) {
    Float r = scan_real<Float>(str);
    if (str)
      THROW_MSG(string_to_exception, "conversion to real number from '" << putChars(p, end)
                                                                        << "' leaves unused characters "
                                                                        << putChars(str.p, end));
    return r;
  } else
    return scan_real<Float>(str);
}
예제 #10
0
static void CM_VARARGS error_Handler(CMErrorNbr errorNumber, ...)
#endif
{
	va_list inserts;
	char errorString[256];

	va_start(inserts, errorNumber);
	CMVGetErrorString(errorString, 256, errorNumber, inserts);
	va_end(inserts);

	THROW_MSG(kODErrBentoErr, errorString);
}
예제 #11
0
inline U atou_fast_advance_nooverflow(I& i, I end) {
  typedef typename std::iterator_traits<I>::value_type Char;
  I begin = i;
  const U maxTenth = boost::integer_traits<U>::const_max / 10;
  U x = 0;
  if (i == end) return x;
  for (; i != end; ++i) {
    const Char c = *i;
    if (c < '0' || c > '9') return x;
    if (x > maxTenth)
      THROW_MSG(string_to_exception, "ascii to unsigned overflow on char "
                                         << c << " in '" << putChars(begin, end) << "': " << x << "*10 > "
                                         << boost::integer_traits<U>::const_max);
    x *= 10;
    U prev = x;
    x += c - '0';
    if (x < prev)
      THROW_MSG(string_to_exception, "ascii to unsigned overflow on char "
                                         << c << " in '" << putChars(begin, end) << "': " << prev
                                         << " * 10 + " << c << " => (overflow) " << x);
  }
  return x;
}
예제 #12
0
inline long strtol_complete(char const* s, int base = 0) {
  char* e;
  if (*s) {
    long r = strtol(s, &e, base);
    char c = *e;
    if (!c || std::isspace(c))  // simplifying assumption: we're happy if there's other stuff in the string,
      // so long as the number ends in a space or eos. TODO: loop consuming spaces
      // until end?
      return r;
    THROW_MSG(string_to_exception, "integer from string '" << s << "' => " << r << " had extra chars: '" << e
                                                           << "'");
  }
  // empty string => 0
  return 0;
}
예제 #13
0
void
RelativeDateUnitTest::test_operators_general_invalid()
{
	RelativeDateUnit d1("1M");
	RelativeDateUnit d2("1Y");

	try {
		if (d1 == d2)
			THROW_MSG(CoreText::instance().reviewImplementation());
	}
	catch (BaseException& ex)
	{
		std::cout << "Expected exception (Invalid date comparison): " << ex.what() << std::endl;
	}
}
예제 #14
0
inline U octaltou(char const* begin, char const* end, bool complete = true) {
  char const* p = begin;
  U x = 0;
  for (;;) {
    if (*p >= '0' && *p <= '7') {
      x *= 8;
      x += *p - '0';
    } else {
      if (complete)
        THROW_MSG(string_to_exception, "hexidecimal string '" << putChars(begin, end)
                                                              << "' had extra characters - value so far is "
                                                              << x);
      return x;
    }
    if (++p == end) return x;
  }
}
예제 #15
0
// FIXME: preprocessor separation for tokens int<->unsigned, long<->unsigned long, strtol<->strtoul ? massive
// code duplication
inline unsigned long strtoul_complete(char const* s, int base = 0) {
  unsigned long r;
  if (*s) {
#if GRAEHL_HAVE_STRTOUL
    char* e;
    r = strtoul(s, &e, base);
    char c = *e;
    if (!c || std::isspace(c))  // simplifying assumption: we're happy if there's other stuff in the string,
      // so long as the number ends in a space or eos. TODO: loop consuming spaces
      // until end?
      return r;
#else
    int nchars;
    // unsigned long r=strtol(s, &e, base); //FIXME: not usually safe
    if (sscanf(s, "%lu%n", &r, &nchars) && s[nchars] == '\0') return r;
#endif
  }
  THROW_MSG(string_to_exception, "can't get integer from '" << s << "'");
  return 0;  // quiet, warning!
}
예제 #16
0
void GCNotifier::sendNotificationInternal(TRAPS) {
  ResourceMark rm(THREAD);
  HandleMark hm(THREAD);
  GCNotificationRequest *request = getRequest();
  if (request != NULL) {
    NotificationMark nm(request);
    Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);

    Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
    Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
    Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);

    Klass* k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
    instanceKlassHandle gc_mbean_klass(THREAD, k);

    instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
    instanceHandle gc_mbean_h(THREAD, gc_mbean);
    if (!gc_mbean_h->is_a(k)) {
      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
                "This GCMemoryManager doesn't have a GarbageCollectorMXBean");
    }

    JavaValue result(T_VOID);
    JavaCallArguments args(gc_mbean_h);
    args.push_long(request->timestamp);
    args.push_oop(objName);
    args.push_oop(objAction);
    args.push_oop(objCause);
    args.push_oop(objGcInfo);

    JavaCalls::call_virtual(&result,
                            gc_mbean_klass,
                            vmSymbols::createGCNotification_name(),
                            vmSymbols::createGCNotification_signature(),
                            &args,
                            CHECK);
  }
}
예제 #17
0
void Klass::check_valid_for_instantiation(bool throwError, TRAPS) {
  ResourceMark rm(THREAD);
  THROW_MSG(throwError ? vmSymbols::java_lang_InstantiationError()
            : vmSymbols::java_lang_InstantiationException(), external_name());
}
예제 #18
0
// throw if out of int range
inline int strtoi_complete_exact(char const* s, int base = 10) {
  long l = strtol_complete(s, base);
  if (l < std::numeric_limits<int>::min() || l > std::numeric_limits<int>::max())
    THROW_MSG(string_to_exception, "Out of range for int " INTRANGE_STR ": '" << s << "'");
  return l;
}
예제 #19
0
void ClassFileStream::truncated_file_error(TRAPS) {
  THROW_MSG(vmSymbols::java_lang_ClassFormatError(), "Truncated class file");
}