コード例 #1
0
ファイル: eqw_http_handler.cpp プロジェクト: Leere/Server
void EQWHTTPHandler::ProcessAndSend(const std::string &str) {
	std::string::size_type len = str.length();
	std::string::size_type start = 0;
	std::string::size_type pos, end;

	while((pos = str.find("<?", start)) != std::string::npos) {
		//send all the crap leading up to the script block
		if(pos != start) {
			ProcessText(str.c_str() + start, pos-start);
		}

		//look for the end of this script block...
		end = str.find("?>", pos+2);
		if(end == std::string::npos) {
			//terminal ?> not found... should issue a warning or something...
			std::string scriptBody = str.substr(pos+2);
			ProcessScript(scriptBody);
			start = len;
			break;
		} else {
			//script only consumes some of this buffer...
			std::string scriptBody = str.substr(pos+2, end-pos-2);
			ProcessScript(scriptBody);
			start = end + 2;
		}
	}

	//send whatever is left over
	if(start != len)
		ProcessText(str.c_str() + start, len-start);
}
コード例 #2
0
ファイル: InputParser.cpp プロジェクト: Ichthyostega/blender
CValue* CParser::GetValue(STR_String& txt, bool bFallbackToText)
{
	// returns parsed text into a value,
	// empty string returns NULL value !
	// if bFallbackToText then unparsed stuff is put into text

	CValue* result=NULL;
	CExpression* expr = ProcessText(txt);
	if (expr) {
		result = expr->Calculate();
		expr->Release();
	}
	if (result)
	{
		// if the parsed stuff lead to an errorvalue, don't return errors, just NULL
		if (result->IsError()) {
			result->Release();
			result=NULL;
			if (bFallbackToText) {
				if (txt.Length()>0)
				{
					result = new CStringValue(txt,"");
				}
			}
		}
	}
	return result;
}
コード例 #3
0
void CPDF_RenderStatus::ProcessObjectNoClip(
    const CPDF_PageObject* pObj,
    const CFX_AffineMatrix* pObj2Device) {
  FX_BOOL bRet = FALSE;
  switch (pObj->m_Type) {
    case PDFPAGE_TEXT:
      bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL);
      break;
    case PDFPAGE_PATH:
      bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_IMAGE:
      bRet = ProcessImage((CPDF_ImageObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_SHADING:
      bRet = ProcessShading((CPDF_ShadingObject*)pObj, pObj2Device);
      break;
    case PDFPAGE_FORM:
      bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device);
      break;
  }
  if (!bRet) {
    DrawObjWithBackground(pObj, pObj2Device);
  }
}
コード例 #4
0
ファイル: fpdf_render.cpp プロジェクト: gradescope/pdfium
void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj,
                                            const CFX_Matrix* pObj2Device) {
#if defined _SKIA_SUPPORT_
  DebugVerifyDeviceIsPreMultiplied();
#endif
  FX_BOOL bRet = FALSE;
  switch (pObj->GetType()) {
    case CPDF_PageObject::TEXT:
      bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr);
      break;
    case CPDF_PageObject::PATH:
      bRet = ProcessPath(pObj->AsPath(), pObj2Device);
      break;
    case CPDF_PageObject::IMAGE:
      bRet = ProcessImage(pObj->AsImage(), pObj2Device);
      break;
    case CPDF_PageObject::SHADING:
      ProcessShading(pObj->AsShading(), pObj2Device);
      return;
    case CPDF_PageObject::FORM:
      bRet = ProcessForm(pObj->AsForm(), pObj2Device);
      break;
  }
  if (!bRet)
    DrawObjWithBackground(pObj, pObj2Device);
#if defined _SKIA_SUPPORT_
  DebugVerifyDeviceIsPreMultiplied();
