result Enrollment::DisplayText(ByteBuffer& txBuffer, unsigned long buflen) {
	String data;
	char* pBuffer = null;
	result res = E_SUCCESS;

	txBuffer.Flip();
	pBuffer = (char*) (txBuffer.GetPointer());
	data.SetCapacity(buflen + 20);
	res = data.Append(pBuffer);
	TryReturn(res == E_SUCCESS, res, "Append Failed");

	txBuffer.Clear();

	if (data == L"__HELLO__") {
		EnableControl(true);
		__isConnected = true;
		return res;
	}

	if (__isConnected == false) {
		AppLog(
				"Server hasn't received Initial message so all incoming content is discarded");
		// Remove created NetEndPoint
		delete __pUdpEndpoint;
		__pUdpEndpoint = null;
		return res;
	}

	if (data == L"__CLOSE__") {
		SceneManager* pSceneManager = SceneManager::GetInstance();
		AppAssert(pSceneManager);

		pSceneManager->GoBackward(BackwardSceneTransition(SCENE_CALENDAR));

		OnClose();
		return res;
	}

	int i = 0;
	if (data.Contains(__pWorkList[i]->GetText())) {
		__pWorkList[i++]->SetSelected(true);
	}
	if (data.Contains(__pWorkList[i]->GetText())) {
		__pWorkList[i++]->SetSelected(true);
	}
	if (data.Contains(__pWorkList[i]->GetText())) {
		__pWorkList[i++]->SetSelected(true);
	}
	if (data.Contains(__pWorkList[i]->GetText())) {
		__pWorkList[i++]->SetSelected(true);
	}

	TryReturn(res == E_SUCCESS, res, "AppendText Failed");

	for (int k = 0; k < MAX_WORK_COUNT; k++) {
		__pWorkList[k]->RequestRedraw();
	}

	return res;
}
Ejemplo n.º 2
0
void Script::JumpToNextConditional()
{
	// If the statement is not true, find an else or endif block..!
	for (int i = currentLine; i < lines.Size(); ++i){
		String l = lines[i];
		if (l.Contains("elsif"))
		{
			std::cout<<"\nJumpToNextConditional: "<<l;
			currentLine = i;
			// Call this function again?
			EvaluateLine(lines[i]);
			return;
		}
		else if (l.Contains("else"))
		{
			/// Jump to this row ^^
			currentLine = i;
			lineFinished = true;
			return;
		}
		else if (l.Contains("endif")){
			currentLine = i;
			lineFinished = true;
			return;
		}
	}
}
Ejemplo n.º 3
0
// Let's say you don't know if the input string is raw base64, or if it has
// bookends
// on it like -----BEGIN BLAH BLAH ...
// And if it DOES have Bookends, you don't know if they are escaped:  -
// -----BEGIN ...
// Let's say you just want an easy function that will figure that crap out, and
// load the
// contents up properly into an OTASCIIArmor object. (That's what this function
// will do.)
//
// str_bookend is a default.
// So you could make it more specific like, -----BEGIN ENCRYPTED KEY (or
// whatever.)
//
// static
bool OTASCIIArmor::LoadFromString(OTASCIIArmor& ascArmor,
                                  const String& strInput,
                                  std::string str_bookend)
{

    if (strInput.Contains(str_bookend)) // YES there are bookends around this.
    {
        const std::string str_escaped("- " + str_bookend);

        const bool bEscaped = strInput.Contains(str_escaped);

        String strLoadFrom(strInput);

        if (!ascArmor.LoadFromString(strLoadFrom, bEscaped)) // removes the
                                                             // bookends so we
                                                             // have JUST the
                                                             // coded part.
        {
            //          otErr << "%s: Failure loading string into OTASCIIArmor
            // object:\n\n%s\n\n",
            //                        __FUNCTION__, strInput.Get());
            return false;
        }
    }
    else
        ascArmor.Set(strInput.Get());

    return true;
}
Ejemplo n.º 4
0
String DateTime::ToFormat(const String& format) const
{
	String s = format.IsEmpty() ? "M/D/YYYY" : format;
	TimeSpan t = *this;
	String ampm = "am";
	if (s.Contains("am/pm") || s.Contains("AM/PM"))
	{
		s = s.Replace("am/pm", "{4}");
		s = s.Replace("AM/PM", "{5}");
		if (t.Hours() >= 12)
		{
			t = t.AddHours(-12);
			ampm = "pm";
		}
		else if (t.Hours() == 0)
			t = t.AddHours(12);
	}
	String AMPM = ampm.ToUpper();
	YearString y(*this);
	MonthString m(*this);
	DayString d(*this);
	s = s
		.Replace("YYYY", "{0:~~~~}")
		.Replace("YY", "{0:~~}")
		.Replace("MMMM", "{1:~~~~}")
		.Replace("MMM", "{1:~~~}")
		.Replace("MM", "{1:~~}")
		.Replace("M", "{1}")
		.Replace("DDDD", "{2:~~~~}")
		.Replace("DDD", "{2:~~~}")
		.Replace("DD", "{2:~~}")
		.Replace("D", "{2}")
		.Replace("hh", "{3:HH}")
		.Replace("h", "{3:H}")
		.Replace("mm", "{3:MM}")
		.Replace("m", "{3:M}")
		.Replace("ss", "{3:SS}")
		.Replace("s", "{3:S}")
		.Replace("nnn", "{3:NNN}")
		.Replace("nn", "{3:NN}")
		.Replace("n", "{3:N}")
		.Replace("{3:HH}", "{3:hh}")
		.Replace("{3:H}", "{3:h}")
		.Replace("{3:MM}", "{3:mm}")
		.Replace("{3:M}", "{3:m}")
		.Replace("{3:SS}", "{3:ss}")
		.Replace("{3:S}", "{3:s}")
		.Replace("{3:NNN}", "{3:nnn}")
		.Replace("{3:NN}", "{3:nn}")
		.Replace("{3:N}", "{3:n}");
	if (s.Contains("{4}"))
		s = s.Replace("{4}", ampm);
	if (s.Contains("{5}"))
		s = s.Replace("{5}", AMPM);
	return Format(s, y, m, d, t);
}
bool ModelImporter::Import()
{
    String modelAssetFilename = asset_->GetPath();

    importNode_ = new Node(context_);

    // skip external animations, they will be brought in when importing their
    // corresponding model
    if (!modelAssetFilename.Contains("@"))
    {
        ImportModel();

        if (importAnimations_)
        {
            ImportAnimations();
        }

    }

    File outFile(context_);

    if (!outFile.Open(asset_->GetCachePath(), FILE_WRITE))
        ErrorExit("Could not open output file " + asset_->GetCachePath());

    importNode_->SaveXML(outFile);

    importNode_ = 0;

    return true;
}
Ejemplo n.º 6
0
AssetStoragePtr HttpAssetProvider::TryCreateStorage(HashMap<String, String> &storageParams, bool fromNetwork)
{
    if (!storageParams.Contains("src") || !IsValidRef(storageParams["src"], ""))
        return AssetStoragePtr();
    if (storageParams.Contains("type") && storageParams["type"].Compare("HttpAssetStorage", false) != 0)
        return AssetStoragePtr();

    String baseUrl = storageParams["src"];
    if (!baseUrl.EndsWith("/") && baseUrl.Contains("/"))
        baseUrl = baseUrl.Substring(0, baseUrl.FindLast('/')+1);
    if (!baseUrl.EndsWith("/"))
        return AssetStoragePtr();

    String name = UniqueName(storageParams["name"]);

    // @todo liveupdate, liveupload, autodiscoverable etc. when actually needed
    AssetStoragePtr storage = StorageForBaseURL(baseUrl);
    if (!storage)
    {
        storage = AssetStoragePtr(new HttpAssetStorage(framework_->GetContext(), name, baseUrl, storageParams["localdir"]));
        httpStorages_.Push(storage);
    }

    storage->SetReplicated(Urho3D::ToBool(storageParams["replicated"]));
    return storage;
}
Ejemplo n.º 7
0
UserGroup *UserGroup::MatchFilter(const String &filter) {
	UserGroup *filteredGroup = null;
	String filterLowerCase;
	filter.ToLowerCase(filterLowerCase);

	for(int i = 0; i < _pUserList->GetCount(); i++) {
		JsonObject *user;
		String firstName;
		String lastName;
		String fullName;

		JsonParseUtils::GetObject(_pUserList, i, user);
		JsonParseUtils::GetString(*user, L"first_name", firstName);
		JsonParseUtils::GetString(*user, L"last_name", lastName);
		(firstName + L" " + lastName).ToLowerCase(fullName);

		if(fullName.Contains(filterLowerCase)) {
			if(filteredGroup == null) {
				filteredGroup = new UserGroup();
				filteredGroup->Construct(*_pGroupName);
			}

			filteredGroup->_pUserList->Add(user);
		}
	}

	return filteredGroup;
}
Ejemplo n.º 8
0
/** Used to tokenize with some characters used to start and stop the tokenization procedure temporarily.
	Sample use-case would be to tokenize the string "Aim(7,3), Guard(2,3)" and returning "Aim(7,3)" and "Guard(2,3)",
	using the tokenizer ',' and ignoreparts "()". 
	Ignore parts should be in pairs, one starting the ignore part, the other stopping it.
*/
List<String> TokenizeIgnore(String string, String tokenizers, String ignoreParts)
{
	List<String> tokens;
	int inIgnorePart = 0;
	const char * cString = string.c_str();
	String str;
	for (int i = 0; i < string.Length(); ++i)
	{
		char c = cString[i];
		for (int i = 0; i < ignoreParts.Length(); i += 2)
		{
			if (c == ignoreParts.c_str()[i])
				++inIgnorePart;
			if (c == ignoreParts.c_str()[i+1])
				--inIgnorePart;
		}

		if (tokenizers.Contains(c) && inIgnorePart == 0)
		{
			tokens.Add(str);
			str = String();
		}
		else 
		{
			str += c;
		}
	}
	// Add final one.
	tokens.Add(str);
	return tokens;
}
Ejemplo n.º 9
0
void UEventObserver::UEventThread::SendEvent(
    /* [in] */ const String& message)
{
    {
        AutoLock lock(mKeysAndObserversLock);

        List< AutoPtr<IInterface> >::Iterator it = mKeysAndObservers.Begin();
        while (it != mKeysAndObservers.End()) {
            AutoPtr<ICharSequence> csStr = ICharSequence::Probe(*it);
            assert(csStr != NULL);
            String key;
            csStr->ToString(&key);
            if (message.Contains(key)) {
                List< AutoPtr<IInterface> >::Iterator tmpIt = it;
                AutoPtr<IInterface> obj = *(++tmpIt);
                AutoPtr<UEventObserver> observer = (UEventObserver*)IObject::Probe(obj);
                mTempObserversToSignal.PushBack(observer);
            }
            ++it;
            ++it;
        }
    }

    if (!mTempObserversToSignal.IsEmpty()) {
        AutoPtr<UEvent> event = new UEvent(message);
        List< AutoPtr<UEventObserver> >::Iterator it;
        for (it = mTempObserversToSignal.Begin(); it != mTempObserversToSignal.End(); ++it) {
            AutoPtr<UEventObserver> observer = *it;
            observer->OnUEvent(event);
        }
        mTempObserversToSignal.Clear();
    }
}
Ejemplo n.º 10
0
FileFormat::FileFormat( const String& nameExtOrMime, bool toRead, bool toWrite ) :
   FileFormatBase()
{
   if ( nameExtOrMime.IsEmpty() )
      throw Error( "FileFormat: Empty format name, file extension or MIME type specified" );

   m_data = new FileFormatPrivate;

   if ( nameExtOrMime.Contains( '/' ) )
   {
      IsoString mimeType( nameExtOrMime );
      m_data->handle = (*API->FileFormat->GetFileFormatByMimeType)( ModuleHandle(), mimeType.c_str(), toRead, toWrite );
      if ( m_data->handle == nullptr )
         throw Error( "FileFormat: No installed image file format was found "
                      "for the specified MIME type \'" + nameExtOrMime + "\' and access conditions" );
   }
   else if ( nameExtOrMime.StartsWith( '.' ) )
   {
      m_data->handle = (*API->FileFormat->GetFileFormatByFileExtension)( ModuleHandle(), nameExtOrMime.c_str(), toRead, toWrite );
      if ( m_data->handle == nullptr )
         throw Error( "FileFormat: No installed image file format was found "
                      "for the specified file extension \'" + nameExtOrMime + "\'and access conditions" );
   }
   else
   {
      IsoString id( nameExtOrMime );
      m_data->handle = (*API->FileFormat->GetFileFormatByName)( ModuleHandle(), id.c_str() );
      if ( m_data->handle == nullptr )
         throw Error( "FileFormat: No installed image file format was found "
                      "with the specified identifier \'" + nameExtOrMime + '\'' );
   }

   m_data->GetCapabilities();
}
Ejemplo n.º 11
0
void Script::EndCutscene(bool endingPrematurely /*= false*/)
{
	// Make sure we're in a cutscene first..
	if (!inCutscene)
		return;
	if (endingPrematurely)
	{
		// Jump to the end of the cutscene.
		for (int i = currentLine; i < lines.Size(); ++i)
		{
			// Look for the end.
			String line = lines[i];
			if (line.Contains("End(Cutscene)"))
			{
				// Jump to it.
				currentLine = i;
				// Stop doing whatever we were doing too.
				lineFinished = true;
				break;
			}
		} 
	}
	// End all sub-scripts too!
	for (int i = 0; i < childScripts.Size(); ++i)
	{
		Script * script = childScripts[i];
		script->QueueEnd();
	}

	inCutscene = false;
}
Ejemplo n.º 12
0
bool Project::Load(const String& fullpath)
{
    loading_ = true;

    if (fullpath.Contains(".atomic")) {

        projectPath_ = AddTrailingSlash(GetPath(fullpath));
        projectFilePath_ = fullpath;

    }
    else
    {
        projectPath_ = AddTrailingSlash(fullpath);
        projectFilePath_ = projectPath_ + GetFileName(RemoveTrailingSlash(projectPath_)) + ".atomic";

    }


    SharedPtr<ProjectFile> pfile(new ProjectFile(context_));
    bool result = pfile->Load(this);

    loading_ = false;

    LoadBuildSettings();
    LoadUserPrefs();

    if ( true /*result*/) {
        VariantMap data;
        data[ProjectLoaded::P_PROJECTPATH] = projectFilePath_;
        SendEvent(E_PROJECTLOADED, data);
    }

    return result;
}
   void
   POP3ClientConnection::ParseStateCAPASent_(const String &sData)
   {
      if (!CommandIsSuccessfull_(sData) || !sData.Contains(_T("STLS")))
      {
         // STLS is not supported.
         if (GetConnectionSecurity() == CSSTARTTLSRequired)
         {
            String message = 
               Formatter::Format("The download of messages from external account {0} failed. The external aAccount is configured to use STARTTLS connection security, but the POP3 server does not support it.", account_->GetName());
            
            LOG_APPLICATION(message)
            QuitNow_();
            return;
         }
         else
         {
            SendUserName_();
            return;
         }
      }

      EnqueueWrite_("STLS");
      current_state_ = StateSTLSSent;
   }
