Exemple #1
0
void MediaLibrary::onMediaThumbnailReady( medialibrary::MediaPtr media, bool success )
{
    vlc_ml_event_t ev;
    ev.i_type = VLC_ML_EVENT_MEDIA_THUMBNAIL_GENERATED;
    ev.media_thumbnail_generated.b_success = success;
    auto mPtr = vlc::wrap_cptr<vlc_ml_media_t>(
                static_cast<vlc_ml_media_t*>( malloc( sizeof( vlc_ml_media_t ) ) ),
                vlc_ml_media_release );
    if ( unlikely( mPtr == nullptr ) )
        return;
    ev.media_thumbnail_generated.p_media = mPtr.get();
    if ( Convert( media.get(), *mPtr ) == false )
        return;
    m_vlc_ml->cbs->pf_send_event( m_vlc_ml, &ev );
}
nsresult
Convert(const bt_service_record_t& aIn, BluetoothServiceRecord& aOut)
{
  nsresult rv = Convert(aIn.uuid, aOut.mUuid);
  if (NS_FAILED(rv)) {
    return rv;
  }

  aOut.mChannel = aIn.channel;

  MOZ_ASSERT(sizeof(aIn.name) == sizeof(aOut.mName));
  memcpy(aOut.mName, aIn.name, sizeof(aOut.mName));

  return NS_OK;
}
int Convert(const CString& szSrc, CString& szDst, int nConvertWay)
{
	int nSrcLen = szSrc.GetLength();
	if(nSrcLen <= 0)
	{
		szDst.Empty();
		return 0;
	}

	int nResult = 0;
	nResult = Convert(szSrc, nSrcLen, szDst.GetBuffer(nSrcLen), nSrcLen, nConvertWay);
	ASSERT(nResult <= nSrcLen);
	szDst.ReleaseBuffer();
	return nResult;
}
Exemple #4
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if (a.arguments().size() != 4) {
        std::cout<<std::endl;
        std::cout<<"code_highlight -- part of the Seer app: http://1218.io"<<std::endl;
        std::cout<<"----------------------------------------------------------"<<std::endl;
        std::cout<<"Usage: code_highlight.exe css_filename input_path output_path"<<std::endl;
        std::cout<<std::endl;
        return -1;
    }

    Convert(a.arguments().at(1),a.arguments().at(2),a.arguments().at(3));
    return 0;
}
Exemple #5
0
void ReadStringArray(ifstream& in, vector<string>& data)
{
    data.clear();
    int length;
    in.read((char*)&length, sizeof(int));
    data.resize(length);
    for (vector<string>::iterator it = data.begin(); it != data.end(); ++it)
    {
        int size;
        in.read((char*)&size, sizeof(int));
        char* buffer = new char[size];
        in.read(buffer, sizeof(char) * size);
        Convert(buffer, size, *it);
        delete [] buffer;
    }
}
Exemple #6
0
int main(int argc, char* argv[])
{
    //check parameters
    if (argc < 2)
    {
        printf("You need to specify input file(s) in application parameters!\n");
        system("pause");
        return 0;
    }

    for (int i = 1; i < argc; i++)
        Convert(argv[i]);

    system("pause");
    return 0;
}
Exemple #7
0
inline void fast_Ring< TNum, kdefs>::multInvInPlace( TNum & a) const
{
	#ifdef SAFE
		assert( a==Convert(a) );
	#endif
	TNum const &	res = multiplicativeInverseTable[getSingleIndex( a)];
	if (res.isNotZero() ) 
	{
		a = res;
	}
	else 
	{
		std::cerr << "Multiplicative inverse does not exist!" << std::endl;
		throw "Multiplicative inverse does not exist!" ;
	}
}
	//////////////////////////////////////////////////////////////////////////////
	// UpdateConvertedSurface()
	// Make	sure the bits for a	converted surface are available	and	up to date.
	//////////////////////////////////////////////////////////////////////////////
	void UpdateConvertedSurface(PixelFormat* ppf, const	WinPoint& size,	SurfaceData& data, const SurfaceData& dataSource)
	{
		if( ppf != data.m_ppf )
		{
			ConstructSurfaceData(data, ppf,	size);
		}

		if( data.m_id != dataSource.m_id ) 
		{
			SetSurfaceMode(SurfaceModeDD);

			Convert(size, data.m_pd3dtexture, dataSource.m_pd3dtexture);
//			Convert(size, data.m_pdds, dataSource.m_pdds);
			data.m_id =	dataSource.m_id;
		}
	}