#endif
}
コード例 #5
0
void TextMessageProcessor::Run()
{
    // parse input.
    std::string error;
    if (!XmlToProtoMessage(m_input, &m_input_message, &error)) {
        LOG(ERROR)
            << "xml to text message failed. input [" << m_input
            << "] error [" << error << "]";
        return;
    }

    // record upstream message.
    // StorageRedisClient storage_client;
    // horoscope::UserMessages::Item item;
    // item.set_stamp(static_cast<uint32_t>(time(NULL)));
    // item.set_content(m_input_message.content());
    // item.set_result_flag(0);
    // storage_client.AddUserMessages(m_input_message.fromusername(), item);

    std::string content;
    if (!ConvertUtf8ToGbk(m_input_message.content(), &content))
        content.assign(m_input_message.content());

    int date_type = GetDateByText(content);
    mpserver::NewsMessage news_message;
    mpserver::TextMessage text_message;
    bool use_text = true;
    if (date_type == ChineseYangYear) {
        use_text = false;
        ProcessChineseYangYear(&news_message, use_text, &text_message);
    }else if (date_type == ThisYear) {
        use_text = false;
        ProcessYear(&news_message, use_text, &text_message);
    }else if (content.find("日报") != std::string::npos) {
        use_text = false;
        ProcessDailyReport(&news_message, use_text, &text_message);
    }else {
        ProcessText(&text_message);
    }

    // serialize output.
    m_output->clear();
    bool succ = true;
    if (use_text) {
        succ = ProtoMessageToXmlWithRoot(text_message, m_output, &error);
    } else {
        succ = ProtoMessageToXmlWithRoot(news_message, m_output, &error);
    }

    if (!succ) {
        LOG(ERROR)
            << "message to xml failed. text message ["
            << text_message.ShortDebugString()
            << "] news message ["
            << news_message.ShortDebugString()
            << "] error [" << error << "]";
        return;
    }
}
コード例 #6
0
ファイル: fpdf_render.cpp プロジェクト: gradescope/pdfium
void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
                                        const CFX_Matrix* pObj2Device) {
  if (!ClipPath) {
    if (m_LastClipPath) {
      m_pDevice->RestoreState(true);
      m_LastClipPath.SetNull();
    }
    return;
  }
  if (m_LastClipPath == ClipPath)
    return;

  m_LastClipPath = ClipPath;
  m_pDevice->RestoreState(true);
  int nClipPath = ClipPath.GetPathCount();
  for (int i = 0; i < nClipPath; ++i) {
    const CFX_PathData* pPathData = ClipPath.GetPath(i).GetObject();
    if (!pPathData)
      continue;

    if (pPathData->GetPointCount() == 0) {
      CFX_PathData EmptyPath;
      EmptyPath.AppendRect(-1, -1, 0, 0);
      int fill_mode = FXFILL_WINDING;
      m_pDevice->SetClip_PathFill(&EmptyPath, nullptr, fill_mode);
    } else {
      int ClipType = ClipPath.GetClipType(i);
      m_pDevice->SetClip_PathFill(pPathData, pObj2Device, ClipType);
    }
  }
  int textcount = ClipPath.GetTextCount();
  if (textcount == 0)
    return;

  if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
      !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) {
    return;
  }

  std::unique_ptr<CFX_PathData> pTextClippingPath;
  for (int i = 0; i < textcount; ++i) {
    CPDF_TextObject* pText = ClipPath.GetText(i);
    if (pText) {
      if (!pTextClippingPath)
        pTextClippingPath.reset(new CFX_PathData);
      ProcessText(pText, pObj2Device, pTextClippingPath.get());
      continue;
    }

    if (!pTextClippingPath)
      continue;

    int fill_mode = FXFILL_WINDING;
    if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH)
      fill_mode |= FXFILL_NOPATHSMOOTH;
    m_pDevice->SetClip_PathFill(pTextClippingPath.get(), nullptr, fill_mode);
    pTextClippingPath.reset();
  }
}
コード例 #7
0
ファイル: Text.cpp プロジェクト: ClementVidal/sable.sable
Void CText::SetText( String string )
{
	if( StringCompare( string, m_Text.GetBuffer() ) == 0 )
		return;

	StringCopy( string, m_Text.GetBuffer(), m_Capacity );
	ProcessText();
}
コード例 #8
0
void CGUISettingsSliderControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  m_buttonControl.SetFocus(HasFocus());
  m_buttonControl.SetPulseOnSelect(m_pulseOnSelect);
  m_buttonControl.SetEnabled(m_enabled);
  m_buttonControl.Process(currentTime, dirtyregions);
  ProcessText();
  CGUISliderControl::Process(currentTime, dirtyregions);
}
コード例 #9
0
ファイル: menu.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Purpose: Message handler for ShowMenu message
//   takes four values:
//		short: a bitfield of keys that are valid input
//		char : the duration, in seconds, the menu should stay up. -1 means is stays until something is chosen.
//		byte : a boolean, TRUE if there is more string yet to be received before displaying the menu, false if it's the last string
//		string: menu string to display
//  if this message is never received, then scores will simply be the combined totals of the players.
//-----------------------------------------------------------------------------
void CHudMenu::MsgFunc_ShowMenu( bf_read &msg)
{
	m_bitsValidSlots = (short)msg.ReadWord();
	int DisplayTime = msg.ReadChar();
	int NeedMore = msg.ReadByte();

	if ( DisplayTime > 0 )
	{
		m_flShutoffTime = m_flOpenCloseTime + DisplayTime + gpGlobals->realtime;

	}
	else
	{
		m_flShutoffTime = -1;
	}

	if ( m_bitsValidSlots )
	{
		char szString[2048];
		msg.ReadString( szString, sizeof(szString) );

		if ( !m_fWaitingForMore ) // this is the start of a new menu
		{
			Q_strncpy( g_szPrelocalisedMenuString, szString, sizeof( g_szPrelocalisedMenuString ) );
		}
		else
		{  // append to the current menu string
			Q_strncat( g_szPrelocalisedMenuString, szString, sizeof( g_szPrelocalisedMenuString ), COPY_ALL_CHARACTERS );
		}

		if ( !NeedMore )
		{  
			GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
			m_nSelectedItem = -1;
			
			// we have the whole string, so we can localise it now
			char szMenuString[MAX_MENU_STRING];
			Q_strncpy( szMenuString, ConvertCRtoNL( hudtextmessage->BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ), sizeof( szMenuString ) );
			g_pVGuiLocalize->ConvertANSIToUnicode( szMenuString, g_szMenuString, sizeof( g_szMenuString ) );
			
			ProcessText();
		}

		m_bMenuDisplayed = true;
		m_bMenuTakesInput = true;

		m_flSelectionTime = gpGlobals->curtime;
	}
	else
	{
		HideMenu();
	}

	m_fWaitingForMore = NeedMore;
}
コード例 #10
0
ファイル: Text.cpp プロジェクト: ClementVidal/sable.sable
Void CText::WriteFormattedText( String format, ... )
{
    va_list args;
    va_start( args, format );

    StringSetFormattedTextVaList( m_Text.GetBuffer(), m_Text.GetItemCount(), format, args ); 

	ProcessText();

    va_end( args );
}
コード例 #11
0
ファイル: eqw_http_handler.cpp プロジェクト: Leere/Server
void EQWHTTPHandler::ProcessScript(const std::string &script_body) {
	const char *script = script_body.c_str();
	if(strcmp("perl", script) == 0)
		script += 4;	//allow <?perl

//	printf("Script: ''''%s''''\n\n", script_body.c_str());

	GetParser()->EQW_eval("testing", script_body.c_str());
	const std::string &res = EQW::Singleton()->GetOutput();
	if(!res.empty()) {
		ProcessText(res.c_str(), res.length());
		EQW::Singleton()->ClearOutput();
	}
}
コード例 #12
0
ファイル: menu.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Purpose: hud scheme settings
//-----------------------------------------------------------------------------
void CHudMenu::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	SetPaintBackgroundEnabled( false );

	// set our size
	int screenWide, screenTall;
	int x, y;
	GetPos(x, y);
	GetHudSize(screenWide, screenTall);
	SetBounds(0, y, screenWide, screenTall - y);

	ProcessText();
}
コード例 #13
0
ファイル: SyntaxDlg.cpp プロジェクト: yantrabuddhi/poesie
void CSyntaxDlg::OnGenerate() 
{
  	CStdioFile rfile( m_strTagPath,  CFile::modeRead | CFile::typeText );
	CArchive rar( & rfile, CArchive::load );
	if( m_bTitles )
		ProcessTitles( rar ); 
	else
		ProcessText( rar );
	rar.Close();	
	rfile.Close();
	WriteReportFile();
	m_strTagPath = "";
	EnableControls( FALSE );
	GetDlgItem( IDC_SYN_FILENAME )->SetWindowText( "Keine Datei ausgewählt" );
}
コード例 #14
0
void CGUISettingsSliderControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  if (m_bInvalidated)
  {
    float sliderPosX = m_buttonControl.GetXPosition() + m_buttonControl.GetWidth() - m_width - m_buttonControl.GetLabelInfo().offsetX;
    float sliderPosY = m_buttonControl.GetYPosition() + (m_buttonControl.GetHeight() - m_height) * 0.5f;
    CGUISliderControl::SetPosition(sliderPosX, sliderPosY);
  }
  m_buttonControl.SetFocus(HasFocus());
  m_buttonControl.SetPulseOnSelect(m_pulseOnSelect);
  m_buttonControl.SetEnabled(m_enabled);
  m_buttonControl.DoProcess(currentTime, dirtyregions);
  ProcessText();
  CGUISliderControl::Process(currentTime, dirtyregions);
}
コード例 #15
0
ファイル: GUIButtonControl.cpp プロジェクト: MrMC/mrmc
void CGUIButtonControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  ProcessText(currentTime);
  if (m_bInvalidated)
  {
    m_imgFocus.SetWidth(GetWidth());
    m_imgFocus.SetHeight(m_height);

    m_imgNoFocus.SetWidth(GetWidth());
    m_imgNoFocus.SetHeight(m_height);
  }

  if (HasFocus())
  {
    unsigned int alphaChannel = m_alpha;
    if (m_pulseOnSelect)
    {
      unsigned int alphaCounter = m_focusCounter + 2;
      if ((alphaCounter % 128) >= 64)
        alphaChannel = alphaCounter % 64;
      else
        alphaChannel = 63 - (alphaCounter % 64);

      alphaChannel += 192;
      alphaChannel = (unsigned int)((float)m_alpha * (float)alphaChannel / 255.0f);
    }
    if (m_imgFocus.SetAlpha((unsigned char)alphaChannel))
      MarkDirtyRegion();

    m_imgFocus.SetVisible(true);
    m_imgNoFocus.SetVisible(false);
    m_focusCounter++;
  }
  else
  {
    m_imgFocus.SetVisible(false);
    m_imgNoFocus.SetVisible(true);
  }

  m_imgFocus.Process(currentTime);
  m_imgNoFocus.Process(currentTime);

  CGUIControl::Process(currentTime, dirtyregions);
}
コード例 #16
0
ファイル: menu.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudMenu::ShowMenu_KeyValueItems( KeyValues *pKV )
{
	m_flShutoffTime = -1;
	m_fWaitingForMore = 0;
	m_bitsValidSlots = 0;

	GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
	m_nSelectedItem = -1;
	
	g_szMenuString[0] = '\0';

	wchar_t wItem[128];

	int i = 0;
	for ( KeyValues *item = pKV->GetFirstSubKey(); item != NULL; item = item->GetNextKey() )
	{
		// Set this slot valid
		m_bitsValidSlots |= (1<<i);

		const char *pszItem = item->GetName();
		const wchar_t *wLocalizedItem = g_pVGuiLocalize->Find( pszItem );

		_snwprintf( wItem, sizeof( wItem )/ sizeof( wchar_t ), L"%d. %ls\n", i+1, wLocalizedItem );

		_snwprintf( g_szMenuString, sizeof( g_szMenuString )/ sizeof( wchar_t ), L"%ls%ls", g_szMenuString, wItem );

		i++;
	}

	// put a cancel on the end
	m_bitsValidSlots |= (1<<9);

	_snwprintf( wItem, sizeof( wItem )/ sizeof( wchar_t ), L"0. %ls", g_pVGuiLocalize->Find( "#Cancel" ) );

	_snwprintf( g_szMenuString, sizeof( g_szMenuString )/ sizeof( wchar_t ), L"%ls\n%ls", g_szMenuString, wItem );

	ProcessText();

	m_bMenuDisplayed = true;
	m_bMenuTakesInput = true;

	m_flSelectionTime = gpGlobals->curtime;
}
コード例 #17
0
ファイル: menu.cpp プロジェクト: Au-heppa/swarm-sdk
//-----------------------------------------------------------------------------
// Purpose: Local method to bring up a menu, mirroring code found in
//          MsgFunc_ShowMenu.
//
//   takes two values:
//		menuName  : menu name string 
//		validSlots: a bitfield describing the valid keys
//-----------------------------------------------------------------------------
void CHudMenu::ShowMenu( const char * menuName, int validSlots )
{
	m_flShutoffTime = -1;
	m_bitsValidSlots = validSlots;
	m_fWaitingForMore = 0;

	Q_strncpy( g_szPrelocalisedMenuString, menuName, sizeof( g_szPrelocalisedMenuString ) );

	GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("MenuOpen");
	m_nSelectedItem = -1;

	// we have the whole string, so we can localise it now
	char szMenuString[MAX_MENU_STRING];
	Q_strncpy( szMenuString, ConvertCRtoNL( hudtextmessage->BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ), sizeof( szMenuString ) );
	g_pVGuiLocalize->ConvertANSIToUnicode( szMenuString, g_szMenuString, sizeof( g_szMenuString ) );
	
	ProcessText();

	m_bMenuDisplayed = true;
	m_bMenuTakesInput = true;

	m_flSelectionTime = gpGlobals->curtime;
}
コード例 #18
0
ファイル: InputParser.cpp プロジェクト: Ichthyostega/blender
float CParser::GetFloat(STR_String& txt)
{
	// returns parsed text into a float
	// empty string returns -1

//	AfxMessageBox("parsed string="+txt);
	CValue* val=NULL;
	float result=-1;
//	String tmpstr;

	CExpression* expr = ProcessText(txt);
	if (expr) {
		val = expr->Calculate();
		result=(float)val->GetNumber();



		val->Release();
		expr->Release();
	}
//	tmpstr.Format("parseresult=%g",result);
//		AfxMessageBox(tmpstr);
	return result;
}
コード例 #19
0
ファイル: LAdapt.c プロジェクト: botonchou/AlgoFinal
int main(int argc, char *argv[])
{
   int i;
   char *c,*s,*fn;
   char sBuf[256],fmt[256];

   void       Initialise(void);
   void       ProcessText(char *fn,bool lastFile);
   bool    Exists(char *fn);
   BackOffLM *CombineModels(MemHeap *heap,LMInfo *lmi,int nLModel,int nSize,WordMap *wl) ;

   InitShell(argc,argv,ladapt_version,ladapt_vc_id);
   InitMem();
   InitMath();
   InitWave();
   InitLabel();
   InitLUtil();
   InitWMap();
   InitGBase();
   InitLModel();
   InitPCalc();
   InitPMerge();

   SetConfParms();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(EXIT_SUCCESS);

   InitBuildInfo(&binfo); 
   binfo.dctype = DC_ABSOLUTE;
   nLModel = 1;
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(16419,"Bad switch %s; must be single letter",s);
      switch(s[0]){
         case 'a':
            newWords = GetChkedInt(10,10000000,s); break;
         case 'b':
            ngbSize = GetChkedInt(10,10000000,s); break;
         case 'c':
            i = GetChkedInt(2,LM_NSIZE,s); 
	    binfo.cutOff[i] = GetChkedInt(0,1000,s);
	    break;
         case 'd':
            if (NextArg()!=STRINGARG)
               HError(16419,"Gram base root file name expected");
            rootFN = GetStrArg(); 
	    break;
         case 'f':
	    strcpy(fmt, GetStrArg());
	    for (c=fmt; *c; *c=toupper(*c), c++); /* To uppercase */
	    if (strcmp(fmt, LM_TXT_TEXT)==0)
	      binfo.saveFmt = LMF_TEXT;
	    else if (strcmp(fmt, LM_TXT_BINARY)==0)
	       binfo.saveFmt = LMF_BINARY;
	    else if (strcmp(fmt, LM_TXT_ULTRA)==0)
	       binfo.saveFmt = LMF_ULTRA;
	    else
	       HError(16419,"Unrecognised LM format, should be one of [%s, %s, %s]",
		      LM_TXT_TEXT, LM_TXT_BINARY, LM_TXT_ULTRA);
	    break;
         case 'g':
            processText = FALSE; break;
	 case 'i':
            if (NextArg()!=FLOATARG)
	       HError(16419,"Interpolation weight expected");
	    lmInfo[nLModel].weight = GetChkedFlt(0.0,1.0,s);
            if (NextArg()!=STRINGARG)
	       HError(16419,"Interpolation LM filename expected");
	    lmInfo[nLModel].fn = GetStrArg();
	    nLModel++;
	    break;
         case 'j':
            i = GetChkedInt(2,LM_NSIZE,s); 
	    binfo.wdThresh[i] = GetChkedFlt(0.0,1E10,s);
	    break;
         case 'n':
            nSize = GetChkedInt(1, MAXNG, s); break;
#ifdef HTK_TRANSCRIBER
         case 's':
            if (NextArg()!=STRINGARG)
               HError(16419,"Gram file text source descriptor expected");
            txtSrc = GetStrArg(); break;
         case 't':
	    binfo.dctype = DC_KATZ; break;
#endif
         case 'w':
            if (NextArg()!=STRINGARG)
               HError(16419,"Word list file name expected");
            wlistFN = GetStrArg(); break;
#ifndef HTK_TRANSCRIBER
         case 'x':
            binfo.ptype = LMP_COUNT; break;
#endif
         case 'T':
            trace = GetChkedInt(0,077,s); break;
         default:
            HError(16419,"LAdapt: Unknown switch %s",s);
      }
   }
