コード例 #1
0
ファイル: IPv4.cpp プロジェクト: RGafiyatullin/ApeLibs
		IPv4::IPv4(const CS& str)
			:	m_Bytes(4)
		{
			Array<CS> parts = str.Split(".");
			if (parts.Length() != 4)
				throw EInvalidArgument("Invalid format for IPv4 (1)");
			
			for (size_t i = 0; i < 4; i++) {
				CS part = parts[i];
				
				for (size_t j = 0; j < part.Length(); j++)
					if (part.CharAt(j) < '0' || part.CharAt(j) > '9')
						throw EInvalidArgument("Invalid format for IPv4 (2)");
				
				unsigned char byte = atoi(part.CStr());
				m_Bytes[i] = byte;
			}
		}
コード例 #2
0
ファイル: RegularFile.cpp プロジェクト: RGafiyatullin/ApeLibs
			size_t RegularFile::Read(Array<char>& buff, size_t count) {
				if (m_Mode != OpenMode::Read)
					throw EInvalidOperation("File is not in Read mode");
				if (!count)
					count = buff.Length();
				else if (count > buff.Length())
					throw EInvalidArgument("The requested count exceeds buffer size");
				
				return Read((unsigned char*)(buff.Storage()), count);
			}
コード例 #3
0
  void initialize(boost::function<void(void)> aCallback, unsigned long aPeriodMS, HANDLE aTimerQueue = NULL)
  {
    stop();

    if (aCallback.empty()) {
      ANCHO_THROW(EInvalidArgument());
    }
    mCallback = aCallback;

    mTimerQueue = aTimerQueue;
    mPeriod = aPeriodMS;
  }
コード例 #4
0
inline JSVariant convert(const Ancho::Utils::JSValueWrapperConst &aValue)
{
  if (aValue.isObject()) {
    return convert(aValue.toObject());
  }
  if (aValue.isArray()) {
    return convert(aValue.toArray());
  }

  ANCHO_THROW(EInvalidArgument());
  return JSVariant();
}