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]; } }
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); }
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; }
String::StringIterator::StringIterator(const String* string) : _string(string) { if (!string) { throw ArgumentNullException(); } }
BatchQuery::BatchQuery(PxBatchQuery* batchQuery) { if (batchQuery == NULL) throw gcnew ArgumentNullException("batchQuery"); _batchQuery = batchQuery; }
CStdFile::CStdFile(FILE* fp) : m_fp(fp) { if (fp == NULL) { raise(ArgumentNullException()); } }
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; }
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()); } } }
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); }
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); }
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; }
JointLimitParameters^ JointLimitParameters::ToManaged(PxJointLimitParameters* parameters) { if (parameters == NULL) throw gcnew ArgumentNullException("parameters"); JointLimitParameters^ p = gcnew JointLimitParameters(); p->PopulateManaged(parameters); return p; }
HisDevValueEmail::HisDevValueEmail(xmlNodePtr node, IWriteToDevice* deviceWriter, IHisDevFactory* factory) : HisDevValue::HisDevValue(node, "", factory, deviceWriter) { this->emailSender = factory->GetEmailSender(); if (this->emailSender==NULL) throw ArgumentNullException("emailSender"); }
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; }
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); }
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; }
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; }
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; }
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); }
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; } }
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; }
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); }
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; }
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; }
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; } }
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; } }