Exemplo n.º 1
0
bool Scheme::CheckName()
{
	CFile cfile;

	bool bRet = false;
	
	if( cfile.Open(m_SchemeFile) )
	{
		SchemeHdrRec hdr;
		bRet = InitialLoad(cfile, hdr);
		cfile.Close();
	}

	return bRet;
}
bool FdoRdbmsLongTransactionReader::ReadNext ()

// +---------------------------------------------------------------------------
// | The function reads the next long transaction info data set. It returns
// | TRUE back to the calling routine if there is no more data to be read,
// | FALSE otherwise.
// +---------------------------------------------------------------------------

{

    try {

      // If the long transaction data hasn't been requested yet, issue the
      // request.

      if (!lt_info_loaded) {

          InitialLoad();
          lt_info_loaded = true;

          reader_positioned     = true;
          valid_reader_position = true;

      }  //  if (!lt_infos_loaded) ...

      // Position the query handler reader to be ready to get the first set
      // of data.

      try {

        if (!lt_query_handler->ReadNext()) {

            reader_positioned     = false;
            valid_reader_position = false;
            return false;

        }  //  if (!lt_query_handler->ReadNext()) ...

      }  //  try ...

      catch ( ... ) {

        throw FdoCommandException::Create(
               NlsMsgGet(FDORDBMS_360,
                         "Failed to read next long transaction info data set"));

      }  //  catch ...

      return true;

    }  //  try ...

    catch (FdoCommandException *ex) {

      ex;
      ClearMemory();
      throw;

    }  //  catch (FdoCommandException *ex)

    catch (FdoException *ex) {

      ClearMemory();
      throw FdoCommandException::Create(ex->GetExceptionMessage(), ex, ex->GetNativeErrorCode());

    }  //  catch (FdoException *ex)

    catch ( ... ) {

      ClearMemory();
      throw;

    }  // catch ( ... ) ...

}  //  ReadNext ()
Exemplo n.º 3
0
void Scheme::Load(CScintilla& sc, bool allSettings, LPCTSTR filename)
{
	CFile cfile;
	SchemeHdrRec hdr;
	MsgRec Msg;
	TextRec Txt;
	PropRec Prp;
	char Next2;

	memset(&m_CommentSpec, 0, sizeof(CommentSpecRec));

	if( filename )
	{
		SetFileName(filename);
	}

	if( cfile.Open(m_SchemeFile) )
	{
		// Check the file is OK and read the header.
		if(!InitialLoad(cfile, hdr))
		{
			UNEXPECTED(_T("Tried to load invalid binary scheme file at run-time"));
			cfile.Close();
			return;
		}

		// Set the defaults - these may be changed by the load.
		SetupScintilla(sc, allSettings);

		std::vector<char> buf;

		while (cfile.GetPosition() < cfile.GetLength())
		{
			cfile.Read(&Next2, sizeof(char));
			switch(Next2)
			{
				case nrMsgRec:
					cfile.Read(&Msg, sizeof(MsgRec));
					sc.SPerform(Msg.MsgNum, Msg.wParam, Msg.lParam);
					break;
				case nrTextRec:
					{
						cfile.Read(&Txt, sizeof(TextRec));
						buf.resize(Txt.TextLength + 1);
						cfile.Read(&buf[0], Txt.TextLength*sizeof(char));
						buf[Txt.TextLength] = '\0';
						switch(Txt.TextType)
						{
							case ttFontName : 
								sc.SPerform(SCI_STYLESETFONT, Txt.wParam, (long)&buf[0]);
								break;
							case ttKeywords : 
								sc.SetKeyWords(Txt.wParam, &buf[0]);
								break;
							case ttLexerLanguage : 
								{
									sc.SPerform(SCI_SETLEXERLANGUAGE, 0, (long)&buf[0]);
									m_Lexer = &buf[0];
								}
								break;
							case ttWordChars :
								{
									sc.SPerform(SCI_SETWORDCHARS, 0, (long)&buf[0]);
								}
								break;
						}
					}
					break;
				case nrPropRec:
				{
					cfile.Read(&Prp, sizeof(PropRec));
					buf.resize(Prp.NameLength + 1);
					cfile.Read(&buf[0], Prp.NameLength * sizeof(char));
					buf[Prp.NameLength] = '\0';

					std::vector<char> buf2(Prp.ValueLength + 1);
					cfile.Read(&buf2[0], Prp.ValueLength * sizeof(char));
					buf2[Prp.ValueLength] = '\0';
					sc.SPerform(SCI_SETPROPERTY, (long)&buf[0], (long)&buf2[0]);
				}
				break;
				case nrCommentRec:
				{
					// skip here...
					cfile.Read(&m_CommentSpec, sizeof(CommentSpecRec));
				}
				break;
			}
		}

		cfile.Close();

		if((hdr.Flags & fldEnabled) && OPTIONS->GetCached(Options::OFoldingEnabled))
		{
			///@todo obviously these details need to come from settings somewhere...
			sc.SPerform(SCI_SETPROPERTY, (WPARAM)"fold", (LPARAM)"1");
			sc.SPerform(SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
			sc.SPerform(SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
			sc.SPerform(SCI_SETMARGINSENSITIVEN, 2, true);
			sc.SPerform(SCI_SETMARGINWIDTHN, 2, 14);
			sc.SPerform(SCI_SETFOLDFLAGS, 16, 0);
			sc.SetFoldingMargins(efsVSNet);

			sc.SPerform(SCI_SETPROPERTY, (WPARAM)"fold.compact", (LPARAM)((hdr.Flags & fldCompact) ? "1" : "0"));
			
			if(hdr.Flags & fldComments)
				sc.SPerform(SCI_SETPROPERTY, (WPARAM)"fold.comment", (LPARAM)"1");

			if(hdr.Flags & fldPreProc)
				sc.SPerform(SCI_SETPROPERTY, (WPARAM)"fold.preprocessor", (LPARAM)"1");

			if(hdr.Flags & fldElse) 
				sc.SPerform(SCI_SETPROPERTY, (WPARAM)"fold.at.else", (LPARAM)"1");
		}

		if(hdr.Flags & schOverrideTabs)
		{
			if(hdr.Flags & schUseTabs)
				sc.SPerform(SCI_SETUSETABS, 1, 0);
			else
				sc.SPerform(SCI_SETUSETABS, 0, 0);
		}

		if(hdr.Flags & schOverrideTabSize)
		{
			sc.SPerform(SCI_SETTABWIDTH, hdr.TabWidth, 0);
		}

	}
	else
	{
		// Show an error or something...
	}
}
Exemplo n.º 4
0
/**
 * This function allocates a list of StyleDetails objects containing
 * the settings used by this scheme. The caller must free the list
 * and the items contained within.
 */
StylesList* Scheme::CreateStylesList()
{
	CFile			cfile;
	SchemeHdrRec	hdr;
	TextRec			Txt;
	MsgRec			Msg;
	char			Next2;

	if( cfile.Open(m_SchemeFile) )
	{
		if (!InitialLoad(cfile, hdr))
			return NULL;

		StylesList* pList = new StylesList;
		StyleDetails* pDefault = new StyleDetails;
		StyleDetails* pS = NULL;
		pDefault->Key = STYLE_DEFAULT;
		pList->AddStyle(pDefault);
		int curStyle = -1;

		std::vector<char> buf;

		// Find the default style...
		while (cfile.GetPosition() < cfile.GetLength())
		{
			cfile.Read(&Next2, sizeof(char));
			switch(Next2)
			{
				case nrMsgRec:
				{
					cfile.Read(&Msg, sizeof(MsgRec));
					if(Msg.MsgNum == SCI_STYLESETBOLD || Msg.MsgNum == SCI_STYLESETITALIC ||
						Msg.MsgNum == SCI_STYLESETUNDERLINE || Msg.MsgNum == SCI_STYLESETSIZE ||
						Msg.MsgNum == SCI_STYLESETFORE || Msg.MsgNum == SCI_STYLESETBACK ||
						Msg.MsgNum == SCI_STYLESETEOLFILLED)
					{
						if(Msg.wParam != curStyle)
						{
							if(Msg.wParam == STYLE_DEFAULT)
							{
								pS = pDefault;
							}
							else
							{
								pS = new StyleDetails(*pDefault);
								pS->Key = Msg.wParam;
								pList->AddStyle(pS);
							}
							curStyle = Msg.wParam;
						}
						
						switch(Msg.MsgNum)
						{
						case SCI_STYLESETBOLD:
							pS->Bold = (Msg.lParam != 0);
							break;
						case SCI_STYLESETITALIC:
							pS->Italic = (Msg.lParam != 0);
							break;
						case SCI_STYLESETUNDERLINE:
							pS->Underline = (Msg.lParam != 0);
							break;
						case SCI_STYLESETSIZE:
							pS->FontSize = Msg.lParam;
							break;
						case SCI_STYLESETFORE:
							pS->ForeColor = Msg.lParam;
							break;
						case SCI_STYLESETBACK:
							pS->BackColor = Msg.lParam;
							break;
						case SCI_STYLESETEOLFILLED:
							pS->EOLFilled = (Msg.lParam != 0);
							break;
						};
					}
				}
				break;

				case nrTextRec:
				{
					cfile.Read(&Txt, sizeof(TextRec));
					if(Txt.TextType == ttFontName)
					{
						if(Txt.wParam != curStyle)
						{
							if(Txt.wParam == STYLE_DEFAULT)
							{
								pS = pDefault;
							}
							else
							{
								pS = new StyleDetails(*pDefault);
								pS->Key = Txt.wParam;
								pList->AddStyle(pS);
							}
							curStyle = Txt.wParam;
						}

						buf.resize(Txt.TextLength + 1);
						cfile.Read(&buf[0], Txt.TextLength * sizeof(char));
						buf[Txt.TextLength] = '\0';
						switch(Txt.TextType)
						{
							case ttFontName : 
								pS->FontName = CA2CT(&buf[0]);
								break;
						}
					}
					else 
						cfile.Seek(Txt.TextLength * sizeof(char), CFile::current);
				}
				break;

				case nrCommentRec:
				{
					// skip here...
					cfile.Seek(sizeof(CommentSpecRec), CFile::current);
				}
				break;
			}
		}

		cfile.Close();

		return pList;
	}

	return NULL;
}