Пример #1
0
 void DumpCore( String & s, char const * buf, int len )
 {
     for( int i = 0; i < len; ++i )
     {
         uint8 c = buf[ i ];
         if( c < 32 || c > 126 ) s.Append( '.' );
         else s.Append( (char)c );
     }
 }
Пример #2
0
Bitmap * LangSetting::GetIconN(Locale & lc)
{
	String name = L"ic_";
	name.Append(lc.GetCountryCodeString());
	name.Append(L".png");
	name.ToLowerCase();

	return Utils::GetBitmapN(name);
}
Пример #3
0
void replace_macro_tokens(const char *text, String &fixed_text) {
    const char*curptr=&text[0];
    char tmpm[3];
    const char*endat = curptr + strlen(text);
    fixed_text.Empty();
    char tempo[STD_BUFFER_SIZE];

    while (1) {
        if (curptr[0]==0) break;
        if (curptr>=endat) break;
        if (curptr[0]=='@') {
            const char *curptrWasAt = curptr;
            char macroname[21]; int idd=0; curptr++;
            for (idd=0;idd<20;idd++) {
                if (curptr[0]=='@') {
                    macroname[idd]=0;
                    curptr++;
                    break;
                }
                // unterminated macro (eg. "@SCORETEXT"), so abort
                if (curptr[0] == 0)
                    break;
                macroname[idd]=curptr[0];
                curptr++;
            }
            macroname[idd]=0; 
            tempo[0]=0;
            if (stricmp(macroname,"score")==0)
                sprintf(tempo,"%d",play.score);
            else if (stricmp(macroname,"totalscore")==0)
                sprintf(tempo,"%d",MAXSCORE);
            else if (stricmp(macroname,"scoretext")==0)
                sprintf(tempo,"%d of %d",play.score,MAXSCORE);
            else if (stricmp(macroname,"gamename")==0)
                strcpy(tempo, play.game_name);
            else if (stricmp(macroname,"overhotspot")==0) {
                // While game is in Wait mode, no overhotspot text
                if (!IsInterfaceEnabled())
                    tempo[0] = 0;
                else
                    GetLocationName(divide_down_coordinate(mousex), divide_down_coordinate(mousey), tempo);
            }
            else { // not a macro, there's just a @ in the message
                curptr = curptrWasAt + 1;
                strcpy(tempo, "@");
            }

            fixed_text.Append(tempo);
        }
        else {
            tmpm[0]=curptr[0]; tmpm[1]=0;
            fixed_text.Append(tmpm);
            curptr++;
        }
    }
}
Пример #4
0
void JSBModule::WriteClassDeclaration(String& source)
{

    source += "static void jsb_declare_classes(JSVM* vm)\n{\n";

    source += "duk_context* ctx = vm->GetJSContext();\n";

    for (unsigned i = 0; i < classes_.Size(); i++)
    {
        JSBClass* klass = classes_.At(i);

        if (klass->isNumberArray())
            continue;

        source.AppendWithFormat("   js_class_declare(vm, \"%s\", jsb_constructor_%s);\n", klass->GetName().CString(), klass->GetName().CString());

        if (klass->hasProperties())
        {
            source.AppendWithFormat("js_class_push_propertyobject(vm, \"%s\");\n", klass->GetName().CString());


            Vector<String> pnames;
            klass->GetPropertyNames(pnames);

            for (unsigned j = 0; j < pnames.Size(); j++)
            {
                JSBProperty* prop = klass->GetProperty(pnames[j]);

                source.Append("duk_push_object(ctx);\n");

                if (prop->getter_ && !prop->getter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 0);\n",
                                            klass->GetName().CString(), prop->getter_->name_.CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"get\");\n");
                }
                if (prop->setter_ && !prop->setter_->Skip())
                {
                    source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, 1);\n",
                                            klass->GetName().CString(), prop->setter_->name_.CString());
                    source.Append("duk_put_prop_string(ctx, -2, \"set\");\n");
                }

                pnames[j][0] = tolower(pnames[j][0]);
                source.AppendWithFormat("duk_put_prop_string(ctx, -2, \"%s\");\n", pnames[j].CString());

            }

            source.Append("duk_pop(ctx);\n");

        }
    }

    source += "\n}\n\n";

}
void GameEconomicGameClientStateSplash::SplashStatInit(void)
{
/// Get Needed SubSystems
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    Renderer* renderer = GetSubsystem<Renderer>();
    Graphics* graphics = GetSubsystem<Graphics>();
    UI* ui = GetSubsystem<UI>();

    FileSystem * filesystem = GetSubsystem<FileSystem>();

    /// Create variables (urho3d)
    String InputDataFile;

    InputDataFile.Append(filesystem->GetProgramDir().CString());
    InputDataFile.Append("Resources/Scenes/");
    InputDataFile.Append("Login1.xml");

    bool success;
    /// Check if the input data file exist
    if(filesystem->FileExists(InputDataFile))
    {
        /// Open file as a Urho3d Datafile
        dataFile = new File(context_, InputDataFile, FILE_READ);

        if (dataFile -> IsOpen())
        {

            /// Get File Extension
            String extension = GetExtension(InputDataFile);


            /// Determine file extension
            if (extension != ".xml")
            {
                ///success= Existence-> scene_ -> Load(dataFile);
                success = Existence-> scene_ -> LoadAsync(dataFile);
            }
            else
            {
                success= Existence-> scene_ ->LoadAsyncXML(dataFile);
            }
        }
        else
        {
            /// set is error
            success=false;
        }

    }

    /// on update
    SubscribeToEvent(E_UPDATE, HANDLER(GameEconomicGameClientStateSplash, HandlerSplashUpdate)); // Keep visible until rendering of the scene

    return;
}
Пример #6
0
QuitReason quit_check_for_error_state(const char *&qmsg, String &alertis)
{
    if (qmsg[0]=='|')
    {
        return kQuit_GameRequest;
    }
    else if (qmsg[0]=='!')
    {
        QuitReason qreason;
        qmsg++;

        if (qmsg[0] == '|')
        {
            qreason = kQuit_UserAbort;
            alertis = "Abort key pressed.\n\n";
        }
        else if (qmsg[0] == '?')
        {
            qmsg++;
            qreason = kQuit_ScriptAbort;
            alertis = "A fatal error has been generated by the script using the AbortGame function. Please contact the game author for support.\n\n";
        }
        else
        {
            qreason = kQuit_GameError;
            alertis.Format("An error has occurred. Please contact the game author for support, as this "
                "is likely to be a scripting error and not a bug in AGS.\n"
                "(ACI version %s)\n\n", EngineVersion.LongString.GetCStr());
        }

        alertis.Append(get_cur_script(5));

        if (qreason != kQuit_UserAbort)
            alertis.Append("\nError: ");
        else
            qmsg = "";
        return qreason;
    }
    else if (qmsg[0] == '%')
    {
        qmsg++;
        alertis.Format("A warning has been generated. This is not normally fatal, but you have selected "
            "to treat warnings as errors.\n"
            "(ACI version %s)\n\n%s\n", EngineVersion.LongString.GetCStr(), get_cur_script(5));
        return kQuit_GameWarning;
    }
    else
    {
        alertis.Format("An internal error has occurred. Please note down the following information.\n"
        "If the problem persists, post the details on the AGS Technical Forum.\n"
        "(ACI version %s)\n"
        "\nError: ", EngineVersion.LongString.GetCStr());
        return kQuit_FatalError;
    }
}
void GalleryForm::ConfigureTitle() {

	String newTitle;

	newTitle.Append(pGallery->GetCurrentItemIndex() + 1);
	newTitle.Append(L"/");
	newTitle.Append(pImagesPaths->GetCount());

	GetHeader()->SetTitleText(newTitle);

}
/// Save account information to a file
void GameEconomicGameClient::SaveConfiguration(Configuration &configuration)
{
    /// Get Resource
    ResourceCache * cache = GetSubsystem<ResourceCache>();
    FileSystem * fileSystem = GetSubsystem<FileSystem>();

    String configFileName;

    /// Set directory and path for network file
    configFileName.Append(fileSystem->GetProgramDir().CString());
    configFileName.Append("");
    configFileName.Append("Configuration.xml");


    /// Check if the account file information exist
    if(fileSystem->FileExists(configFileName.CString()))
    {
        fileSystem->Delete(configFileName.CString());
    }

    cout << "It got here "<<endl;

    File saveFile(context_, configFileName.CString(), FILE_WRITE);

    XMLFile * preferencefileconfig  = new XMLFile(context_);

    XMLElement configElem = preferencefileconfig   -> CreateRoot("Configuration");
    XMLElement GameModeConfigurationElement = configElem.CreateChild("GameModeConfiguration");
    XMLElement VideoConfigurationElement= configElem.CreateChild("VideoConfiguration");

    /// Set true false
    if(configuration.GameModeForceTablet==true)
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "true");
    }
    else
    {
        GameModeConfigurationElement.SetAttribute("GameModeForceTablet", "false");
    }

    /// Convert video bloom to float
    String VideoBloomParamValue1String(configuration.VideoBloomParam1);
    String VideoBloomParamValue2String(configuration.VideoBloomParam2);

    /// Copy values testing
    VideoConfigurationElement.SetAttribute("BloomParam1",VideoBloomParamValue1String);
    VideoConfigurationElement.SetAttribute("BloomParam2",VideoBloomParamValue2String);

    preferencefileconfig->Save(saveFile);

    return;
}
Пример #9
0
String PixInsightVersion::AsString( bool withCodename )
{
   Initialize();
   String v = String().Format( "PixInsight %s%02d.%02d.%02d.%04d",
               LE() ? "LE " : "", Major(), Minor(), Release(), Build() );
   if ( BetaRelease() != 0 )
      v.Append( String().Format( " %s%d", (BetaRelease() < 0) ? "RC" : "beta ", Abs( BetaRelease() ) ) );
   if ( withCodename )
      v.Append( ' ' + Codename() );
   if ( Confidential() )
      v.Append( " (confidential)" );
   return v;
}
Пример #10
0
bool 	SFtpReader::isChkFile(const File& tFile)
{
	LIBSSH2_SFTP_ATTRIBUTES 	tAttr;
	if (libssh2_sftp_stat((LIBSSH2_SFTP*)_pSessionSFtp, (char*)tFile.sFullName.c_str(), &tAttr) == -1)
	{
		String	sMsg; string sErrMsg = GetLastErrMsg();
		sMsg.Append(_("File access error (%s), continue? !!!"), tFile.sFullName.c_str());
		if (!sErrMsg.empty()) sMsg.Append("[%s]", sErrMsg.c_str());
		MsgBox(_("Error"), sMsg.c_str());
		return false;
	}
	return true;
}
Пример #11
0
bool	SFtpReader::Rename(File* pFile, const string& sRename)
{
	if (pFile == NULL) 
	{
		LOG_WRITE("Rename pFile is NULL !!!");
		return false;
	}

	string sRenameName = pFile->sName;
	if (sRenameName == "..") return false;

	if (sRename == "")
	{
		if (InputBox(_("Rename"), sRenameName) == ERROR) 
			return false;
	}
	else
		sRenameName = sRename;
	
	sRenameName = _sCurPath + sRenameName;

	LOG_WRITE("Rename - [%s] [%s]", pFile->sFullName.c_str(), sRenameName.c_str());

	if ( libssh2_sftp_rename_ex((LIBSSH2_SFTP*)_pSessionSFtp, 
								(char*)pFile->sFullName.c_str(), 
								pFile->sFullName.size(),
								(char*)sRenameName.c_str(),
								sRenameName.size(), 
								LIBSSH2_SFTP_RENAME_OVERWRITE |
								LIBSSH2_SFTP_RENAME_ATOMIC |
								LIBSSH2_SFTP_RENAME_NATIVE) == -1)
	{
		String	sMsg; string	sErrMsg;
		int		nRt = GetLastError( &sErrMsg );
		sMsg.Append(_("SFtp rename failure !!! [%s]"), sRename.c_str());
		if ( !sErrMsg.empty() ) sMsg.Append("%s", sErrMsg.c_str() );
		MsgBox(_("Error"), sMsg.c_str());
		
		if ( nRt == LIBSSH2_ERROR_SOCKET_TIMEOUT)
		{
			string sTmp = _sCurPath;
			Destroy();
			Init(_sInitFile);
			_sCurPath = sTmp;
		}
		return false;
	}
	return true;
}
Пример #12
0
Value AndExpr::Evaluate(SymbolTable *scope, EvalContext& context, bool asbool)
{
	// Scope override; must do this for every expression that might contain an identifier
	if(this->scope != NULL)
		scope = this->scope;

	// Lowering A and B:
	//  [A]
	//  [iffalse goto end]
	//  [B]
	//  label end:

	String* value = new String();

	// Create internal label
	string labelbase = context.GetUniqueLabelName();
	Anchor* endanchor = new Anchor(labelbase + ".end");

	// Evaluate the first operand
	value->Append( a->Evaluate(scope, context, true).ToCodeString() );

	// Add a jump to the end if the first operand is false
	value->Code("1B 02 FF FF FF FF");
	value->AddReference(value->GetPos()-4, endanchor);

	// TODO:
	//  Hm. I just realized that some boolean expressions (and and or) rely on reference
	//  resolution to operate correctly. Thus, it doesn't make sense to use them in ROM
	//  write statements at the moment, because ROM write statements occur after normal
	//  resolution, but without doing any resolution themselves. Perhaps ROM write statements
	//  should have a special resolution step to take care of stuff like this. (Perhaps
	//  the ROM data itself should be represented as a ByteChunk, with refs?)
	//  Anyway, don't worry about this for now, since using boolean expressions in a ROM
	//  write statement is not a very likely usage scenario.
	// UPDATE: 11/11/2008
	//  This issue has been fixed by moving the evaluation of ROM write subexpressions
	//  back to the evaluation pass of the compiler, and simply caching the results and
	//  resolving references in a later pass. However, it still might be worthwhile to
	//  consider alternative solutions; whole-ROM resolution seems interesting for example.

	// Evaluate the second operand
	value->Append( b->Evaluate(scope, context, true).ToCodeString() );

	// Set the position of the end label
	value->AddAnchor(endanchor);

	return Value(value);
}
bool ForUsDocForm::UpdateCalendarDisplay(void) {

	DateTime oldValue = __pSelectCalendar->GetTime();
	result r = E_SUCCESS;

	for (int i = 0; i < DAY_BUTTON_COUNT; i++) {
		r = __pDayBtn[i]->SetShowState(false);
		TryReturn(!IsFailed(r), false,
				"DayButton::SetShowStqte() failed with [%s]", GetErrorMessage(r));
	}
	r = __pSelectCalendar->SetTimeField(TIME_FIELD_DAY_OF_MONTH, 1);
	int offset = __pSelectCalendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK) - 1;
	int date = __pSelectCalendar->GetTimeField(TIME_FIELD_DAY_OF_MONTH);

	int i = offset;
	do {
		String value(L"");
		value.Append(date);
		__pDayBtn[i]->SetEnabled(true);
		__pDayBtn[i]->SetText(value);
		r = __pDayBtn[i]->SetShowState(true);
		TryReturn(!IsFailed(r), false,
				"Button::SetShowState() failed with [%s]", GetErrorMessage(r));
		r = __pSelectCalendar->AddTimeField(TIME_FIELD_DAY_OF_MONTH, 1);
		TryReturn(!IsFailed(r), false,
				"Calendar::AddTimeField failed with [%s]", GetErrorMessage(r));
		date = __pSelectCalendar->GetTimeField(TIME_FIELD_DAY_OF_MONTH);

		i++;

	} while (date != 1 && i < DAY_BUTTON_COUNT);

	__pSelectCalendar->SetTime(oldValue);

	String year = L"";
	year.Append(__pSelectCalendar->GetTimeField(TIME_FIELD_YEAR));
	__pEditFields[0]->SetText(year);

	String month = L"";
	month.Append(__pSelectCalendar->GetTimeField(TIME_FIELD_MONTH));
	__pEditFields[1]->SetText(month);

	SetFocus();
	RequestRedraw(true);

	return true;

}
String BonkEnc::Utilities::LocalizeNumber(Int64 number)
{
	String	 nString = String::FromInt(number);
	String	 retVal;
	String	 separator;

	char	*buffer_a = new char [256];
	wchar_t	*buffer_w = new wchar_t [256];

	if (Setup::enableUnicode)	GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, buffer_w, 256);
	else				GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, buffer_a, 256);

	if (Setup::enableUnicode)	separator = buffer_w;
	else				separator = buffer_a;

	delete [] buffer_a;
	delete [] buffer_w;

	for (Int i = 0; i < nString.Length(); i++)
	{
		if ((nString.Length() - i) % 3 == 0 && i > 0) retVal.Append(separator);

		retVal[retVal.Length()] = nString[i];
	}

	return retVal;
}
Пример #15
0
bool DatabaseForm::CreateDatabase(){

	Database pDatabase;
	String sql;
	String sql2;
	String statement;

	result r = E_SUCCESS;

	// create the database if it doesn't exist
	r = pDatabase.Construct(__databaseName, true);
	if (IsFailed(r)) return false;


	//pDatabase = new Database();
	//if (pDatabase == null) return false;
	//r = pDatabase->Construct(pDatabaseName,true);
	//if (IsFailed(r)) return false;

	// Create the main table
	sql.Append(L"CREATE TABLE IF NOT EXISTS movies (id INTEGER PRIMARY KEY AUTOINCREMENT, description TEXT)");
	r = pDatabase.ExecuteSql(sql, true);

	if (IsFailed(r)) return false;

	return true;
}
Пример #16
0
bool DatabaseForm::AddItemToDatabase(DatabaseItem* newItem)
{

	String        notesString(L"very empty");
	Database      pDatabase;
	DbStatement*  pStmt;
	DbEnumerator* pEnum;
	String        statement;
	result        r = E_SUCCESS;

	pDatabase.BeginTransaction();

	// Prepare the INSERT statement
	statement.Append(L"INSERT INTO movies(description) VALUES (?, ?)");
	pStmt = pDatabase.CreateStatementN(statement);

   // Bind the values from the current entry into this statement
	pStmt->BindString(0, newItem->__description);

	// Now execute the statement with our values included
	pEnum = pDatabase.ExecuteStatementN(*pStmt);
	pDatabase.CommitTransaction();

	delete pEnum;
	delete pStmt;
	return true;
}
Пример #17
0
void HTTPBodyResultMapper::ReadBody(String &body, std::istream &is, Context &ctx) {
	StartTrace(HTTPBodyResultMapper.ReadBody);

	long contentLength = ctx.Lookup("Mapper.content-length", -1L);
	Trace("contentLength: " << contentLength);
	if (contentLength > -1) {
		body.Append(is, contentLength);
	} else {
		char c;
		while (is.get(c).good()) {
			body.Append(c);
		}
	}
	Trace("Body[" << body.Length() << "]");
	Trace("<" << body << ">");
}
Пример #18
0
void	Editor::GotoLine()
{
	string	sNumber;
	int		nLine;

	if (InputBox(_("go to line number."), sNumber) == -1) return;

	for (int n=0; n< (int)sNumber.size(); n++)
	{
		if (isdigit((char)sNumber[n]) == 0)
		{
			String sMsg;
			sMsg.Append(_("not digit [%s"), sNumber.c_str());
			MsgBox(_("Error"), sMsg.c_str());
			return;
		}
	}

	if (sNumber.size() == 0) return;
	nLine = atoi(sNumber.c_str());

	if (nLine < (int)_vText.size())
	{
		_nCurLine = nLine-1;
		if (_nCurLine <= 0) _nCurLine = 0;
		_nFirstLine = _nCurLine - 10;
		if (_nFirstLine <= 0) _nFirstLine = 0;
	}
	else
	{
		_nCurLine = (int)_vText.size()-1;
		_nFirstLine = _nCurLine - 10;
	}
	_EditMode = EDIT;
}
Пример #19
0
String  ParameterProcess::ToString ()
{
  String  statusStr ("");

  statusStr.Append (curStatus);

  String  class0Name;
  String  class1Name;

  if  (!class0)
    class0Name = "NoName";
  else
    class0Name = class0->Name ();

  if  (!class1)
    class1Name = "NoName";
  else
    class1Name = class1->Name ();
    

  statusStr << "\t" << processNum
            << "\t" << jobId 
            << "\t" << class0Name
            << "\t" << class1Name
            << "\t" << cParm
            << "\t" << gammaParm
            << "\t" << aParm
            << "\t" << highestAccuracy;
            
  
  return  statusStr;
} /* ToString */
Пример #20
0
/*
================
idLexer::GetLastWhiteSpace
================
*/
int idLexer::GetLastWhiteSpace( String &whiteSpace ) const {
	whiteSpace.Clear();
	for ( const char *p = whiteSpaceStart_p; p < whiteSpaceEnd_p; p++ ) {
		whiteSpace.Append( *p );
	}
	return whiteSpace.GetLength();
}
Пример #21
0
void DatabaseForm::ReadItemsFromDatabase()
{
	Database pDatabase;
	DbEnumerator* pEnum;
  	String sql;
	String statement;

	result r = E_SUCCESS;

	r = pDatabase.Construct(__databaseName, false);

	sql.Append(L"select id, description from movies");
	pEnum = pDatabase.QueryN(sql);
	String description;
	int	   id;

   while( pEnum->MoveNext()== E_SUCCESS )
	{
		pEnum->GetIntAt(0, id);
		pEnum->GetStringAt(1, description);

		// Store the item in our data structure
		DatabaseItem* newItem = new DatabaseItem(description);
		newItem->SetIndex(id);
		// Display the item in our user interface using our own method
		AddItemToList(newItem);
		}
	if (pEnum != null)
		delete pEnum;
}
Пример #22
0
string	SFtpReader::GetPwd() const
{
	char		cRealPath[4096];
	
	try
	{
		const char* cPath = ".";
		int nRt = 0;
		if ( (nRt = libssh2_sftp_realpath(	(LIBSSH2_SFTP*)_pSessionSFtp,
                          			cPath,
                          			cRealPath, sizeof(cRealPath))) == -1)
		{
			throw Exception("libssh2_sftp_realpath fail.");
		}
		cRealPath[ nRt ] = 0;
		LOG_WRITE("Real Path GetPwd :: %s", cRealPath);
	}
	catch(Exception& ex)
	{
		String	sMsg; 
		sMsg.Append("%s", (char*)ex);		
		MsgBox(_("Error"), sMsg.c_str());
		return "";
	}
	return cRealPath;
}
Пример #23
0
void JSClassWriter::GenerateNonStaticFunctionsSource(String& source, String& packageName)
{
    source.AppendWithFormat("js_class_get_prototype(ctx, \"%s\", \"%s\");\n", packageName.CString(), klass_->GetName().CString());

    for (unsigned i = 0; i < klass_->functions_.Size(); i++)
    {
        JSBFunction* function = klass_->functions_.At(i);

        if (function->Skip())
            continue;

        if (function->IsConstructor() || function->IsDestructor())
            continue;

        if (function->IsStatic())
            continue;

        if (function->FirstDefaultParameter() != -1)
        {
            source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, DUK_VARARGS);\n", klass_->GetName().CString(), function->GetName().CString());
        }
        else
        {
            source.AppendWithFormat("duk_push_c_function(ctx, jsb_class_%s_%s, %i);\n", klass_->GetName().CString(), function->GetName().CString(), (int)function->GetParameters().Size());
        }

        String scriptName = function->GetName();
        scriptName[0] = tolower(scriptName[0]);
        source.AppendWithFormat("duk_put_prop_string(ctx, -2, \"%s\");\n", scriptName.CString());

    }
    source.Append("duk_pop(ctx);\n");
}
Пример #24
0
String Version::AsString()
{
   String v = String().Format( "PCL %02d.%02d.%02d.%04d", Major(), Minor(), Release(), Build() );
   if ( BetaRelease() != 0 )
      v.Append( String().Format( " beta %d", BetaRelease() ) );
   return v;
}
Пример #25
0
Value FlagExpr::Evaluate(SymbolTable* scope, EvalContext& context, bool asbool)
{
	// When evaluating as a boolean, we want to use the "load flag" command, 07.
	// This is so an expression "flag <x>" can be used in normal expressions as
	// a flag number (e.g., set(myflag)) and in boolean conditions (e.g.,
	//  if myflag { }). Just sugar, really.
	// Thus, if statements and "and", "or", "not" expressions pass asbool=true.
	// All other nodes ignore this parameter, using the default value of false.
	//
	// Honestly, this feels like a hack, and it comes at the cost of some possibly
	// unintuitive behavior. However, it seems useful to allow the use of flags
	// in conditionals this way... Maybe there's a better alternative.

	String* value = new String();

	if(asbool) value->Code("07");

	Value flagval = expr->Evaluate(scope, context, false);

	String flagstr = flagval.ToCodeString();

	value->Append(flagstr.Substring(0,2));

	return Value(value);
}
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;
}
Пример #27
0
void
DebugConsole::CleanUp(String& str) {
	Uri uri;
	uri.SetUri(str);
	str.Clear();
	str.Append(uri.ToString());
}
Пример #28
0
bool	SFtpReader::Read(const string& sDir)
{
	if (_pSessionSFtp == NULL) return false;

	try
	{
		if ( _pDir )
		{
			libssh2_sftp_close_handle((LIBSSH2_SFTP_HANDLE*)_pDir);
			_pDir = NULL;
		}

		string	sDirTmp = GetRealPath( sDir );
		
		LIBSSH2_SFTP_HANDLE* pDir;
		pDir = libssh2_sftp_opendir( (LIBSSH2_SFTP*)_pSessionSFtp, (char*)sDirTmp.c_str() );
		
		if ( !pDir )
			throw Exception("SFtp open dir failed.");

		_pDir = (void*)pDir;
		_sCurPath = sDirTmp;
		if (_sCurPath.substr(_sCurPath.size()-1, 1) != "/") 
			_sCurPath = _sCurPath + '/';

		LOG_WRITE("SFtp Read :: %s", _sCurPath.c_str());
		//cout << "SFtp Read :: " << _sCurPath << endl;
	}
	catch(Exception& ex)
	{
		String	sMsg; string	sErrMsg;
		int		nRt = GetLastError( &sErrMsg );
		sMsg.Append(_("sftp file reading failure."));
		if ( !sErrMsg.empty() ) sMsg.Append("%s", sErrMsg.c_str() );		
		MsgBox(_("Error"), sMsg.c_str());
		
		if ( nRt == LIBSSH2_ERROR_SOCKET_TIMEOUT)
		{
			string sTmp = _sCurPath;
			Destroy();
			Init(_sInitFile);
			_sCurPath = sTmp;
		}
		return false;
	}
	return true;
}
Пример #29
0
void FileStream::Open(const String &file_name, FileOpenMode open_mode, FileWorkMode work_mode)
{
    String mode;

    if (open_mode == kFile_Open)
    {
        if (work_mode == kFile_Read)
        {
            mode.AppendChar('r');
        }
        else if (work_mode == kFile_Write || work_mode == kFile_ReadWrite)
        {
            mode.Append("r+");
        }
    }
    else if (open_mode == kFile_Create)
    {
        if (work_mode == kFile_Write)
        {
            mode.AppendChar('a');
        }
        else if (work_mode == kFile_Read || work_mode == kFile_ReadWrite)
        {
            mode.Append("a+");
        }
    }
    else if (open_mode == kFile_CreateAlways)
    {
        if (work_mode == kFile_Write)
        {
            mode.AppendChar('w');
        }
        else if (work_mode == kFile_Read || work_mode == kFile_ReadWrite)
        {
            mode.Append("w+");
        }
    }

    if (mode.IsEmpty())
    {
        // TODO: warning to the log
        return;
    }

    mode.AppendChar('b');
    _file = fopen(file_name, mode);
}
  Sensor* SensorRegistry::GetSensorByName(const Identifier& rName)
  {
    if (m_pSensorRegistryPrivate->m_SensorMap.find(rName) != m_pSensorRegistryPrivate->m_SensorMap.end())
    {
      Sensor* pSensor = m_pSensorRegistryPrivate->m_SensorMap[rName];

      assert(pSensor != NULL);

      return pSensor;
    }

    String errorMessage;
    errorMessage.Append("Sensor not registered: [");
    errorMessage.Append(rName.ToString());
    errorMessage.Append("]");
    throw Exception(errorMessage);
  }