Exemplo n.º 1
0
	void Buffer::BlockCopy(T src[], int srcOffset, T dst[], int dstOffset, int count)
	{
		if (src == null)
			throw ArgumentNullException("src");

		if (dst == null)
			throw ArgumentNullException("dst");

		if (srcOffset < 0)
			throw ArgumentOutOfRangeException("srcOffset", "Non-negative number required.");

		if (dstOffset < 0)
			throw ArgumentOutOfRangeException("dstOffset", "Non-negative number required.");

		if (count < 0)
			throw ArgumentOutOfRangeException("count", "Non-negative number required.");
		
		if ((srcOffset > ByteLength(src) - count) || (dstOffset > ByteLength(dst) - count))
				throw ArgumentException("Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.");

		for(int i = srcOffset, j = dstOffset; i < (srcOffset + count); i++, j++)
		{
			dst[j] = src[i];
		}
	}
Exemplo n.º 2
0
	PhysicsComponent::PhysicsComponent(PhysicsManager* physManager, btCollisionShape* collisionShape,
			const btVector3& COG, float objMass)
			: body(nullptr), cShape(collisionShape), absoluteCShape(nullptr),
				mass(objMass), absoluteMass(objMass),
				cog(COG), absoluteCOG(COG), physMan(physManager)
	{
		if(physManager == nullptr)
			throw ArgumentNullException("The physics manager cannot be null.", __FUNCTION__);

		if(collisionShape == nullptr)
			throw ArgumentNullException("Each physics component must be given a collision shape");

		// Allow this collision shape to be traced back to us
		collisionShape->setUserPointer(owner);
	}
Exemplo n.º 3
0
void Window::ElementSetMouseCursor(UIElement* element)
{
	if (element == nullptr)
	{
		raise(ArgumentNullException());
	}

	if (element->get_IsMouseDirectlyOver())
	{
		Cursor* pCursor = element->get_Cursor();
		if (pCursor)
		{
			::SetCursor(pCursor->GetHCursor());

			if (!showCursor)
			{
				showCursor = true;
				::ShowCursor(TRUE);
			}
		}
		else
		{
			if (showCursor)
			{
				::ShowCursor(FALSE);
				showCursor = false;
			}
		}
	}
}
    void MemoryStream::Write(ByteArray& buffer, int32 offset, int32 count)
      {
      if(buffer.IsNull())
        throw ArgumentNullException(L"buffer");

      if (offset < 0 || count < 0)
        throw ArgumentOutOfRangeException ();

      if((int32)buffer.Length() - offset < count)
        throw ArgumentException(L"offset+count", L"The size of the buffer is less than offset + count.");

      CheckIfClosedThrowDisposed ();

      if(!CanWrite())
        throw NotSupportedException(L"Cannot write to this stream.");

      // reordered to avoid possible integer overflow
      if(_position > _length - count)
        Expand(_position + count);

      Buffer::BlockCopy(buffer, offset, (*_internalBuffer), _position, count);
      _position += count;
      if(_position >= _length)
        _length = _position;
      }
JointLimitParameters::JointLimitParameters(PxJointLimitParameters* parameters)
{
	if (parameters == NULL)
		throw gcnew ArgumentNullException("parameters");

	_parameters = parameters;
}
Exemplo n.º 6
0
		String::StringIterator::StringIterator(const String* string) :
			_string(string)
		{
			if (!string) {
				throw ArgumentNullException();
			}
		}
Exemplo n.º 7
0
BatchQuery::BatchQuery(PxBatchQuery* batchQuery)
{
	if (batchQuery == NULL)
		throw gcnew ArgumentNullException("batchQuery");

	_batchQuery = batchQuery;
}
Exemplo n.º 8
0
CStdFile::CStdFile(FILE* fp) : m_fp(fp)
{
	if (fp == NULL)
	{
		raise(ArgumentNullException());
	}
}
Exemplo n.º 9
0
		String& String::operator=(const char* string)
		{
			// check argument
			if (!string) {
				throw ArgumentNullException("source string must have a valid value");
			}

			// variables 
			int length = strlen(string);

			// check if capacity is big enough
			if (_capacity >= length) {
				// set new values
				strncpy(_data, string, length);
				_data[length] = 0;
				_length = length;
			} else {
				// reallocate buffer
				delete[] _data;
				_data = new char[length + 1];

				// set new values
				strncpy(_data, string, length);
				_data[length] = 0;
				_length = _capacity = length;
			}

			return (*this);
		}
 void BitArray::CheckOperand(BitArray& operand)
   {
   if(&operand == nullptr)
     throw ArgumentNullException();
   if(operand._length != _length)
     throw ArgumentException ();
   }