void userlearn :: GetNotRemembered(std::vector<std::string> &words)
{
    char *filename, *name;
    name = Convert(username);
    filename = Path("record", name, "last.info");
    std::ifstream fin(filename);
    if (!fin) return;
    std::string word;
    int rec;
    while (!fin.eof())
    {
        fin >> word >> rec;
        if (rec == 0)
            words.push_back(word);
    }
}
Exemple #10
0
nsresult
Convert(const btgatt_gatt_id_t& aIn, BluetoothGattId& aOut)
{
  nsresult rv = Convert(aIn.uuid, aOut.mUuid);
  if (NS_FAILED(rv)) {
    return rv;
  }
  // HAL uses reversed UUID for GATT
  for (uint8_t i = 0; i < sizeof(aOut.mUuid.mUuid) / 2; i++) {
    auto temp = aOut.mUuid.mUuid[i];
    aOut.mUuid.mUuid[i] = aOut.mUuid.mUuid[sizeof(aOut.mUuid.mUuid) - i - 1];
    aOut.mUuid.mUuid[sizeof(aOut.mUuid.mUuid) - i - 1] = temp;
  }
  aOut.mInstanceId = aIn.inst_id;
  return NS_OK;
}
Exemple #11
0
void ConvertInx::ConvertMonster( const char* Directory )
{
	hDirectory = FindFirstFileA( Format( "%s\\char\\monster\\*", Directory ), &DirAttr );
	s_Inx InxFile = { 0 };
	while( true )
	{
		if( hDirectory != INVALID_HANDLE_VALUE )
		{
			if( DirAttr.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY )
				break;

			if( DirAttr.dwFileAttributes == FILE_ATTRIBUTE_HIDDEN )
				break;

			hFile = FindFirstFileA( Format( "%s\\char\\monster\\%s\\*.inx", Directory, DirAttr.cFileName ), &FileAttr );
			while( true )
			{
				if( FileAttr.cFileName[ lstrlenA( FileAttr.cFileName ) - 1 ] == 'x' )
				{
					if( FileAttr.nFileSizeLow == OLD_INX_SIZE )
					{
						StringCbCopyA( InxFile.FileName, 256, FileAttr.cFileName );
						StringCbCopyA( InxFile.FullPath, 512, Format( "%s\\char\\monster\\%s\\%s",
							Directory, DirAttr.cFileName, FileAttr.cFileName ) );
						Convert( &InxFile );
					};
				};

				if( FindNextFileA( hFile, &FileAttr ) == FALSE )
					break;
			};

			if( FindNextFileA( hDirectory, &DirAttr ) == FALSE )
			{
				break;
			};
		}
		else
		{
			break;
		};
	};
	hDirectory = NULL;
	hFile = NULL;
	SecureZeroMemory( &DirAttr, sizeof( WIN32_FIND_DATA ) );
	SecureZeroMemory( &FileAttr, sizeof( WIN32_FIND_DATA ) );
};
bool userlearn :: CheckWord(std::string sword)
{
    char *filename, *name;
    std::string wordr;
    name = Convert(username);
    filename = Path("record", name, "remembered.info");
    std::ifstream fin(filename);
    if (!fin)
        return false;
    while (!fin.eof())
    {
        getline(fin, wordr);
        if (wordr.compare(sword) == 0)
            return true;
    }
    return false;
}
Exemple #13
0
int main (int argc, char * argv[])
{
  double   dIn;
  double   dOut;
  Measure  factor;
  char     op;
  Unit *   uIn;
  Unit *   uOut;

  if (argc != 3) GiveUsage();
  dIn = atof (argv[1]);
  switch (argv[2][0])
  {
    case 'f': case 'F':
      factor = CONVERT_FEETPERMETER;
      op = '/';
      uIn = &FOOT;
      uOut = &METER;
    break;
    case 'k': case 'K':
      factor = CONVERT_SLUGSPERKILOGRAM;
      op = '*';
      uIn = &KILOGRAM;
      uOut = &SLUG;
    break;
    case 'm': case 'M':
      factor = CONVERT_FEETPERMETER;
      op = '*';
      uIn = &METER;
      uOut = &FOOT;
    break;
    case 's': case 'S':
      factor = CONVERT_SLUGSPERKILOGRAM;
      op = '/';
      uIn = &SLUG;
      uOut = &KILOGRAM;
    break;
    default: GiveUsage(); break;
  }
  dOut = Convert (dIn, uIn, uOut, op, factor);

  cout << dIn << ' ' << uIn->GetName() << " = ";
  cout << dOut << ' ' << uOut->GetName() << endl;

  exit (0);
}
void main()
   {
   char Reply;
   do
      {
		char Infix[50], Postfix[50]=""; 

      cout << "Enter an infix expression (e.g. (a+b)/c^2, with no spaces):"<< endl;
      cin >> Infix;

      Convert(Infix, Postfix);
      cout << "The equivalent postfix expression is:" << endl<< Postfix << endl;
      cout << endl << "Do another (y/n)? ";
      cin >> Reply;
      }
   while (Reply == 'y');
   }
