Пример #1
0
 bool test()
 {
   StringBuilder sb;
   sb.Append("qwerty asdfgh");
   SmartPointer<String> s = sb.Substring(-2, -1);
   return (s.IsNull());
 }
Пример #2
0
SmartPointer<IElementReference> CommandService::RegisterElementForCommand(
    const SmartPointer<ParameterizedCommand>& command,
    const SmartPointer<UIElement>& element)
{
  if (!command->GetCommand()->IsDefined())
  {
    throw NotDefinedException(
        "Cannot define a callback for undefined command "
            + command->GetCommand()->GetId());
  }
  if (element.IsNull())
  {
    throw NotDefinedException("No callback defined for command "
        + command->GetCommand()->GetId());
  }

  QHash<QString, QString> paramMap = command->GetParameterMap();
  QHash<QString, Object::Pointer> parms;
  for (QHash<QString, QString>::const_iterator i = paramMap.begin();
       i != paramMap.end(); ++i)
  {
    Object::Pointer value(new ObjectString(i.value()));
    parms.insert(i.key(), value);
  }
  IElementReference::Pointer ref(new ElementReference(command->GetId(),
                                                      element, parms));
  RegisterElement(ref);
  return ref;
}
Пример #3
0
CommandParameter::CommandParameter(const QString& id, const QString& name,
                 const SmartPointer<IConfigurationElement>& values,
                 const SmartPointer<ParameterType>& parameterType,
                 const bool optional)
  : name(name)
  , optional(optional)
  , parameterType(parameterType)
  , valuesConfigurationElement(values)
  , id(id)
{
  if (id.isNull())
  {
    throw ctkInvalidArgumentException("Cannot create a parameter with a null id");
  }

  if (name.isNull())
  {
    throw ctkInvalidArgumentException("The name of a parameter cannot be null.");
  }

  if (values.IsNull())
  {
    throw ctkInvalidArgumentException("The values for a parameter cannot be null.");
  }
}
Пример #4
0
		static void add_by (SmartPointer<Client> client, ChatMessage & message) {
		
			if (!client.IsNull()) message << String::Format(
				by,
				client->GetUsername()
			);
		
		}
ParameterValueConverterProxy::ParameterValueConverterProxy(
    const SmartPointer<IConfigurationElement>& converterConfigurationElement)
  : converterConfigurationElement(converterConfigurationElement)
{
  if (converterConfigurationElement.IsNull())
  {
    throw ctkInvalidArgumentException(
        "converterConfigurationElement must not be null");
  }
}
void AbstractHandlerWithState::AddState(const QString& stateId, const SmartPointer<State>& state)
{
  if (state.IsNull())
  {
    throw ctkInvalidArgumentException("Cannot add a null state");
  }

  states.insert(stateId, state);
  state->AddListener(this);
  HandleStateChange(state, Object::Pointer(0));
}
Пример #7
0
void ContributionRoot::RegisterVisibilityForChild(const SmartPointer<IContributionItem>& item,
                                const SmartPointer<Expression>& visibleWhen)
{
  if (item.IsNull())
    throw std::invalid_argument("item must not be null");

  Expression::Pointer visibleWhenTmp = visibleWhen;
  if (visibleWhenTmp.IsNull())
    visibleWhenTmp = AlwaysEnabledExpression::INSTANCE;

  menuService->RegisterVisibleWhen(item, visibleWhenTmp, restriction,
                                   CreateIdentifierId(item));
  itemsToExpressions.append(item);
}
void RegistryObjectReferenceMap::Put(int key, const SmartPointer<RegistryObject>& value)
{
  if (value.IsNull())
    throw ctkInvalidArgumentException("null values not allowed");

  Purge();

  ReferenceMapType::Iterator i = references.find(key);
  if (i != references.end())
  {
    delete *i;
  }
  references.insert(key, NewEntry(value));
}
bool CommandContributionItem::ShouldRestoreAppearance(const SmartPointer<IHandler>& handler)
{
  // if no handler or handler doesn't implement IElementUpdater,
  // restore the contributed elements
  if (handler.IsNull())
    return true;

  if (!(handler.Cast<IElementUpdater>()))
    return true;

  // special case, if its HandlerProxy, then check the actual handler
//  if (handler instanceof HandlerProxy) {
//    HandlerProxy handlerProxy = (HandlerProxy) handler;
//    IHandler actualHandler = handlerProxy.getHandler();
//    return shouldRestoreAppearance(actualHandler);
//  }
  return false;
}
Пример #10
0
void EditorHistory::Remove(const SmartPointer<IEditorInput>& input)
{
  if (input.IsNull())
  {
    return;
  }
  auto iter = fifoList.begin();
  while (iter != fifoList.end())
  {
    if ((*iter)->Matches(input))
    {
      iter = fifoList.erase(iter);
    }
    else
    {
      ++iter;
    }
  }
}
Пример #11
0
 bool test()
 {
   StringBuilder sb;
   SmartPointer<String> s = sb.Substring(1);
   return (s.IsNull());
 }