Ejemplo n.º 14
0
String CSTypeHelper::GetNativeFunctionSignature(JSBFunction* function, String& returnType)
{

    if (function->Skip())
        return String::EMPTY;

    if (function->IsDestructor())
        return String::EMPTY;

    if (OmitFunction(function))
        return String::EMPTY;

    JSBClass* klass = function->GetClass();
    JSBPackage* package = klass->GetPackage();
    String fname = function->IsConstructor() ? "Constructor" : function->GetName();

    returnType = "void";

    if (function->IsConstructor())
    {
        returnType = "RefCounted*";
    }
    else if (function->GetReturnType())
    {
        if (function->IsConstructor())
        {
            returnType = ToString("%s*", klass->GetNativeName().CString());
        }
        else if (function->GetReturnClass())
        {
            if (!function->GetReturnClass()->IsNumberArray())
            {
                returnType = ToString("const %s*", function->GetReturnClass()->GetNativeName().CString());
            }
        }
        else if (function->GetReturnType()->type_->asStringHashType())
        {
            returnType = "unsigned";
        }
        else
        {
            returnType = ToString("%s", CSTypeHelper::GetNativeTypeString(function->GetReturnType()).CString());

            // ScriptVector is handled by a out parameter
            if (returnType.Contains("ScriptVector"))
                returnType = "void";
        }
    }


    String sig;
    GenNativeFunctionParameterSignature(function, sig);

    String functionSig = ToString("csb_%s_%s_%s_%u(%s)",
                package->GetName().CString(), klass->GetName().CString(),
                fname.CString(), function->GetID(), sig.CString());

    return functionSig;
}
Ejemplo n.º 15
0
ECode CTestBasicType::strStartwith(
    /* [in] */ String i,
    /* [in] */ String j,
    /* [out] */ Boolean * pO)
{
    *pO = i.Contains(j);
    return NOERROR;
}
Ejemplo n.º 16
0
   boost::shared_ptr<const Domain> 
   CacheContainer::GetDomain(const String &sName)
   {
#ifdef _DEBUG
      if (sName.Contains(_T("@")))
      {
         assert(0);
      }
#endif
      return Cache<Domain, PersistentDomain>::Instance()->GetObject(sName);
   }