Exemple #15
0
int main(int argc, const char **argv)
{
   if (Init(argc,argv) != 0) {
      return 0;
   }

   while (ReadHeader()) {
      Convert();
      ++MemberCount;
   }
   if (MemberCount == 0) {
      MESSAGE(0,("Warning: %s is empty",inpname));
   }

   Cleanup();
   return 0;
}
Exemple #16
0
void ReadStringArray(const string &fname, vector<string>& data)
{
    data.clear();
    ifstream in(fname.c_str(), std::ios::in | std::ios::binary);
    int length;
    in.read((char*)&length, sizeof(int));
    data.resize(length);
    for (vector<string>::iterator it = data.begin(); it != data.end(); ++it)
    {
        int size;
        in.read((char*)&size, sizeof(int));
        char* buffer = new char[size];
        in.read(buffer, sizeof(char) * size);
        Convert(buffer, size, *it);
        delete [] buffer;
    }
}
		void DebugFrameRendererVisitor::Visit(const Dia::Graphics::DebugFrameDataCircle2D& object)const
		{
			sf::CircleShape shape(object.GetRadius());

			shape.setOutlineThickness(2);

			// Set the position, we need to offset the radius so that the center is the position of the circle
			shape.setPosition(sf::Vector2f(object.GetPosition().x - object.GetRadius(), object.GetPosition().y - object.GetRadius()));
			
			// Set the colour
			sf::Color sfColour;
			Convert(sfColour, object.GetColour());
			shape.setFillColor(sf::Color(0,0,0,0));
			shape.setOutlineColor(sfColour);

			// Now draw the circle
			mRenderTarget->draw(shape);
		}