#ifdef HTK_TRANSCRIBER
   if (nLModel==1) {  /* must interpolate with at least one model */
      HError(16419,"LAdapt: at least one model must be specified with -i option");
   }
   if (binfo.saveFmt==LMF_TEXT) { /* save fomat cannot be TEXT */ 
      binfo.saveFmt=LMF_BINARY;
   }
#endif
   if (NextArg() != STRINGARG)
      HError(16419,"LAdapt: language model file name expected");
   outFN = CopyString(&gstack,GetStrArg());

   Initialise();
   if (processText) {
      if (NextArg() != STRINGARG)
	 ProcessText(NULL,TRUE);       /* input from stdin */
      else
	 while (NextArg() == STRINGARG) {
	    /* !! copy string argument since it gets overwritten 
	       by NextArg() when reading from script file */
	    fn = CopyString(&gstack,GetStrArg());
	    ProcessText(fn,NextArg() != STRINGARG);
	 }
      if (NumArgs() != 0)
	 HError(-16419,"LAdapt: unused args left on cmd line");
      for (i=0; i<stdBuf.ngb->fndx; i++) {
	 sprintf(sBuf,"%s.%d",stdBuf.ngb->fn,i);  
	 AddInputGFile(&inSet,sBuf,1.0);
      }
      ResetHeap(&langHeap);
   } else {
      for (i=0; i<MAX_NGRAM_FILES; i++) {
	 sprintf(sBuf,"%s.%d",rootFN,i);
	 if (!Exists(sBuf))
	    break;
	 AddInputGFile(&inSet,sBuf,1.0);
      }
      if (i==MAX_NGRAM_FILES)
      {
	HError(-16419, "LAdapt: Only %d n-gram files read (recompile with different setting\nof MAX_NGRAM_FILES");
      }
   }
   if (nLModel==1) {
      adpLM = GenerateModel(&langHeap,&binfo);
   } else {
      if (binfo.ptype==LMP_COUNT) 
	 binfo.ptype = LMP_FLOAT;
      newLM = GenerateModel(&langHeap,&binfo);
      lmInfo[0].lm = newLM;
      lmInfo[0].fn = "unknown";
      /* combine all models into one */
      adpLM = CombineModels(&langHeap,lmInfo,nLModel,nSize,tgtVoc);
   }