Ejemplo n.º 17
0
/// Default processor to react to messages created by the default bindings declared above.
void ProcessCameraMessages(String msg, Camera * forCamera)
{
	if (!forCamera->inputFocus)
		return;
	if (msg == "ResetCamera")
	{
		forCamera->Reset();		
	}
	else if (msg == "CamIncreaseSpeed")
	{
		forCamera->flySpeed = ClampedFloat(forCamera->flySpeed * 1.1f + 0.1f, 0.1f, 100.f);
	}
	else if (msg == "CamDecreaseSpeed")
	{
		forCamera->flySpeed = ClampedFloat(forCamera->flySpeed * 0.9f - 0.1f, 0.1f, 100.f);
	}
	else if (msg.Contains("StartCameraRot"))
	{
		String dirStr = msg - "StartCameraRot";
		int direction = Direction::Get(dirStr);
		forCamera->BeginRotate(direction);	
	}
	else if (msg.Contains("StopCameraRot"))
	{
		String dirStr = msg - "StopCameraRot";
		int direction = Direction::Get(dirStr);
		forCamera->EndRotate(direction);	
	}
	else if (msg.Contains("StartCamera"))
	{
		String dirStr = msg - "StartCamera";
		int direction = Direction::Get(dirStr);
		forCamera->Begin(direction);
	}
	else if (msg.Contains("StopCamera"))
	{
		String dirStr = msg - "StopCamera";
		int direction = Direction::Get(dirStr);
		forCamera->End(direction);
	}
}
Ejemplo n.º 18
0
/// Continue to dat alternative (for branching with Alternatives/Questions)
bool Script::ContinueToAlternative(String alternative){
	/// Check that we're currently in an alternativeDialogue?
	if (!isInAlternativeDialogue){
		std::cout<<"\nNot in any alternative dialogue anymore. Ignoring command.";
		return false;
	}
	bool endAlternativesFound = false;
	for (int i = currentLine; i < lines.Size(); ++i){
		String line = lines[i];
		if (line.Contains("EndAlternatives"))
			endAlternativesFound = true;
		if (!endAlternativesFound)
			continue;
		if (line.Contains(alternative)){
			currentLine = i;
			lineFinished = true;
			isInAlternativeDialogue = false;
			return true;
		}
	}
	return false;
}
Ejemplo n.º 19
0
void ParseCommand(String input, String &command, StringVector &parameters)
{
    input = input.Trimmed();
    if (input.Empty())
        return;

    uint parenPos = input.Find('(', 0);
    uint spacePos = input.Find(' ', 0);
    if (parenPos == String::NPOS && spacePos == String::NPOS)
    {
        command = input;
        return;
    }
    StringVector parts;
    if (parenPos != String::NPOS && parenPos < spacePos)
    {
        uint parenEndPos = input.FindLast(')');
        String insideParens = (parenEndPos != String::NPOS ? 
            input.Substring(parenPos+1, parenEndPos-parenPos-1).Trimmed() : input.Substring(parenPos+1).Trimmed());
        command = input.Substring(0, parenPos).Trimmed();
        // "one, two, three", "one,two,three" and "one two three"
        parts = insideParens.Contains(',') ? insideParens.Split(',') : insideParens.Split(' ');
    }
    else
    {
        command = input.Substring(0, spacePos).Trimmed();
        String remaining = input.Substring(spacePos+1).Trimmed();
        // "one, two, three", "one,two,three" and "one two three"
        parts = remaining.Contains(',') ? remaining.Split(',') : remaining.Split(' ');
    }
    for(StringVector::Iterator iter=parts.Begin(); iter!=parts.End(); ++iter)
    {
        String part = (*iter).Trimmed();
        if (part.EndsWith(","))
            part = part.Substring(0, part.Length()-1);
        if (!part.Empty())
            parameters.Push(part);
    }
}
Ejemplo n.º 20
0
void RRDialogueProperty::ProcessMessage(Message * message)
{
	/* 	Relevant messages.
			Interact - sent to all RuneEntity's in front of the player.
			Continue
			Choose(choice)
			Cancel
*/
	String msg = message->msg;
	if (msg == "Interact")
	{
		activeDialogue = dialogues.Size()? dialogues[0] : 0;
		if (activeDialogue)
		{
			activeDialogue->Start();
			activeDialogue->owner = owner;
			if (activeDialogue->state == Dialogue::BEGUN)
			{
				/// Processes it straight away, no queueing.
				MesMan.ProcessMessage("OnDialogueBegun("+String(activeDialogue->ID())+")");
				/// Pause movement of this NPC or whatever.
				Message msg("PauseMovement");
				owner->ProcessMessage(&msg);
			}
		}
	}
	else if (msg == "Continue")
	{
		if (activeDialogue == 0)
		{
			MesMan.ProcessMessage("OnDialogueBegun("+String(activeDialogue->ID())+")");
			return;
		}
		activeDialogue->Continue();
		if (activeDialogue->state == Dialogue::ENDED)
		{
			OnDialogueEnded();
			return;
		}
	}
	else if (msg.Contains("Choose")){}
	else if (msg == "OnDialogueEnded")
	{
		activeDialogue = 0;
		OnDialogueEnded();
	}
	else if (msg == "Cancel")
	{
		
	}
}
Ejemplo n.º 21
0
void ShaderPrecache::LoadShaders(Graphics* graphics, Deserializer& source)
{
    LOGDEBUG("Begin precaching shaders");

    XMLFile xmlFile(graphics->GetContext());
    xmlFile.Load(source);

    XMLElement shader = xmlFile.GetRoot().GetChild("shader");
    while (shader)
    {
        String vsDefines = shader.GetAttribute("vsdefines");
        String psDefines = shader.GetAttribute("psdefines");

        // Check for illegal variations on OpenGL ES and skip them
#ifdef GL_ES_VERSION_2_0
        if (
#ifndef __EMSCRIPTEN__
            vsDefines.Contains("INSTANCED") ||
#endif
            (psDefines.Contains("POINTLIGHT") && psDefines.Contains("SHADOW")))
        {
            shader = shader.GetNext("shader");
            continue;
        }
#endif

        ShaderVariation* vs = graphics->GetShader(VS, shader.GetAttribute("vs"), vsDefines);
        ShaderVariation* ps = graphics->GetShader(PS, shader.GetAttribute("ps"), psDefines);
        // Set the shaders active to actually compile them
        graphics->SetShaders(vs, ps);

        shader = shader.GetNext("shader");
    }

    LOGDEBUG("End precaching shaders");
}
Ejemplo n.º 22
0
/** Extracts target header-data, for example specifying "CSeq:" might return the following: "314159".
	The header-data will, if available, be sent into the second parameter string reference.
	Upon failure (lack of such data), it will return false AND set the target string to an empty String.
*/
bool SIPPacket::GetHeaderData(String tagName, String & data){
	for (int i = 0; i < header.Size(); ++i){
		String line = header[i];
		if (!line.Contains(tagName))
			continue;
		// Split using all white-space characters!
		List<String> tokens = line.Tokenize(" \n\r\t");
		if (tokens.Size() < 2)
			continue;
		data = tokens[1];
		return true;
	}
	data = String();
	return false;
}
Ejemplo n.º 23
0
char Stream::ReadUntil(String &strOut, const String &strCharacters)
{
  String ret;
  char ccc = '\0';
  while(!AtEOF()) {
    char cc = ReadChar();
    if(strCharacters.Contains(cc)) {
      ccc = cc;
      break;
    }
    ret += cc;
  }
  strOut = ret;
  return ccc;
}
Ejemplo n.º 24
0
void Script::JumpToEndif()
{
	// If the statement is not true, find an else or endif block..!
	for (int i = currentLine; i < lines.Size(); ++i)
	{
		String l = lines[i];
		if (l.Contains("endif"))
		{
			std::cout<<"\nJumpToEndif: "+l+" from: "+lines[currentLine];
			currentLine = i;
			lineProcessed = false;
	//		lineFinished = true;
			return;
		}
	}
	std::cout<<"\nERROR: No Endif found D:";
}
Ejemplo n.º 25
0
/// Yus.
bool Mesh::SaveObj(String path)
{
	if (!path.Contains(".obj"))
		path = path + ".obj";
	File objFile(path);
	bool ok = objFile.OpenForWritingText();
	if (!ok)
		return false;
	std::fstream & fstream = objFile.GetStream();
	fstream<<"o "<<name;
	for (int i = 0; i < vertices.Size(); ++i)
	{
		Vector3f & v = vertices[i];
		fstream<<"\nv "<<v;
	}
	for (int i = 0; i < uvs.Size(); ++i)
	{
		Vector2f & uv = uvs[i];
		fstream<<"\nvt "<<uv;
	}
	for (int i = 0; i < normals.Size(); ++i)
	{
		Vector3f & n = normals[i];
		fstream<<"\nvn "<<n;
	}
	for (int i = 0; i < faces.Size(); ++i)
	{
		MeshFace & f = faces[i];
		fstream<<"\nf";
		for (int i = 0; i < f.vertices.Size(); ++i)
		{
			fstream<<" "<<(f.vertices[i]+1);
			if (f.normals.Size() || f.uvs.Size())
				fstream<<"/";
			if (f.uvs.Size())
				fstream<<(f.uvs[i]+1);
			if (f.normals.Size())
				fstream<<"/"<<(f.normals[i]+1);
		}
	}
	objFile.Close();
	return true;
}
Ejemplo n.º 26
0
void SetLogLevel(String fromString)
{
	if (fromString.Contains("FATAL"))
		logLevel = FATAL;
	if (fromString.Contains("INFO"))
		logLevel = INFO;
	if (fromString.Contains("WARNING"))
		logLevel = WARNING;
	if (fromString.Contains("ERROR"))
		logLevel = ERROR;
	if (fromString.Contains("DEBUG"))
		logLevel = DEBUG;
	if (fromString.Contains("EXTENSIVE_DEBUG"))
		logLevel = EXTENSIVE_DEBUG;
}
void CookieToServerRenderer::OutputCookies(const String &explicitDomainName, std::ostream &reply, Context &c) {
	StartTrace(CookieToServerRenderer.OutputCookies);

	String newString = explicitDomainName;
	newString.ToUpper();

	ROAnything roaAllCookieDomains;
	if (c.Lookup("Cookies", roaAllCookieDomains)) {
		Trace( "try to find [" << explicitDomainName << "]");
		TraceAny( roaAllCookieDomains, "try to find [" << explicitDomainName << "] in here" );
		// could be .y.z match cookie to be sent out
		ROAnything roaCookies;
		AnyExtensions::Iterator<ROAnything, ROAnything, String> aCookieIter(roaAllCookieDomains);
		while (aCookieIter.Next(roaCookies)) {
			String potPartDomain;
			aCookieIter.SlotName(potPartDomain);
			Trace("PotPartDomain " << potPartDomain << " NewString " << newString);
			long posn = newString.Contains(potPartDomain);
			Trace("Posn " << posn << " potPartDomain.Length " << potPartDomain.Length() << " newString.Length " << newString.Length());
			if ((posn + potPartDomain.Length()) == newString.Length()) {
				// match of domains at end of string...only
				Trace( "(part) domain found at slot no" << aCookieIter.Index() );

				reply << "\r\nCookie: ";
				// output all cookies in the current cookie container...
				ROAnything roaEntry;
				AnyExtensions::Iterator<ROAnything, ROAnything, String> aDCookieIter(roaCookies);
				if (aDCookieIter.Next(roaEntry)) {
					Trace("Cookie passed to server [" << roaEntry.AsString() << "]");
					reply << roaEntry.AsString();
					while (aDCookieIter.Next(roaEntry)) {
						Trace("Cookie passed to server [" << roaEntry.AsString() << "]");
						reply << "; " << roaEntry.AsString();
					}
				}
				// finish loop now
				break;
			}
		}
	}
}
ECode CDownloadManagerRequest::AddRequestHeader(
    /* [in] */ const String& header,
    /* [in] */ const String& value)
{
    if (header.IsNull()) {
        // throw new NullPointerException("header cannot be null");
        Slogger::E("CDownloadManagerRequest", "header cannot be null");
        return E_NULL_POINTER_EXCEPTION;
    }
    if (header.Contains(":")) {
        // throw new IllegalArgumentException("header may not contain ':'");
        Slogger::E("CDownloadManagerRequest", "header may not contain ':'");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }
    if (value.IsNull()) {
        mRequestHeaders.PushBack(Pair<String, String>(header, String("")));
        return NOERROR;
    }
    mRequestHeaders.PushBack(Pair<String, String>(header, value));
    return NOERROR;
}
Ejemplo n.º 29
0
bool FileSystem::CheckAccess(const String& pathName) const
{
    String fixedPath = AddTrailingSlash(pathName);

    // If no allowed directories defined, succeed always
    if (allowedPaths_.Empty())
        return true;

    // If there is any attempt to go to a parent directory, disallow
    if (fixedPath.Contains(".."))
        return false;

    // Check if the path is a partial match of any of the allowed directories
    for (HashSet<String>::ConstIterator i = allowedPaths_.Begin(); i != allowedPaths_.End(); ++i)
    {
        if (fixedPath.Find(*i) == 0)
            return true;
    }

    // Not found, so disallow
    return false;
}
Ejemplo n.º 30
0
void SettingsHelper::SetGpsLocation(
    /* [in] */ const String& value)
{
    AutoPtr<IInterface> obj;
    mContext->GetSystemService(IContext::USER_SERVICE, (IInterface**)&obj);
    AutoPtr<IUserManager> um = IUserManager::Probe(obj);
    Boolean res;
    if (um->HasUserRestriction(IUserManager::DISALLOW_SHARE_LOCATION, &res), res) {
        return;
    }

    String GPS = ILocationManager::GPS_PROVIDER;
    Boolean enabled = GPS.Equals(value) ||
            value.StartWith(GPS + String(",")) ||
            value.EndWith(String(",") + GPS) ||
            value.Contains(String(",") + GPS + String(","));
    AutoPtr<ISettingsSecure> secure;
    CSettingsSecure::AcquireSingleton((ISettingsSecure**)&secure);
    AutoPtr<IContentResolver> resolver;
    mContext->GetContentResolver((IContentResolver**)&resolver);
    secure->SetLocationProviderEnabled(resolver, GPS, enabled);
}