SerializationRegistry::SerializationRegistry(PxSerializationRegistry* serializationRegistry)
{
	if (serializationRegistry == NULL)
		throw gcnew ArgumentNullException("serializationRegistry");

	_serializationRegistry = serializationRegistry;
}
Exemplo n.º 12
0
    System::Object^ VowpalWabbitDynamicPredictionFactory::Create(vw* vw, example* ex)
    {
        if (ex == nullptr)
            throw gcnew ArgumentNullException("ex");

        switch (vw->l->pred_type)
        {
        case prediction_type::scalar:
            return VowpalWabbitPredictionType::Scalar->Create(vw, ex);
        case prediction_type::scalars:
            return VowpalWabbitPredictionType::Scalars->Create(vw, ex);
        case prediction_type::multiclass:
            return VowpalWabbitPredictionType::Multiclass->Create(vw, ex);
        case prediction_type::multilabels:
            return VowpalWabbitPredictionType::Multilabel->Create(vw, ex);
        case prediction_type::action_scores:
            return VowpalWabbitPredictionType::ActionScore->Create(vw, ex);
        case prediction_type::prob:
            return VowpalWabbitPredictionType::Probability->Create(vw, ex);
        case prediction_type::multiclassprobs:
            return VowpalWabbitPredictionType::MultiClassProbabilities->Create(vw, ex);
        default:
        {
            auto sb = gcnew StringBuilder();
            sb->Append("Unsupported prediction type: ");
            sb->Append(gcnew String(prediction_type::to_string(vw->l->pred_type)));
            throw gcnew ArgumentException(sb->ToString());
        }
        }
    }
Exemplo n.º 13
0
    MemoryStream::MemoryStream(const SharedPtr<ByteArray>& buffer, int32 index, int32 count, bool writable, bool publiclyVisible)
      :_streamClosed(false)
      ,_dirty_bytes(0)
      {
      if(buffer->IsNull())
        throw ArgumentNullException(L"buffer");

      InternalConstructor(buffer, index, count, writable, publiclyVisible);
      }
Exemplo n.º 14
0
    MemoryStream::MemoryStream(const SharedPtr<ByteArray>& buffer, bool writable)
      :_streamClosed(false)
      ,_dirty_bytes(0)
      {
      if(buffer->IsNull())
        throw ArgumentNullException(L"buffer");

      InternalConstructor(buffer, 0, (int32)buffer->Length(), writable, false);
      }
Exemplo n.º 15
0
    cli::array<float>^ VowpalWabbitTopicPredictionFactory::Create(vw* vw, example* ex)
    {
        if (ex == nullptr)
            throw gcnew ArgumentNullException("ex");

        auto values = gcnew cli::array<float>(vw->lda);
        Marshal::Copy(IntPtr(ex->pred.scalars.begin()), values, 0, vw->lda);

        return values;
    }
Exemplo n.º 16
0
JointLimitParameters^ JointLimitParameters::ToManaged(PxJointLimitParameters* parameters)
{
	if (parameters == NULL)
		throw gcnew ArgumentNullException("parameters");

	JointLimitParameters^ p = gcnew JointLimitParameters();
	
	p->PopulateManaged(parameters);

	return p;
}
Exemplo n.º 17
0
HisDevValueEmail::HisDevValueEmail(xmlNodePtr node,
			IWriteToDevice* deviceWriter,
			IHisDevFactory* factory) :
					HisDevValue::HisDevValue(node,
							"",
							factory,
							deviceWriter)
{
	this->emailSender = factory->GetEmailSender();
	if (this->emailSender==NULL)
		throw ArgumentNullException("emailSender");
}
Exemplo n.º 18
0
void MemoryStream::Write(const u8 *buf, u64 count)
{
	if (!buf)
		throw ArgumentNullException();

	/* We can't expand the buffer. So if a Write request is made out of bounds, throw */
	if (ptr + count > size)
		throw NotSupportedException();

	memcpy(&buffer[ptr], buf, count);
	ptr += count;
}
Exemplo n.º 19
0
zDBBinaryReader::zDBBinaryReader(StatementHandle* pStatement, int ordinal) :
	m_pStatement(pStatement), m_ordinal(ordinal)
{
	if(!m_pStatement) throw gcnew ArgumentNullException();
	if(ordinal < 0) throw gcnew ArgumentOutOfRangeException();

	// Get how much data there is to work with now, so we don't have to
	// do it each and every time.  This is supposed to be an OPTIMIZED
	// way of working with binary values, after all.

	m_cb = sqlite3_column_bytes(m_pStatement->Handle, m_ordinal);
	m_pStatement->AddRef(this);
}
Exemplo n.º 20
0
HisBase::HisBase(IHisDevFactory* factory)
	: factory(factory)
{
	if (factory==NULL)
		throw ArgumentNullException("factory");
	createDate = DateTime::Now();
	modifyDate = createDate;
	isnew = true;
	isloaded = false;
	node = NULL;
	parent = NULL;
	name = DEFAULTNAME;
}
Exemplo n.º 21
0
JointLimitPair^ JointLimitPair::ToManaged(PxJointLimitPair* parameters)
{
	if (parameters == NULL)
		throw gcnew ArgumentNullException("parameters");

	JointLimitPair^ pair = gcnew JointLimitPair();

	pair->PopulateManaged(parameters);

	pair->LowerLimit = parameters->lower;
	pair->UpperLimit = parameters->upper;

	return pair;
}
Exemplo n.º 22
0
HisDevValueEmail::HisDevValueEmail(IWriteToDevice* deviceWriter, IHisDevFactory* factory	) :
		HisDevValue::HisDevValue("emailtag",
				EHisDevDirection::Write,
				EDataType::Email,
				0,
				"",
				"Email",
				factory,
				deviceWriter)
{
	this->emailSender = factory->GetEmailSender();
	if (this->emailSender==NULL)
		throw ArgumentNullException("emailSender");
	this->fromAddr = fromAddr;
	this->receivers = receivers;
}
Exemplo n.º 23
0
			Value FieldInfoImpl::GetValue(const Value& thisObject)
			{
				if(thisObject.IsNull())
				{
					throw ArgumentNullException(L"thisObject", this);
				}
				else
				{
					auto td = thisObject.GetTypeDescriptor();
					auto valueType = td->GetValueSerializer() ? Value::Text : Value::RawPtr;
					if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType))
					{
						throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject);
					}
				}
				return GetValueInternal(thisObject);
			}