#ifdef HTK_TRANSCRIBER
#ifdef HTK_CRYPT
   adpLM->encrypt = TRUE;     /* force to write encrypted model */
#endif
#endif
   SaveLangModel(outFN,adpLM);

   Exit(EXIT_SUCCESS);
   return EXIT_SUCCESS; /* never reached -- make compiler happy */
}
コード例 #20
0
ファイル: Text.cpp プロジェクト: ClementVidal/sable.sable
Void CText::SetFont( const CTextFont& font )
{
	m_Font = & font;
	ProcessText();
}
コード例 #21
0
ファイル: Text.cpp プロジェクト: ClementVidal/sable.sable
Void CText::SetFontSize( Float32 size )
{
    m_FontSize = size;
	ProcessText();
}
コード例 #22
0
int PostScriptDrv::ConvertTextFile(DiskFileB &infile, 
				   GXSTD::ostream &stream,
				   int wrap, int cut)
// Convert the ASCII document to postscript. Returns 1 if successful.
// If wrap is true the line will wrap around the page if the number
// of columns are exceeded. If cut is true the line will be truncated
// to match the number of columns.
{
  if(!infile) return 0; 
  char bufin[BUFIN];

  // Read in text file line by line until EOF
  while(!infile.df_EOF()) {
    StartPage(page_count + 1, stream);
    row = start_y;
    line_count = lines_per_page;
    // Process the next page 
    for (int lineno = 0; lineno < line_count; lineno++) {
      if(infile.df_GetLine(bufin, MAX_LINE) != DiskFileB::df_NO_ERROR) {
	break;
      }
      if (bufin[0] == '\f') break;
      if (bufin[0] != '\0') {
	int len = strlen(bufin);
	
	if(wrap == 1 && len >= columns) { // Wrap text lines 
	  int i = 0, j = 0, x = 0;
	  char *temp_buf = new char[columns];
	  // PC-lint 04/26/2005: Possible access of out-of-bounds pointer
	  temp_buf[columns-1] = '\0';
    
	  while(len >= columns) { // Loop until length is less then columns
	    len = len - columns;
	    for(j = 0; j < columns; j++, i++) temp_buf[j] = bufin[i];
	    stream << start_x << " "  << row << " " << MOVETO << "\n";
	    if(PrintLine(temp_buf, stream) == 0) {
	      // PC-lint 04/26/2005: Prevent memory leak
	      delete[] temp_buf;
	      return 0;
	    }
	    for(x = 0; x < columns; x++) temp_buf[x] = '\0';
	    row -= (int)font_size; // Update the y position after wrap

	    if(row < font_size) { // Start a new page
	      EndPage(stream);
	      StartPage(page_count + 1, stream);
	      row = start_y;
	      line_count = lines_per_page;
	      lineno = 0;
	    }
	    line_count--;
	    if(len < columns) break;
	  }

	  if(len > 0) { // Print the remaining characters
	    for(j = 0; j < len; j++, i++) temp_buf[j] = bufin[i];
	    stream << start_x << " "  << row << " " << MOVETO << "\n";
	    if(PrintLine(temp_buf, stream) == 0) {
	      // PC-lint 04/26/2005: Prevent memory leak
	      delete[] temp_buf;
	      return 0;
	    }
	  }
	  // PC-lint 04/26/2005: Prevent memory leak
	  delete[] temp_buf;
	}
	else { 
	  if(ProcessText(bufin, stream, cut) == 0) return 0;
	}
	for(int i = 0; i < BUFIN; i++) bufin[i] = 0;  // Clear the buffer
      }
      row -= (int)font_size;
    }
    EndPage(stream);
  } 
  return 1;
}
コード例 #23
0
void LayoutManager::OnCharacter(char character)
{
	ProcessText(character);

	std::cout << "OnCharacter " << character << std::endl;
}