void ARadiantWebViewActor::CallJavaScriptFunction(const FString& HookName, UObject* Parameters)
{
	if (!HookName.IsEmpty() && Parameters && WebViewRenderComponent && WebViewRenderComponent->WebView.IsValid())
	{
		TSharedPtr<FRadiantWebView> WebView = WebViewRenderComponent->WebView;

		if (WebView.IsValid())
		{
			ICefRuntimeVariantList* Arguments = FJavaScriptHelper::CreateVariantList(Parameters->GetClass(), Parameters, WebView->GetVariantFactory());
			FTCHARToUTF8 Convert(*HookName);
			WebViewRenderComponent->WebView->CallJavaScriptFunction(Convert.Get(), Arguments);
			if (Arguments)
			{
				Arguments->Release();
			}
		}
	}
}
template <class Model> void Fill<Model>::AddPhraseOOV(TargetPhrase &phrase, std::list<TargetPhraseCollection*> &, const WordsRange &)
{
  std::vector<lm::WordIndex> words;
  CHECK(phrase.GetSize() <= 1);
  if (phrase.GetSize())
    words.push_back(Convert(phrase.GetWord(0)));

  search::PartialEdge edge(edges_.AllocateEdge(0));
  // Appears to be a bug that FutureScore does not already include language model.
  search::ScoreRuleRet scored(search::ScoreRule(context_.LanguageModel(), words, edge.Between()));
  edge.SetScore(phrase.GetFutureScore() + scored.prob * context_.LMWeight() + static_cast<search::Score>(scored.oov) * oov_weight_);

  search::Note note;
  note.vp = &phrase;
  edge.SetNote(note);

  edges_.AddEdge(edge);
}
Exemple #20
0
CFieldDate::CFieldDate(LPCTSTR pName, LPCTSTR pLow, LPCTSTR pHigh, LPCTSTR pFormat, LPCTSTR pInputFormat,DWORD datetime)
			: CField(pName, pLow, pHigh, pFormat, pInputFormat)
{
	dDatetimeFlag = datetime;

	if (datetime == VAR_TIMEVALUEONLY)
	{
		m_type = eTime;
	}
	else if (datetime == VAR_DATEVALUEONLY)
	{
		m_type = eDate;
	}
	else
		m_type = eDateTime;

	Convert();
}
void LMSImportChannelMapDialog::Init() {
    for (int i=0;i<mSequenceElements->GetElementCount();i++) {
        if (mSequenceElements->GetElement(i)->GetType() == "model") {
            ModelsChoice->Append(mSequenceElements->GetElement(i)->GetName());
        }
    }
    int sz = ChannelMapGrid->GetColSize(3);
    ChannelMapGrid->DeleteCols(5, 4);
    ChannelMapGrid->SetColSize(0, sz * 1.5);
    ChannelMapGrid->SetColSize(1, sz * 1.5);
    ChannelMapGrid->SetColSize(2, sz * 1.5);
    ChannelMapGrid->SetColSize(3, sz * 4.5);
    ChannelMapGrid->SetColSize(4, sz / 2);
    ChannelMapGrid->DeleteRows(0, ChannelMapGrid->GetNumberRows());
    ChannelMapGrid->SetRowLabelSize(0);
    wxGridCellChoiceEditor *editor = new wxGridCellChoiceEditor(Convert(MapByStrand->GetValue() ? ccrNames : channelNames));
    ChannelMapGrid->SetDefaultEditor(editor);
}
/* This method handles asyncronous conversion of data. */
NS_IMETHODIMP
TestConverter::OnDataAvailable(nsIRequest* request,
                               nsISupports *ctxt, 
                               nsIInputStream *inStr, 
                               PRUint32 sourceOffset, 
                               PRUint32 count) {
    nsresult rv;
    nsCOMPtr<nsIInputStream> convertedStream;
    // just make a syncronous call to the Convert() method.
    // Anything can happen here, I just happen to be using the sync call to 
    // do the actual conversion.
    rv = Convert(inStr, fromType.get(), toType.get(), ctxt, getter_AddRefs(convertedStream));
    if (NS_FAILED(rv)) return rv;

    PRUint32 len;
    convertedStream->Available(&len);
    return mListener->OnDataAvailable(request, ctxt, convertedStream, sourceOffset, len);
}
Exemple #23
0
void main()
{
	char romanNumber[128];
	int decimal;
	int onceMore;

	do
	{
		printf("Enter a roman number....");
		scanf("%s", romanNumber);

		decimal = Convert(romanNumber);
		printf("The converted no. is....%d\n", decimal);

		printf("Do you want to continue...[1/0]...");
		scanf("%d", &onceMore);
	}while (onceMore);
}
Exemple #24
0
int main(void){
  TExaS_Init();
	ST7735_InitR(INITR_REDTAB); 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	SysTick_Init();			// This makes things work
  // your Lab 8
  while(1){
		while(ADCStatus == 0){}
		Data = ADCMail;
		Position = Convert(Data); 
		ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
		ADCStatus = 0;
  }
}
Exemple #25
0
void SysTick_Handler(){
	PF2 ^= 0x04;      						// 1. Toggle heartbeat 		
	uint32_t data = ADC_In();  		// 2. Sample ADC (12-bit channel 1)
	PF2 ^= 0x04;      						// 3. Toggle heartbeat
	data=Convert(data);						// 4. Convert to distance and create the 8-byte message
	uint8_t message[]= {0x02,0,0x2E,0,0,0,0x0D,0x03};
	message[1] = (data/1000)%10 + 0x30;
	message[3] = (data/100)%10 + 0x30;
	message[4] = (data/10)%10 + 0x30;
	message[5] = data%10 + 0x30;
	for(int i=0; i<8; i++){				// 5. Send the 8-byte message to the other computer (calls UART1_OutChar 8 times)
		UART1_OutChar(message[i]);
	}
	TxCounter++;									// 6. increment TxCounter (for debugging)
	PF2 ^= 0x04;   				   			// 7. Toggle heartbeat
	NVIC_ST_RELOAD_R = 2000000-1; // 8. Return from interrupt
  NVIC_ST_CURRENT_R = 0;				// Reset SysTick timer for .25ms
}
void LMSImportChannelMapDialog::Init(bool allModels) {
    allowAddModels = allModels;
    if (allModels) {
        for (auto it = xlights->AllModels.begin(); it != xlights->AllModels.end(); it++) {
            ModelsChoice->Append(it->first);
        }
    } else {
        for (size_t i=0;i<mSequenceElements->GetElementCount();i++) {
            if (mSequenceElements->GetElement(i)->GetType() == "model") {
                ModelsChoice->Append(mSequenceElements->GetElement(i)->GetName());
            }
        }
    }
    int sz = ChannelMapGrid->GetColSize(3);
    ChannelMapGrid->DeleteCols(5, 4);

    wxGridCellAttr *ca = new wxGridCellAttr();
    ca->SetKind(wxGridCellAttr::wxAttrKind::Col);
    ca->SetReadOnly();
    ChannelMapGrid->SetColAttr(0, ca);
    ca = new wxGridCellAttr();
    ca->SetKind(wxGridCellAttr::wxAttrKind::Col);
    ca->SetReadOnly();
    ChannelMapGrid->SetColAttr(1, ca);
    ca = new wxGridCellAttr();
    ca->SetKind(wxGridCellAttr::wxAttrKind::Col);
    ca->SetReadOnly();
    ChannelMapGrid->SetColAttr(2, ca);
    ca = new wxGridCellAttr();
    ca->SetKind(wxGridCellAttr::wxAttrKind::Col);
    ca->SetReadOnly();
    ChannelMapGrid->SetColAttr(4, ca);

    ChannelMapGrid->SetColSize(0, sz * 1.5);
    ChannelMapGrid->SetColSize(1, sz * 1.5);
    ChannelMapGrid->SetColSize(2, sz * 1.5);
    ChannelMapGrid->SetColSize(3, sz * 4.5);
    ChannelMapGrid->SetColSize(4, sz / 2);

    ChannelMapGrid->DeleteRows(0, ChannelMapGrid->GetNumberRows());
    ChannelMapGrid->SetRowLabelSize(0);
    wxGridCellChoiceEditor *editor = new wxGridCellChoiceEditor(Convert(MapByStrand->GetValue() ? ccrNames : channelNames));
    ChannelMapGrid->SetDefaultEditor(editor);
}
Exemple #27
0
HugeNumber::HugeNumber(char *x)
{
   int i,n;

   n=BaseRazr();
   if (x[1]=='x')
   {
		// Chislo v shestnadsaterichnoj zapisi
      int len,j,k;
      char buf[11],*str;

      buf[n]=0;
      len=strlen(x);
      str= new char[len+n];
      strcpy(str,&x[2]);

      for (len=strlen(str); len%n!=0; len++)
      {
         for (j=len; j>0; j--)
         {
            str[j]=str[j-1];
         };
         str[0]='0';
      };

      j=0;
      for (i=len-1; i>=0; i=i-n)
      {
         for (k=0; k<n; k++)
            buf[k]=str[i-n+k+1];
         sscanf(buf,"%x",&digit[j++]);
      };
      delete str;
      for (;j<MaxRazr;j++) digit[j]=0;
   }
   else
   {
		// Chislo v desiatichnoj zapisi
   	HugeNumber a;
   	Convert(x,a);
   	for (i=0; i<MaxRazr; i++) digit[i]=a.digit[i];
   }
};
int main3(void){ 
  TExaS_Init();         // Bus clock is 80 MHz 
  PortF_Init();
  ADC_Init();         // turn on ADC, set channel to 1
	ST7735_InitR(INITR_REDTAB); 
  while(1){  
    PF2 ^= 0x04;      // Heartbeat
    Data = ADC_In();  // sample 12-bit channel 1
    PF3 = 0x08;       // Profile Convert
    Position = Convert(Data); 
    PF3 = 0;          // end of Convert Profile
    PF1 = 0x02;       // Profile LCD
    ST7735_SetCursor(0,0);
    LCD_OutDec(Data); ST7735_OutString("    "); 
    ST7735_SetCursor(6,0);
    LCD_OutFix(Position);
    PF1 = 0;          // end of LCD Profile
  }
}
Exemple #29
0
static  void    BinOp( TYPE typ1, TYPE typ2, OPTR op ) {
//===================================================

    byte        index;

    typ2 = typ2;
    op -= OPTR_FIRST_ARITHOP;
    index = ResultType - FT_INTEGER_1;
    if( typ1 != FT_NO_TYPE ) {
        Convert();
        XArithTab[ index * AR_TAB_COLS + op ]
                 ( &CITNode->value, &CITNode->link->value );
    } else {
        CnvTo( CITNode->link , ResultType, TypeSize( ResultType ) );
        XUArithTab[ index * UAR_TAB_COLS + op ]
                  ( &CITNode->value, &CITNode->link->value );
        CITNode->opn.us = USOPN_CON;
    }
}
nsresult mozHunspell::ConvertCharset(const PRUnichar* aStr, char ** aDst)
{
  NS_ENSURE_ARG_POINTER(aDst);
  NS_ENSURE_TRUE(mEncoder, NS_ERROR_NULL_POINTER);

  PRInt32 outLength;
  PRInt32 inLength = nsCRT::strlen(aStr);
  nsresult rv = mEncoder->GetMaxLength(aStr, inLength, &outLength);
  NS_ENSURE_SUCCESS(rv, rv);

  *aDst = (char *) nsMemory::Alloc(sizeof(char) * (outLength+1));
  NS_ENSURE_TRUE(*aDst, NS_ERROR_OUT_OF_MEMORY);

  rv = mEncoder->Convert(aStr, &inLength, *aDst, &outLength);
  if (NS_SUCCEEDED(rv))
    (*aDst)[outLength] = '\0';

  return rv;
}