Exemplo n.º 24
0
			void EventInfoImpl::Invoke(const Value& thisObject, collections::Array<Value>& arguments)
			{
				if(thisObject.IsNull())
				{
					throw ArgumentNullException(L"thisObject", this);
				}
				else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr))
				{
					throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject);
				}
				DescriptableObject* rawThisObject=thisObject.GetRawPtr();
				if(rawThisObject)
				{
					InvokeInternal(rawThisObject, arguments);
				}
				else
				{
					return;
				}
			}
Exemplo n.º 25
0
bool Window::ElementCaptureMouse(UIElement* element)
{
	if (element == nullptr)
	{
		raise(ArgumentNullException());
	}

	if (m_MouseCaptureElement != element)
	{
		m_MouseCaptureElement = element;
		m_MouseCaptureElement->SetCaptureMouse(true);
		if (m_platformWindow)
		{
			::SetCapture(m_platformWindow->get_Handle());
			return true;
		}
	}

	return true;
}
Exemplo n.º 26
0
			void FieldInfoImpl::SetValue(Value& thisObject, const Value& newValue)
			{
				if(thisObject.IsNull())
				{
					throw ArgumentNullException(L"thisObject", this);
				}
				else
				{
					auto td = thisObject.GetTypeDescriptor();
					auto valueType = td->GetValueSerializer() ? Value::Text : Value::RawPtr;
					if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType))
					{
						throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject);
					}
				}
				if(!newValue.CanConvertTo(returnInfo.Obj()))
				{
					throw ArgumentTypeMismtatchException(L"newValue", returnInfo.Obj(), newValue);
				}
				SetValueInternal(thisObject, newValue);
			}
Exemplo n.º 27
0
	Dictionary<int, float>^ VowpalWabbitMulticlassProbabilitiesPredictionFactory::Create(vw* vw, example* ex)
	{
#if _DEBUG
		if (ex == nullptr)
			throw gcnew ArgumentNullException("ex");
#endif
		v_array<float> confidence_scores;

		try {
			confidence_scores = VW::get_cost_sensitive_prediction_confidence_scores(ex);
		}
		CATCHRETHROW

		auto values = gcnew Dictionary<int, float>();
		int i = 0;
		for (auto& val : confidence_scores) {
			values->Add(++i, val);
		}

		return values;
	}
Exemplo n.º 28
0
bool Window::ElementReleaseMouseCapture(UIElement* element)
{
	if (element == nullptr)
	{
		raise(ArgumentNullException());
	}

	if (m_MouseCaptureElement == element)
	{
		m_MouseCaptureElement->SetCaptureMouse(false);

		m_MouseCaptureElement = nullptr;
		if (m_platformWindow)
		{
			return !! ::ReleaseCapture();
		}
		else
			return true;
	}
	else
		return false;
}
Exemplo n.º 29
0
			Ptr<IEventHandler> EventInfoImpl::Attach(const Value& thisObject, Ptr<IValueFunctionProxy> handler)
			{
				if(thisObject.IsNull())
				{
					throw ArgumentNullException(L"thisObject", this);
				}
				else if(!thisObject.CanConvertTo(ownerTypeDescriptor, Value::RawPtr))
				{
					throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, Value::RawPtr, thisObject);
				}
				DescriptableObject* rawThisObject=thisObject.GetRawPtr();
				if(rawThisObject)
				{
					Ptr<EventHandlerImpl> eventHandler=new EventHandlerImpl(this, rawThisObject, handler);
					AddEventHandler(rawThisObject, eventHandler);
					AttachInternal(rawThisObject, eventHandler.Obj());
					return eventHandler;
				}
				else
				{
					return 0;
				}
			}
Exemplo n.º 30
0
u64 MemoryStream::Read(u8 *buf, u64 count)
{
	if (!buf)
		throw ArgumentNullException();

	if (ptr >= size)
	{
		memset(buffer, 0, count);
		return 0;
	}
	else if (ptr + count > size)
	{
		memcpy(buf, &buffer[ptr], size - ptr);
		memset(&buf[size - ptr], 0, count - (size - ptr));
		ptr = size;
		return size - ptr;
	}
	else
	{
		memcpy(buf, &buffer[ptr], count);
		ptr += count;
		return count;
	}
}