Exemplo n.º 1
0
 bool Vector3f::AnyGreaterEqual(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f temp = other - Vector3f(epsilon);
         return temp.x >= epsilon || temp.y >= epsilon || temp.z >= epsilon;
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 2
0
 bool Vector3f::AllLessEqual(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f temp = other + Vector3f(epsilon);
         return (x <= temp.x && y <= temp.y && z <= temp.z);
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 3
0
 bool Vector3f::AllGreater(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f temp = other - Vector3f(epsilon);
         return (x > temp.x && y > temp.y && z > temp.z);
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 4
0
 bool Vector2f::AnyLess(const Vector2f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector2f temp = other + epsilon;
         return x < temp.x || y < temp.y;
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 5
0
 bool Vector3f::AllEqual(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f diff = Abs(*this - other);
         return (diff.x <= epsilon && diff.y <= epsilon && diff.z <= epsilon);
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 6
0
 bool Vector2f::AnyGreaterEqual(const Vector2f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector2f temp = other - epsilon;
         return x >= temp.x || y >= temp.y;
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 7
0
void BoundingSphere::SetRadius(F32 radius) {
    if (radius > 0.0f) {
        this->radius = radius;
    } else {
        string message = format("Invalid radius value '%f'", radius);
        throw InvalidArgumentException(message);
    }
}
Exemplo n.º 8
0
void SerialConfigImpl::setParityImpl(SerialConfigImpl::ParityImpl parity)
{
	switch (parity)
	{
	case PARITY_NONE_IMPL:
		return setParityCharImpl('N');
	case PARITY_ODD_IMPL:
		return setParityCharImpl('O');
	case PARITY_EVEN_IMPL:
		return setParityCharImpl('E');
	case PARITY_MARK_IMPL:
	default:
		throw InvalidArgumentException();
	}

	throw InvalidArgumentException("Wrong parity.");
}
Exemplo n.º 9
0
RawSocket& RawSocket::operator = (const Socket& socket)
{
	if (dynamic_cast<RawSocketImpl*>(socket.impl()))
		Socket::operator = (socket);
	else
		throw InvalidArgumentException("Cannot assign incompatible socket");
	return *this;
}
Exemplo n.º 10
0
 bool Vector3f::AnyLess(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f temp = other + Vector3f(epsilon);
         return temp.x < epsilon || temp.y < epsilon || temp.z < epsilon;
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 11
0
 bool Vector3f::AnyNotEqual(const Vector3f& other, F32 epsilon /*= Epsilon*/) const {
     if (epsilon >= 0.0f) {
         Vector3f diff = Abs(*this - other);
         return diff.x > epsilon || diff.y > epsilon;
     } else {
         throw InvalidArgumentException("epsilon");
     }
 }
Exemplo n.º 12
0
void FileChannel::setPurgeAge(const std::string& age)
{
	delete _pPurgeStrategy;
	_pPurgeStrategy = 0;
	_purgeAge = "none";
	if (age.empty() || 0 == icompare(age, "none"))
		return;

	std::string::const_iterator it = age.begin();
	std::string::const_iterator end = age.end();

	int n = 0;
	while (it != end && Ascii::isSpace(*it))
		++it;
	while (it != end && Ascii::isDigit(*it))
	{
		n *= 10;
		n += *it++ - '0';
	}
	while (it != end && Ascii::isSpace(*it))
		++it;
	std::string unit;
	while (it != end && Ascii::isAlpha(*it))
		unit += *it++;
	
	Timespan::TimeDiff factor = Timespan::SECONDS;
	if (unit == "minutes")
		factor = Timespan::MINUTES;
	else if (unit == "hours")
		factor = Timespan::HOURS;
	else if (unit == "days")
		factor = Timespan::DAYS;
	else if (unit == "weeks")
		factor = 7*Timespan::DAYS;
	else if (unit == "months")
		factor = 30 * Timespan::DAYS;
	else if (unit != "seconds")
		throw InvalidArgumentException("purgeAge", age);

	if (0 == n)
		throw InvalidArgumentException("Zero is not valid purge age.");

	_pPurgeStrategy = new PurgeByAgeStrategy(Timespan(factor * n));
	_purgeAge = age;
}
Exemplo n.º 13
0
int ICMPEventArgs::replyTime(int index) const
{
	if (0 == _rtt.size()) 
		throw InvalidArgumentException("Supplied index exceeds array capacity.");

	if (-1 == index) index = _sent - 1;

	return _rtt[index];
}
Exemplo n.º 14
0
const std::string& ICMPEventArgs::error(int index) const
{
	if (0 == _errors.size()) 
		throw InvalidArgumentException("Supplied index exceeds vector capacity.");

	if (-1 == index) index = _sent - 1;

	return _errors[index];
}
Exemplo n.º 15
0
String StringUtil::Translate(CStrRef input, CStrRef from, CStrRef to) {
  if (input.empty()) return input;

  if (from.empty()) {
    throw InvalidArgumentException("from", "(empty)");
  }
  if (from.size() != to.size()) {
    throw InvalidArgumentException("from and to", "(different sizes)");
  }

  int len = input.size();
  char *ret = (char *)malloc(len + 1);
  memcpy(ret, input, len);
  ret[len] = '\0';

  string_translate(ret, len, from, to, from.size());
  return String(ret, len, AttachString);
}
Exemplo n.º 16
0
    AppearanceDataIC ICAAMModel::getModel(int scale) const
    {
        if (scale < 0 || scale >= this->modelData.size())
        {
            throw InvalidArgumentException();
        }

        return this->modelData[scale];
    }
Query::Query(const Var& source): _source(source)
{
	if (!source.isEmpty() &&
		source.type() != typeid(Object) &&
		source.type() != typeid(Object::Ptr) &&
		source.type() != typeid(Array) &&
		source.type() != typeid(Array::Ptr))
		throw InvalidArgumentException("Only JSON Object, Array or pointers thereof allowed.");
}
Exemplo n.º 18
0
DynamicAny DynamicAny::operator -- (int)
{
	if (!isInteger())
		throw InvalidArgumentException("Invalid operation for this data type.");

	DynamicAny tmp(*this);
	*this -= 1;
	return tmp;
}
Exemplo n.º 19
0
int SerialChannelImpl::readImpl(char*& pBuffer)
{
	if (!_pConfig->getUseEOFImpl())
		throw InvalidAccessException();

	int bufSize = _pConfig->getBufferSizeImpl();
	int it = 1;

	if ((0 == bufSize) || (0 != pBuffer))
		throw InvalidArgumentException();

	std::string buffer;
	DWORD read = 0;
	DWORD readCount = 0;

	pBuffer = static_cast<char*>(std::calloc(bufSize, sizeof(char)));//! freed in parent call

	do
    {
		if (_leftOver.size())
		{
			read = _leftOver.size() > bufSize - readCount ? bufSize - readCount : _leftOver.size();
			std::memcpy(pBuffer + readCount, _leftOver.data(), read);
			if (read == _leftOver.size())
				_leftOver.clear();
			else
				_leftOver.assign(_leftOver, read, _leftOver.size() - read);
		}
		else
		{
			if (!ReadFile(_handle, pBuffer + readCount, bufSize - readCount, &read, NULL)) 
				handleError(_pConfig->name());
			else if (0 == read) break;
		}

		poco_assert (read <= bufSize - readCount);
		
		buffer.assign(static_cast<char*>(pBuffer + readCount), read);
		size_t pos = buffer.find(_pConfig->getEOFCharImpl());
		if (pos != buffer.npos)
		{
			readCount += static_cast<DWORD>(pos);
			PurgeComm(_handle, PURGE_RXCLEAR);
			_leftOver.assign(buffer, pos + 1, buffer.size() - pos - 1);
			break;
		}

		readCount += read;
		if (readCount >= bufSize)
		{
			bufSize *= ++it;
			pBuffer = static_cast<char*>(std::realloc(pBuffer, bufSize * sizeof(char)));
		}
	}while(true);

	return readCount;
}
Exemplo n.º 20
0
void Preparator::freeMemory() const
{
	IndexMap::iterator it = _varLengthArrays.begin();
	IndexMap::iterator end = _varLengthArrays.end();
	for (; it != end; ++it)
	{
		switch (it->second)
		{
			case DT_BOOL:
				deleteCachedArray<bool>(it->first);
				break;

			case DT_CHAR:
				deleteCachedArray<char>(it->first);
				break;

			case DT_WCHAR:
				deleteCachedArray<UTF16String>(it->first);
				break;

			case DT_UCHAR:
				deleteCachedArray<unsigned char>(it->first);
				break;

			case DT_CHAR_ARRAY:
			{
				char** pc = AnyCast<char*>(&_values[it->first]);
				if (pc) std::free(*pc);
				break;
			}

			case DT_WCHAR_ARRAY:
			{
				UTF16String::value_type** pc = AnyCast<UTF16String::value_type*>(&_values[it->first]);
				if (pc) std::free(*pc);
				break;
			}

			case DT_UCHAR_ARRAY:
			{
				unsigned char** pc = AnyCast<unsigned char*>(&_values[it->first]);
				if (pc) std::free(*pc);
				break;
			}

			case DT_BOOL_ARRAY:
			{
				bool** pb = AnyCast<bool*>(&_values[it->first]);
				if (pb) std::free(*pb);
				break;
			}

			default:
				throw InvalidArgumentException("Unknown data type.");
		}
	}
}
Exemplo n.º 21
0
const Any& GraphicsEngine::GetEnvVariable(const std::string& name) {
	auto it = m_envVariables.find(name);
	if (it != m_envVariables.end()) {
		return it->second;
	}
	else {
		throw InvalidArgumentException("Environment variable does not exist.");
	}
}
Exemplo n.º 22
0
SocketStreamBuf::SocketStreamBuf(const Socket& socket): 
	BufferedBidirectionalStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out),
	_pImpl(dynamic_cast<StreamSocketImpl*>(socket.impl()))
{
	if (_pImpl)
		_pImpl->duplicate(); 
	else
		throw InvalidArgumentException("Invalid or null SocketImpl passed to SocketStreamBuf");
}
Exemplo n.º 23
0
void StringData::attach(char *data, int len) {
  if (uint32_t(len) > MaxSize) {
    throw InvalidArgumentException("len>=2^30", len);
  }
  releaseData();
  m_len = len;
  m_data = data;
  m_big.cap = len | IsMalloc;
}
Exemplo n.º 24
0
int Array::getType(size_t pos) const
{
	if (_elements.isNull()) throw NullValueException();

	if (pos >= _elements.value().size()) throw InvalidArgumentException();

	RedisType::Ptr element = _elements.value().at(pos);
	return element->type();
}
Exemplo n.º 25
0
ICMPPacket::ICMPPacket(IPAddress::Family family, int dataSize):_pImpl(0)
{
	if (family == IPAddress::IPv4)
		_pImpl = new ICMPv4PacketImpl(dataSize);
#if POCO_HAVE_IPv6
	else if (family == IPAddress::IPv6)
		throw NotImplementedException("ICMPv6 packets not implemented.");
#endif
	else throw InvalidArgumentException("Invalid or unsupported address family passed to ICMPPacket");
}
Exemplo n.º 26
0
UserStreamWrapper::UserStreamWrapper(const String& name,
                                     const String& clsname,
                                     int flags)
    : m_name(name) {
  m_cls = Unit::loadClass(clsname.get());
  if (!m_cls) {
    throw InvalidArgumentException(0, "Undefined class '%s'", clsname.data());
  }
  m_isLocal = !(flags & k_STREAM_IS_URL);
}
Exemplo n.º 27
0
UserStreamWrapper::UserStreamWrapper(CStrRef name, CStrRef clsname) :
  m_name(name) {
  m_cls = Unit::loadClass(clsname.get());
  if (!m_cls) {
    throw InvalidArgumentException(0, "Undefined class '%s'", clsname.data());
  }
  // There is a third param in Zend to stream_wrapper_register() which could
  // affect that when we add that param
  m_isLocal = true;
}
Exemplo n.º 28
0
const Func* UserFSNode::lookupMethod(const StringData* name) {
  const Func* f = m_cls->lookupMethod(name);
  if (!f) return nullptr;

  if (f->attrs() & AttrStatic) {
    throw InvalidArgumentException(0, "%s::%s() must not be declared static",
                                   m_cls->name()->data(), name->data());
  }
  return f;
}
Exemplo n.º 29
0
    Vector3f Vector3f::Normalize(const Vector3f& v) {
        F32 length = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);

        if (!Equal(length, 0.0f)) {
            return Vector3f(v.x / length, v.y / length, v.z / length);
        } else {
            throw InvalidArgumentException("vector");
        }
            
    }
Exemplo n.º 30
0
ViewPtr<plugin::Api> Simulation::requirePlugin(const String& name)
{
    // Load plugin
    auto api = loadPlugin(name);

    if (api)
        return api;

    throw InvalidArgumentException("Plugin '" + name + "' not found");
}