Esempio n. 1
0
void CPDF_StreamContentParser::Handle_SetLineCap() {
  m_pCurStates->m_GraphState.GetModify()->m_LineCap =
      (CFX_GraphStateData::LineCap)GetInteger(0);
}
 /**
  * Subtraction operator, subtracts from the current
  * @param other the IntegerData to subtract
  */
 virtual void operator-=(const IntegerData *other)
 {
   Reset();
   _integer.operator-=(GetInteger(other));
 }
 /**
  * Add operator, produces a new Integer
  * @param other the Integer to add
  */
 virtual IntegerData *Add(const IntegerData *other) const
 {
   return new CppIntegerData(_integer.Plus(GetInteger(other)));
 }
 /**
  * Subtraction operator, produces a new Integer
  * @param multiplicand the Integer to multiply this
  */
 virtual IntegerData *Multiply(const IntegerData *multiplicand) const
 {
   return new CppIntegerData(_integer.Times(GetInteger(multiplicand)));
 }
 /**
  * Exponentiating operator
  * @param pow raise this to other
  */
 virtual IntegerData *Pow(const IntegerData *pow,
     const IntegerData *mod) const
 {
   return new CppIntegerData(a_exp_b_mod_c(_integer,
         GetInteger(pow), GetInteger(mod)));
 }
Esempio n. 6
0
QByteArray CompositeIntegerGroup::ElementToByteArray(const Element &a) const
{
    return GetInteger(a).GetByteArray();
}
Esempio n. 7
0
/// --- Limits ---
Limits::Limits( Context* context ) :
	m_Context(context)
{
	maxColorAttachments = GetInteger(GL_MAX_COLOR_ATTACHMENTS);
	maxDrawBuffers      = GetInteger(GL_MAX_DRAW_BUFFERS);

	maxVertexTextureUnits = GetInteger(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS);
	maxFragmentTextureUnits = GetInteger(GL_MAX_TEXTURE_IMAGE_UNITS);
	maxCombinedTextureUnits = GetInteger(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);

	maxTextureSize[TextureType_1D] = GetInteger(GL_MAX_TEXTURE_SIZE);
	maxTextureSize[TextureType_2D] = GetInteger(GL_MAX_TEXTURE_SIZE);
	maxTextureSize[TextureType_3D] = GetInteger(GL_MAX_3D_TEXTURE_SIZE);
	maxTextureSize[TextureType_Rect] = GetInteger(GL_MAX_RECTANGLE_TEXTURE_SIZE);
	maxTextureSize[TextureType_CubeMap] = GetInteger(GL_MAX_CUBE_MAP_TEXTURE_SIZE);

	maxTextureCoords    = GetInteger(GL_MAX_TEXTURE_COORDS);
	maxVertexAttributes = GetInteger(GL_MAX_VERTEX_ATTRIBS);

	if (GLEW_EXT_texture_filter_anisotropic)
		maxTextureAnisotropy = GetFloat(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
	else
		maxTextureAnisotropy = 1.f;

// 	print();
}
Esempio n. 8
0
// 生成 CPack 包
BOOL CommFormPackFunc(int nFunction, char *buffer, CSList *plist, void *pvoid, int DestNO)
{
	ST_CPACK_C *pstpack=(ST_CPACK_C *)pvoid;
	//memset(&(pstpack->pack),0,sizeof(ST_PACKDATA_C));
	char sOldAppendPwd1[9]="", sOldAppendPwd2[9]="";
	char sNewAppendPwd1[9]="", sNewAppendPwd2[9]="";
	char sAccountsId[22] = "";						// 转换以后的帐号
	int  iLen=0;
	int tmp = 0;
	switch(nFunction) 
	{	
	case 11://交易明细查询	847184
		/*
		1.	功能号:11
		2.	发起地址
		3.	保留
		4.	暂时不用(填空)
		5.	卡号
		6.	货币代码
		7.	起始日期
		8.	终止日期
		9.	索引流水号
		10.	最多返回数量 - 10条
		11.	委托方式
		*/
		tmp = GetInteger(plist->GetAt(7));
		AddFieldI_C(pstpack, F_LVOL0, tmp);		// 卡号
		AddField_C(pstpack, F_SDATE0, plist->GetAt(9));		// 起始日期
		AddField_C(pstpack, F_SDATE1, plist->GetAt(10));	// 结束日期
		tmp = GetInteger(plist->GetAt(12));
		AddFieldI_C(pstpack, F_LVOL1, tmp);		// 查询返回记录数
		return TRUE;
	case 12: // 挂失卡  847102
		 /*
		 1.	功能号:12
		 2.	发起地址
		 3.	保留
		 4.	暂时不用(填空)
		 5.	卡号
		 6.	密码
		 7. 客户号
		 8.	委托方式
		*/
		// TODO : 修改挂失的限制
		tmp = GetInteger(plist->GetAt(7));
		AddFieldI_C(pstpack, F_LVOL1, tmp);	// 卡号
		AddField_C(pstpack, F_SCUST_LIMIT, "system");
		return TRUE;
	case 9:		//查询余额  700001
		/*
		*  1. 功能号 9 
		*  2. 发起地址
		*  3. 货币代码(不用)
		*  4. 不用
		*  5. 卡号
		*  6. 委托方式
		*/
		tmp = GetInteger(plist->GetAt(7));
        AddFieldI_C(pstpack, F_LVOL3, tmp);	// 卡号
		return TRUE;
	case 901:	//用户登录 700000
		//////////////////////////////////////////////////////////////////////////
		// 测试
		//AfxMessageBox(plist->GetAt(7));						
		//////////////////////////////////////////////////////////////////////////
		ChangeIdFromPhone(plist->GetAt(7), sAccountsId);	// 转换帐号,从数字转字母
		AddField_C(pstpack, F_SSTATUS0, plist->GetAt(5));	// 账号类别
		//AddField_C(pstpack, F_SCUST_NO, plist->GetAt(7));	// 账号
		//////////////////////////////////////////////////////////////////////////
		// 测试
		//AfxMessageBox(sAccountsId);
		//////////////////////////////////////////////////////////////////////////
		AddField_C(pstpack, F_SCUST_NO, sAccountsId);		// 账号
		//AddField_C(pstpack, F_LVOL0, plist->GetAt(7));	// 卡号
		AddField_C(pstpack, F_SBANK_PWD, plist->GetAt(8));	// 密码
		return TRUE;
	}
	return FALSE;
}
Esempio n. 9
0
 /**
  * Equality operator
  * @param other the ElementData to compare
  */
 virtual bool operator==(const ElementData *other) const
 {
   return _integer == GetInteger(other);
 }
AInt AnimaRenderer::GetInteger(const char* propertyName)
{
	AnimaString str(propertyName, _allocator);
	return GetInteger(str);
}
nsresult
nsOperaProfileMigrator::CopySmartKeywords(nsINavBookmarksService* aBMS, 
                                          nsIStringBundle* aBundle,
                                          PRInt64 aParentFolder)
{
  nsresult rv;

  nsCOMPtr<nsIFile> smartKeywords;
  mOperaProfile->Clone(getter_AddRefs(smartKeywords));
  smartKeywords->Append(NS_LITERAL_STRING("search.ini"));

  nsCOMPtr<nsILocalFile> lf(do_QueryInterface(smartKeywords));
  nsINIParser parser;
  if (!lf || NS_FAILED(parser.Init(lf)))
    return NS_OK;

  nsString sourceNameOpera;
  rv = aBundle->GetStringFromName(NS_LITERAL_STRING("sourceNameOpera").get(),
                                  getter_Copies(sourceNameOpera));
  NS_ENSURE_SUCCESS(rv, rv);

  const PRUnichar* sourceNameStrings[] = { sourceNameOpera.get() };
  nsString importedSearchUrlsTitle;
  rv = aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchURLsFolder").get(),
                                     sourceNameStrings, 1, 
                                     getter_Copies(importedSearchUrlsTitle));
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt64 keywordsFolder;
  rv = aBMS->CreateFolder(aParentFolder,
                          NS_ConvertUTF16toUTF8(importedSearchUrlsTitle),
                          nsINavBookmarksService::DEFAULT_INDEX,
                          &keywordsFolder);
  NS_ENSURE_SUCCESS(rv, rv);

  PRInt32 sectionIndex = 1;
  nsCAutoString name, url, keyword;
  do {
    nsCAutoString section("Search Engine ");
    section.AppendInt(sectionIndex++);

    rv = parser.GetString(section.get(), "Name", name);
    if (NS_FAILED(rv)) {
      // No more smart keywords found, stop parsing the file.
      break;
    }
    if (name.IsEmpty())
      continue;

    rv = parser.GetString(section.get(), "URL", url);
    if (NS_FAILED(rv) || url.IsEmpty())
      continue;

    rv = parser.GetString(section.get(), "Key", keyword);
    if (NS_FAILED(rv) || keyword.IsEmpty())
      continue;

    PRInt32 post;
    rv = GetInteger(parser, section.get(), "Is post", &post);
    if (NS_SUCCEEDED(rv) && post)
      continue;

    PRUint32 length = name.Length();
    PRInt32 index = 0;
    do {
      index = name.FindChar('&', index);
      if ((PRUint32)index >= length - 2)
        break;

      // Assume "&&" is an escaped ampersand in the search query title. 
      if (name.CharAt(index + 1) == '&') {
        name.Cut(index, 1);
        index += 2;
        continue;
      }

      name.Cut(index, 1);
    }
    while ((PRUint32)index < length);

    nsCOMPtr<nsIURI> uri;
    if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), url.get())) || !uri)
      continue;

    nsCAutoString hostCStr;
    uri->GetHost(hostCStr);
    NS_ConvertASCIItoUTF16 host(hostCStr);

    const PRUnichar* descStrings[] = { NS_ConvertUTF8toUTF16(keyword).get(),
                                       host.get() };
    nsString keywordDesc;
    rv = aBundle->FormatStringFromName(NS_LITERAL_STRING("importedSearchUrlDesc").get(),
                                       descStrings, 2,
                                       getter_Copies(keywordDesc));
    NS_ENSURE_SUCCESS(rv, rv);

    PRInt64 newId;
    rv = aBMS->InsertBookmark(keywordsFolder, uri,
                              nsINavBookmarksService::DEFAULT_INDEX,
                              name, &newId);
    NS_ENSURE_SUCCESS(rv, rv);
    rv = aBMS->SetKeywordForBookmark(newId, NS_ConvertUTF8toUTF16(keyword));
    NS_ENSURE_SUCCESS(rv, rv);
    // TODO Bug 397771: set bookmark description to keywordDesc.
  }
  while (1);
  
  return rv;
}
Esempio n. 12
0
CExtGridCellEx* PropertiesBar::AddPropertyItemToTree(CPropItem& item, CExtPropertyItem* pRoot, CString& retStr, PropReturn& Return)
{
	CExtGridCellString* pString;
	CExtGridCellDropListComboBox* pCombo;
	CExtGridCellNumber* pNumber;
	CExtGridCellCurrency* pCurr;
	CExtGridCellCheckBox* pCheck;
	CExtGridCellColor* pColor;
	CExtGridCellHyperLink* pLink;
	CExtGridCellSlider* pSlider;
	CExtGridCellFont* pFont;

	switch (item.Type)
	{
	// Edit
	case 0:
		{
			pString = GetEdit(pRoot);
			pString->TextSet(retStr);
			return pString;
		}

	// Static
	case 1:
		{
			pString = GetEdit(pRoot);
			pString->TextSet(retStr);
			pString->ModifyStyle(__EGCS_READ_ONLY | __EGCS_NO_INPLACE_CONTROL);
			return pString;
		}

	// Button
	case 2:
		{
			pLink = GetHyperLink(pRoot);
			pLink->TextSet(item.Text);
			return pLink;
		}

	// Value
	case 3:
		{
			pNumber = GetInteger(pRoot);
			pNumber->_VariantAssign(Return.val);
			return pNumber;
		}

	// Combo
	case 4:
		{
			pCombo = GetCombo(pRoot);

			// Add items
			CString Work = item.Text;
			int count = Work.Replace("|", "");
			count++;

			for (int e = 0; e < count; e++)
			{
				CString tok;
				AfxExtractSubString(tok, item.Text, e, '|');
				pCombo->InsertString(tok);
			}

			pCombo->SetCurSel(Return.val);
			return pCombo;
		}

	// Float
	case 5:
		{
			pNumber = GetFloat(pRoot);
			pNumber->_VariantAssign(Return.fVal);
			return pNumber;
		}

	// Color
	case 6:
		{
			pColor = GetColor(pRoot);
			pColor->SetColor((COLORREF)Return.val);
			return pColor;
		}

	// Checkbox (bool)
	case 7:
		{
			pCheck = GetCheckBox(pRoot);
			pCheck->SetCheck(Return.val);
			return pCheck;
		}

	//	Font
	case 8:
		{
			pFont = GetFont(pRoot);

			return pFont;
		}

		// Percentage
	case 9:
		{
			pCurr = GetPercent(pRoot);
			pCurr->_VariantAssign(Return.fVal * 100.0);
			return pCurr;
		}

		// Slider (same as value)
	case 10:
		{
			pSlider = GetSlider(pRoot);
			pSlider->SetPos(Return.val);
			return pSlider;
		}

	// Frame property (int)
	case 11:
		{
			pCombo = GetCombo(pRoot);

			// Add frames
			for (int e = 0; e < m_pCurrentApplication->layouts.GetSize(); e++)
				pCombo->InsertString(m_pCurrentApplication->layouts.GetAt(m_pCurrentApplication->layouts.FindIndex(e))->GetName());

			pCombo->SetCurSel(Return.val);
			return pCombo;
		}
	}

	// Invalid
	return NULL;
}
void AseLoader::Process_MESH(OUT AseFrame* frame)
{
	std::vector<D3DXVECTOR3> position;
	std::vector<D3DXVECTOR2> uv;
	std::vector<FVF_PositionNormalTexture>& vertexArray = frame->GetVertexArray();
	int level = 0;
	do 
	{
		char* aseToken = GetToken();
		if (IsEqual(aseToken, "{"))
		{
			level++;
		}
		else if (IsEqual(aseToken, "}"))
		{
			level--;
		}
		else if (IsEqual(aseToken, ID_MESH_NUMVERTEX))
		{		
			//
			position.resize(GetInteger());
		}
		else if (IsEqual(aseToken, ID_MESH_NUMFACES))
		{		
			//
			vertexArray.resize(GetInteger() * 3);
		}
		else if (IsEqual(aseToken, ID_MESH_VERTEX_LIST))
		{		
			Process_MESH_VERTEX_LIST(position);
		}
		else if (IsEqual(aseToken, ID_MESH_FACE_LIST))
		{		
			Process_MESH_FACE_LIST(position, vertexArray);
		}
		else if (IsEqual(aseToken, ID_MESH_NUMTVERTEX))
		{		
			//
			uv.resize(GetInteger());
		}
		else if (IsEqual(aseToken, ID_MESH_TVERTLIST))
		{		
			Process_MESH_TVERTLIST(uv);
		}
		else if (IsEqual(aseToken, ID_MESH_TFACELIST))
		{
			Process_ID_MESH_TFACELIST(uv, vertexArray);
		}
		else if (IsEqual(aseToken, ID_MESH_NORMALS))
		{
			Process_MESH_NORMALS(vertexArray);
		}
		
	} while (level > 0);

	D3DXMATRIXA16& world = frame->GetWorldTransform();
	D3DXMATRIXA16 inverseWorld;
	D3DXMatrixInverse(&inverseWorld, 0, &world);
	for ( size_t i = 0; i < vertexArray.size(); ++i )
	{
		D3DXVec3TransformCoord(&vertexArray[i].pos, &vertexArray[i].pos, &inverseWorld);
		D3DXVec3TransformNormal(&vertexArray[i].normal, &vertexArray[i].normal, &inverseWorld);
	}
}
Esempio n. 14
0
//FlashCS5extension.WriteDynamic(라이브러리 다이나믹들)
JSBool WriteDynamic(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval) {
    
    writelog("begin");
    
    if(argc != 1)
        return JS_FALSE;
    
    writelog("check arg count");
	
	if(pObjectFile) {
		JSObject* dynamicObjs;
		if(JS_ValueToObject(cx, argv[0], &dynamicObjs) == JS_FALSE)
			return ReturnString(cx, "q _ 1", rval);
        
        writelog("get dynamic objects from argv[0]");
		
		unsigned int dynamicLen = (unsigned int)JS_GetArrayLength(cx, dynamicObjs);
		if(dynamicLen == -1)
			return ReturnString(cx, "q _ 2", rval);
        
        writelog("get dynamic length = %u", dynamicLen);
		
		fwrite(&dynamicLen, sizeof(unsigned int), 1, pObjectFile);
		
		for(int i = 0; i < dynamicLen; i++) {
			jsval posDynamic;
			if(JS_GetElement(cx, dynamicObjs, i, &posDynamic) == JS_FALSE)
				return ReturnString(cx, "q _ 3", rval);
            
            writelog("==================================");
            writelog("get dynamic element %d", i);
			
			JSObject* dynamicObj;
			if(JS_ValueToObject(cx, posDynamic, &dynamicObj) == JS_FALSE)
				return ReturnString(cx, "q _ 4", rval);
            
            writelog("get dynamic object %d", i);
			
			//라이브러리 네임
            char *libName = GetString(cx, dynamicObj, 0);
            if(libName == 0)
                return ReturnString(cx, "q _ 5", rval);
            
            //library ID
			unsigned int libID = PushLibraryName(libName);
			fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
            writelog("libName = %s, libID = %u", libName, libID);
			free(libName);
            
            //library Type
            long libType;
            if(GetInteger(cx, dynamicObj, 4, &libType) == JS_FALSE)
                return ReturnString(cx, "q _ 51", rval);
            
            writelog("lib type = %d", libType);
            fwrite(&libType, sizeof(long), 1, pObjectFile);
            
            //frame Length
            long frameLength;
            if(GetInteger(cx, dynamicObj, 5, &frameLength) == JS_FALSE)
                return ReturnString(cx, "q _ 51", rval);
            
            writelog("frame length = %d", frameLength);
            fwrite(&frameLength, sizeof(long), 1, pObjectFile);
            
//            //인스턴스 
//            {
//                JSObject* instanceObj;
//                if(GetObject(cx, dynamicObj, 3, &instanceObj) == JS_FALSE)
//                    return ReturnString(cx, "instance  _ 1", rval);
//                
//                //인스턴스 개수
//                int insLen = (int)JS_GetArrayLength(cx, instanceObj);
//                if(insLen == -1)
//                    return ReturnString(cx, "instance  _ 2", rval);
//                
//                fwrite(&insLen, sizeof(int), 1, pObjectFile);
//                
//                writelog("instance length = %d", insLen);
//                
//                for(int m = 0; m < insLen; m++) {
//                    //instance obj
//                    JSObject* insObj;
//                    if(GetObject(cx, instanceObj, m, &insObj) == JS_FALSE)
//                        return ReturnString(cx, "instance  _ 3", rval);
//                    
//                    //instance id
//                    long insid;
//                    if(GetInteger(cx, insObj, 1, &insid) == JS_FALSE)
//                        return ReturnString(cx, "instance  _ 4", rval);
//                    
//                    //instance name
//                    char* insName = GetString(cx, insObj, 0);
//                    //instnace name length
//                    int insNameLen = strlen(insName);
//                    
//                    fwrite(&insNameLen, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("instance name length = %d", insNameLen);
//                    
//                    fwrite(insName, sizeof(char), insNameLen, pObjectFile);
//                    
//                    writelog("instance name = %s", insName);
//                    
//                    fwrite(&insid, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("instance id = %d", insid);
//                    
//                    free(insName);
//                }
//            }
            
            //레퍼런스
            {
                JSObject* referenceObj;
                if(GetObject(cx, dynamicObj, 1, &referenceObj) == JS_FALSE)
                    return ReturnString(cx, "q _ 6", rval);
                
                writelog("--------------------------------");
                writelog("get reference obj");
                
                
                
                //reference count
                int refLen = (int)JS_GetArrayLength(cx, referenceObj);
                if(refLen == -1)
                    return ReturnString(cx, "q _ 7", rval);
                
                writelog("reference length = %ld", refLen);
                
                fwrite(&refLen, sizeof(int), 1, pObjectFile);
                
                for(int j = 0; j < refLen; ++j) {
                    writelog("--------------------------------");
                    
                    //ref info obj
                    JSObject* refObj;
                    if(GetObject(cx, referenceObj, j, &refObj) == JS_FALSE)
                        return ReturnString(cx, "q _ 71", rval);
                    
                    int refMemberIndex = 0;
                    
                    int refinfoLen = (int)JS_GetArrayLength(cx, refObj);
                    if(refinfoLen == -1)
                        return ReturnString(cx, "q _ 72", rval);
                    
                    //reference ID
                    long refid;
                    if(GetInteger(cx, refObj, refMemberIndex++, &refid) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                    //type
                    long type;
                    if(GetInteger(cx, refObj, refMemberIndex++, &type) == JS_FALSE)
                        return ReturnString(cx, "q _ 11", rval);
                    
                    writelog("type = %d", type);
                    
                    fwrite(&type, sizeof(long), 1, pObjectFile);
                    
                    //lib ID
                    char* libName = GetString(cx, refObj, refMemberIndex++);

                    //read Depth
                    
                    //read StartFrame
                    long startFrame;
                    if(GetInteger(cx, refObj, refMemberIndex++, &startFrame) == JS_FALSE)
                        return ReturnString(cx, "q _ 11", rval);
                    
                    //read End Frame
                    long endFrame;
                    if(GetInteger(cx, refObj, refMemberIndex++, &endFrame) == JS_FALSE)
                        return ReturnString(cx, "q _ 42", rval);
                    
                    //read next reference ID
                    long nextrefid;
                    if(GetInteger(cx, refObj, refMemberIndex++, &nextrefid) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                    //read depth
                    long depth;
                    if(GetInteger(cx, refObj, refMemberIndex++, &depth) == JS_FALSE)
                        return ReturnString(cx, "q _ 8", rval);
                    
                                        
                    if(type == _TYPE_BITMAP_) {
                        //lib Path                    
                        char* libPath = GetString(cx, refObj, refMemberIndex++);
                        unsigned int libID = PushLibraryName(libPath);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib path = %s, lib = %u", libPath, libID);
                        free(libPath);
                    } else if(type == _TYPE_GRAPHIC_) {
                        //get lib name
                        unsigned int libID = PushLibraryName(libName);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib name = %s, lib = %u", libName, libID);
                        free(libName); 
                    } else {
                        //get lib name
                        unsigned int libID = PushLibraryName(libName);
                        fwrite(&libID, sizeof(unsigned int), 1, pObjectFile);
                        writelog("lib name = %s, lib = %u", libName, libID);
                        free(libName);    
                        
                        //instance ID
                        long insLen;
                        char* insName = GetString(cx, refObj, refMemberIndex++);
                        insLen = strlen(insName);
                        fwrite(&insLen, sizeof(long), 1, pObjectFile);
                        fwrite(insName, insLen, 1, pObjectFile);
                        writelog("instnace name = %s", insName);
                    }
                    
                    //write depth
                    writelog("depth = %d", depth);
                    fwrite(&depth, sizeof(long), 1, pObjectFile);
                    
                    //write Start Frame
                    writelog("startFrame = %d", startFrame);
                    
                    fwrite(&startFrame, sizeof(long), 1, pObjectFile);
                    
                    //write End Frame
                    writelog("end frame = %d", endFrame);
                    
                    fwrite(&endFrame, sizeof(long), 1, pObjectFile);

                    if(type == _TYPE_BITMAP_ || type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_) {
                        
                        
                        writelog("ref id = %d", refid);
                        
                        fwrite(&refid, sizeof(long), 1, pObjectFile);
                        
                        //write next reference ID
                        writelog("next ref id = %d", nextrefid);
                        
                        fwrite(&nextrefid, sizeof(long), 1, pObjectFile);
                        
                        //Start Position
                        double startX;
                        double startY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startX) == JS_FALSE)
                            return ReturnString(cx, "q _ 12", rval);
                        
                        if(GetDouble(cx, refObj, refMemberIndex++, &startY) == JS_FALSE)
                            return ReturnString(cx, "q _ 13", rval);
                        
                        float startXf, startYf;
                        startXf = (float)startX;
                        startYf = (float)startY;
                        fwrite(&startXf, sizeof(float), 1, pObjectFile);
                        fwrite(&startYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("startX = %f, startY = %f", startX, startY);
                        
                        //Anchor
                        double anchorX;
                        double anchorY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &anchorX) == JS_FALSE)
                            return ReturnString(cx, "q _ 14", rval);
                        
                        if(GetDouble(cx, refObj, refMemberIndex++, &anchorY) == JS_FALSE)
                            return ReturnString(cx, "q _ 15", rval);
                        
                        float anchorXf, anchorYf;
                        anchorXf = (float)anchorX;
                        anchorYf = (float)anchorY;
                        fwrite(&anchorXf, sizeof(float), 1, pObjectFile);
                        fwrite(&anchorYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("anchorX = %f, anchorY = %f", anchorX, anchorY);
                        
                        //Start Rotation
                        double startRotation;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startRotation) == JS_FALSE)
                            return ReturnString(cx, "q _ 16", rval);
                        
                        float rotf = (float)startRotation;
                        fwrite(&rotf, sizeof(float), 1, pObjectFile);
                        
                        writelog("rotation = %f", startRotation);
                        
                        //Start Scale
                        double scaleX;
                        double scaleY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &scaleX) == JS_FALSE)
                            return ReturnString(cx, "q _ 17", rval);
                        if(GetDouble(cx, refObj, refMemberIndex++, &scaleY) == JS_FALSE)
                            return ReturnString(cx, "q _ 18", rval);
                        
                        float scaleXf, scaleYf;
                        scaleXf = (float)scaleX;
                        scaleYf = (float)scaleY;
                        fwrite(&scaleXf, sizeof(float), 1, pObjectFile);
                        fwrite(&scaleYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("scale x = %f, y = %f", scaleX, scaleY);
                        
                        //Start Skew
                        double startSkewX;
                        double startSkewY;
                        if(GetDouble(cx, refObj, refMemberIndex++, &startSkewX) == JS_FALSE)
                            return ReturnString(cx, "q _ 19", rval);
                        if(GetDouble(cx, refObj, refMemberIndex++, &startSkewY) == JS_FALSE)
                            return ReturnString(cx, "q _ 20", rval);
                        
                        float skewXf, skewYf;
                        skewXf = (float)startSkewX;
                        skewYf = (float)startSkewY;
                        fwrite(&skewXf, sizeof(float), 1, pObjectFile);
                        fwrite(&skewYf, sizeof(float), 1, pObjectFile);
                        
                        writelog("skew x = %f, y = %f", startSkewX, startSkewY);
                        
                        if(type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_) {
                            //Start Color Style
                            long startColorAlphaPercent;
                            long startColorRedPercent;
                            long startColorGreenPercent;
                            long startColorBluePercent;
                            long startColorAlphaAmount;
                            long startColorRedAmount;
                            long startColorGreenAmount;
                            long startColorBlueAmount;
                            
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorAlphaPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 22", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorRedPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 23", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorGreenPercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 24", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBluePercent) == JS_FALSE)
                                return ReturnString(cx, "q _ 25", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorAlphaAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 26", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorRedAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 27", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorGreenAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 28", rval);
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBlueAmount) == JS_FALSE)
                                return ReturnString(cx, "q _ 29", rval);
                            
                            char alphaPercent = (char)startColorAlphaPercent;
                            char redPercent = (char)startColorRedPercent;
                            char greenPercent = (char)startColorGreenPercent;
                            char bluePercent = (char)startColorBluePercent;
                            short alphaAmount = (short)startColorAlphaAmount;
                            short redAmount = (short)startColorRedAmount;
                            short greenAmount = (short)startColorGreenAmount;
                            short blueAmount = (short)startColorBlueAmount;                            
                            fwrite(&redPercent, sizeof(char), 1, pObjectFile);
                            fwrite(&greenPercent, sizeof(char), 1, pObjectFile);
                            fwrite(&bluePercent, sizeof(char), 1, pObjectFile);
                            fwrite(&alphaPercent, sizeof(char), 1, pObjectFile);                            
                            fwrite(&redAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&greenAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&blueAmount, sizeof(short), 1, pObjectFile);
                            fwrite(&alphaAmount, sizeof(short), 1, pObjectFile);
                            
                            writelog("alpha percent = %d", startColorAlphaPercent);
                            writelog("red percent = %d", startColorRedPercent);
                            writelog("green percent = %d", startColorGreenPercent);
                            writelog("blue percent = %d", startColorBluePercent);
                            writelog("alpha amount = %d", startColorAlphaAmount);
                            writelog("red amount = %d", startColorRedAmount);
                            writelog("green amount = %d", startColorGreenAmount);
                            writelog("blue amount = %d", startColorBlueAmount);
                        }
                        
                        if(type == _TYPE_GRAPHIC_ || type == _TYPE_MOVIECLIP_)  {
                            long startColorBlendMode;
                            if(GetInteger(cx, refObj, refMemberIndex++, &startColorBlendMode) == JS_FALSE)
                                return ReturnString(cx, "q _ 30", rval);
                            
                            unsigned char blendMode = (unsigned char)startColorBlendMode;
                            fwrite(&blendMode, sizeof(blendMode), 1, pObjectFile);
                            writelog("blend mode = %d", startColorBlendMode);
                            
                            //Ease
                            long easeType;
                            if(GetInteger(cx, refObj, refMemberIndex++, &easeType) == JS_FALSE)
                                return ReturnString(cx, "q _ 31", rval);
                            
                            writelog("ease type = %d", easeType);
                            
                            unsigned char easeTypeuc = (unsigned char)easeType;
                            fwrite(&easeTypeuc, sizeof(easeTypeuc), 1, pObjectFile);
                            
                            if(easeType == 2) {  //멀티 타입일 경우(Position, Rotation, Scale, Color, Filters)
                                for(int l = 0; l < 4; ++l)
                                {
                                    JSObject* easeObj;
                                    if(GetObject(cx, refObj, refMemberIndex++, &easeObj) == JS_FALSE)
                                        return ReturnString(cx, "q _ 32", rval);
                                    
                                    writelog("get multi ease obj");
                                    
                                    int easeCount = JS_GetArrayLength(cx, easeObj);
                                    if(easeCount == -1)
                                        return ReturnString(cx, "q _ 33", rval);
                                    
                                    writelog("get ease length = %d", easeCount);
                                    
                                    fwrite(&easeCount, sizeof(int), 1, pObjectFile);
                                    
                                    for(int k = 0; k < easeCount; ++k) {
                                        JSObject* posObj;
                                        if(GetObject(cx, easeObj, k, &posObj) == JS_FALSE)
                                            return ReturnString(cx, "q _ 34", rval);
                                        
                                        writelog("get pos obj");
                                        
                                        double x, y;
                                        if(GetDouble(cx, posObj, 0, &x) == JS_FALSE)
                                            return ReturnString(cx, "q _ 35", rval);
                                        if(GetDouble(cx, posObj, 1, &y) == JS_FALSE)
                                            return ReturnString(cx, "q _ 36", rval);
                                        
                                        float fx, fy;
                                        fx = (float)x;
                                        fy = (float)y;
                                        fwrite(&fx, sizeof(float), 1, pObjectFile);
                                        fwrite(&fy, sizeof(float), 1, pObjectFile);
                                        
                                        writelog("x = %f, y = %f", x, y);
                                    }
                                }
                            } else if(easeType == 1) {        //싱글이나 심플일 경우
                                JSObject* easeObj;
                                if(GetObject(cx, refObj, refMemberIndex++, &easeObj) == JS_FALSE)
                                    return ReturnString(cx, "q _ 37", rval);
                                
                                writelog("get ease obj");
                                
                                int easeCount = JS_GetArrayLength(cx, easeObj);
                                if(easeCount == -1)
                                    return ReturnString(cx, "q _ 38", rval);
                                
                                writelog("get ease length = %d", easeCount);
                                
                                fwrite(&easeCount, sizeof(int), 1, pObjectFile);
                                
                                for(int k = 0; k < easeCount; ++k) {
                                    JSObject* posObj;
                                    if(GetObject(cx, easeObj, k, &posObj) == JS_FALSE)
                                        return ReturnString(cx, "q _ 39", rval);
                                    
                                    writelog("get pos obj");
                                    
                                    double x, y;
                                    if(GetDouble(cx, posObj, 0, &x) == JS_FALSE)
                                        return ReturnString(cx, "q _ 40", rval);
                                    if(GetDouble(cx, posObj, 1, &y) == JS_FALSE)
                                        return ReturnString(cx, "q _ 41", rval);
                                    
                                    float fx, fy;
                                    fx = (float)x;
                                    fy = (float)y;
                                    fwrite(&fx, sizeof(float), 1, pObjectFile);
                                    fwrite(&fy, sizeof(float), 1, pObjectFile);
                                    
                                    writelog("x = %f, y = %f", x, y);
                                }
                            }
                        }    
                    }
                }                
            }
            
//			//프레임
//            {
//                JSObject* frameObj;
//                if(GetObject(cx, dynamicObj, 2, &frameObj) == JS_FALSE)
//                    return ReturnString(cx, "q _ 60", rval);
//                
//                writelog("get frame obj");
//                
//                //프레임 개수
//                int frameCount;
//                frameCount = JS_GetArrayLength(cx, frameObj);
//                if(frameCount == -1)
//                    return ReturnString(cx, "q _ 61", rval);
//                
//                writelog("get frame count = %d", frameCount);
//                
//                fwrite(&frameCount, sizeof(int), 1, pObjectFile);
//                
//                for(int j = 0; j < frameCount; ++j) {
//                    //레퍼런스 아이디 배열
//                    JSObject* refObj;
//                    if(GetObject(cx, frameObj, j, &refObj) == JS_FALSE)
//                        return ReturnString(cx, "q _ 62", rval);
//                    
//                    fwrite(&j, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("frame = %d", j);
//                    
//                    //레퍼런스 개수
//                    int refCount = JS_GetArrayLength(cx, refObj);
//                    if(refCount == -1)
//                        return ReturnString(cx, "q _ 63", rval);
//                    
//                    fwrite(&refCount, sizeof(int), 1, pObjectFile);
//                    
//                    writelog("ref count = %d", refCount);
//                    
//                    for(int k = 0; k < refCount; ++k) {
//                        //레퍼런스 번호
//                        long refid;
//                        if(GetInteger(cx, refObj, k, &refid) == JS_FALSE)
//                            return ReturnString(cx, "q _ 64", rval);
//                        
//                        fwrite(&refid, sizeof(long), 1, pObjectFile);
//                        
//                        writelog("ref id = %d", refid);
//                    }
//                }
//            }
		}
        
		*rval = JS_BooleanToValue(JS_TRUE);
		
		return JS_TRUE; 
	} else {
		return ReturnString(cx, "a _ 17", rval);
	}
}
Esempio n. 15
0
Element CompositeIntegerGroup::CascadeExponentiate(const Element &a1, const Integer &e1,
        const Element &a2, const Integer &e2) const
{
    return Element(new IntegerElementData(
                       _p.PowCascade(GetInteger(a1), e1, GetInteger(a2), e2)));
}
Esempio n. 16
0
void CSyntTree::Imprimir(int n)
{
	int i;

	for (i = 0; i < n; i++)
		printf("    ");

	int hijo = 0;

	switch(GetType())
	{
		case SYNT_INSTRUCCION:
			printf("Instrucción: \n");
			break;

		case SYNT_RETURN:
			printf("Return: \n");
			break;

		case SYNT_FOR:
			printf("Instrucción For:\n");
			
			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Inicialización:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Condicion:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Incremento:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Ciclo:\n");
			GetChild(hijo++)->Imprimir(n + 2);
			break;

		case SYNT_WHILE:
			printf("Instrucción While:\n");
			
			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Condición:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Ciclo:\n");
			GetChild(hijo++)->Imprimir(n + 2);
			break;

		case SYNT_IF:
			printf("Instrucción If:\n");
			
			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Condición:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			for (i = 0; i < n + 1; i++)
				printf("    ");
			printf("Si es verdad:\n");
			GetChild(hijo++)->Imprimir(n + 2);

			if (GetChilds() == 3)
			{
				for (i = 0; i < n + 1; i++)
					printf("    ");
				printf("Si es falso:\n");
				GetChild(hijo++)->Imprimir(n + 2);
			}
			break;

		case SYNT_INSTRUCCION_NULA:
			printf("Instrucción nula\n");
			break;

		case SYNT_LISTA_FUNCIONES:
			printf("Lista de funciones:\n");
			break;

		case SYNT_LISTA_INSTRUCCIONES:
			printf("Lista de instrucciones:\n");
			break;

		case SYNT_IDENTIFICADOR:
			printf("Identificador: %s\n", GetString());
			break;

		case SYNT_VARIABLE:
			printf("Variable: %s\n", GetString());
			break;
		
		case SYNT_CONSTANTE:
			printf("Valor constante ");

			if (strcmp(GetReturnType()->GetNombre(), SIMBOLO_INT) == 0)
				printf("(entero) %ld\n", GetInteger());
			else
				if (strcmp(GetReturnType()->GetNombre(), SIMBOLO_FLOAT) == 0)
					printf("(float) %f\n", GetFloat());
				else
					if (strcmp(GetReturnType()->GetNombre(), SIMBOLO_STRING) == 0)
						printf("(cadena) %s\n", GetString());
			break;

		case SYNT_OP_ASIGNACION:
			printf ("Operador =\n");
			break;

		case SYNT_OP_MAS:
			printf ("Operador +\n");
			break;

		case SYNT_OP_MENOS:
			printf ("Operador -\n");
			break;

		case SYNT_OP_POR:
			printf ("Operador *\n");
			break;

		case SYNT_OP_DIV:
			printf ("Operador /\n");
			break;

		case SYNT_LLAMADO_FUNCION:
			printf("LLamado a función: %s\n", GetString());
			break;

		case SYNT_DECLARACION_VARIABLE:
			printf("Declaración de variables del tipo %s\n", GetString());
			break;

		case SYNT_DECLARACION_FUNCION:
			printf("Declaración de la función: %s\n", GetString());
			break;
		
		case SYNT_CONVERSION:
			printf("Conversion desde %s a %s\n", GetChild(0)->GetReturnType()->GetNombre(), GetReturnType()->GetNombre());
			break;

		case SYNT_TABLA_SIMBOLOS:
			printf("Tabla de simbolos\n");
			m_pTablaSimbolos->Imprimir(n + 1);
			break;
	}

	n++;

	for (; hijo < GetChilds(); hijo++)
		GetChild(hijo)->Imprimir(n);
}
Esempio n. 17
0
Element CompositeIntegerGroup::Inverse(const Element &a) const
{
    return Element(new IntegerElementData(GetInteger(a).ModInverse(_p)));
}
Esempio n. 18
0
BOOL PerformanceMonitorPage::OnInitDialog(CWindow /*focus*/,
                                          LPARAM /*init_param*/) {
  auto preferences = application_->GetPreferences(perfmon::kPreferenceName);

  auto monitor_cpu = preferences->GetInteger(perfmon::kMonitorCpuValue,
                                             perfmon::kMonitorCpuDefault);
  cpu_usage_ = preferences->GetInteger(perfmon::kCpuUsageValue,
                                       perfmon::kCpuUsageDefault);
  cpu_time_ =
      preferences->GetInteger(perfmon::kCpuTimeValue, perfmon::kCpuTimeDefault);
  auto cpu_time_unit = preferences->GetInteger(perfmon::kCpuTimeUnitValue,
                                               perfmon::kCpuTimeUnitDefault);

  auto monitor_disk = preferences->GetInteger(perfmon::kMonitorDiskValue,
                                              perfmon::kMonitorDiskDefault);
  disk_usage_ = preferences->GetInteger(perfmon::kDiskUsageValue,
                                        perfmon::kDiskUsageDefault);
  disk_time_ = preferences->GetInteger(perfmon::kDiskTimeValue,
                                       perfmon::kDiskTimeDefault);
  auto disk_time_unit = preferences->GetInteger(perfmon::kDiskTimeUnitValue,
                                                perfmon::kDiskTimeUnitDefault);

  auto monitor_traffic = preferences->GetInteger(
      perfmon::kMonitorTrafficValue, perfmon::kMonitorTrafficDefault);
  traffic_ =
      preferences->GetInteger(perfmon::kTrafficValue, perfmon::kTrafficDefault);
  auto traffic_unit = preferences->GetInteger(perfmon::kTrafficUnitValue,
                                              perfmon::kTrafficUnitDefault);
  traffic_time_ = preferences->GetInteger(perfmon::kTrafficTimeValue,
                                          perfmon::kTrafficTimeDefault);
  auto traffic_time_unit = preferences->GetInteger(
      perfmon::kTrafficTimeUnitValue, perfmon::kTrafficTimeUnitDefault);

  DoDataExchange(DDX_LOAD);

  CString seconds, minutes, hours;
  seconds.LoadString(IDS_SECONDS);
  minutes.LoadString(IDS_MINUTES);
  hours.LoadString(IDS_HOURS);

  monitor_cpu_.SetCheck(monitor_cpu);
  cpu_usage_spin_.SetRange(1, 100);
  cpu_time_spin_.SetRange(1, 100);
  cpu_time_unit_.AddString(seconds);
  cpu_time_unit_.AddString(minutes);
  cpu_time_unit_.AddString(hours);
  cpu_time_unit_.SetCurSel(cpu_time_unit);

  monitor_disk_.SetCheck(monitor_disk);
  disk_usage_spin_.SetRange(1, 100);
  disk_time_spin_.SetRange(1, 100);
  disk_time_unit_.AddString(seconds);
  disk_time_unit_.AddString(minutes);
  disk_time_unit_.AddString(hours);
  disk_time_unit_.SetCurSel(disk_time_unit);

  monitor_traffic_.SetCheck(monitor_traffic);
  traffic_spin_.SetRange32(1, 100000);
  traffic_unit_.AddString(L"B/s");
  traffic_unit_.AddString(L"KB/s");
  traffic_unit_.AddString(L"MB/s");
  traffic_unit_.SetCurSel(traffic_unit);
  traffic_time_spin_.SetRange(1, 100);
  traffic_time_unit_.AddString(seconds);
  traffic_time_unit_.AddString(minutes);
  traffic_time_unit_.AddString(hours);
  traffic_time_unit_.SetCurSel(traffic_time_unit);

  return TRUE;
}
Esempio n. 19
0
bool CompositeIntegerGroup::IsIdentity(const Element &a) const
{
    return (GetInteger(a) == 1);
}
Esempio n. 20
0
int main()
{
    Set<nodeT *> graph;
    Map<nodeT *> graphMap;
    
	InitGraphics();
	SetWindowTitle("Pathfinder");
    
    string backgroundFile;
    bool timeToQuit = false;
    
    
    cout << "This masterful piece of work is a graph extravaganza!" << endl;
    
    while (true) {
        
        cout << "Your options are:" << endl;
        cout << "(1) Choose a new graph data file" << endl;
        cout << "(2) Find shortest path using Dijkstra's algorithm" << endl;
        cout << "(3) Compute the minimal spanning tree using Kruskal's algorithm" << endl;
        cout << "(4) Determine if the graph has cycles" << endl;
        cout << "(5) Quit" << endl;
        cout << "Enter choice: ";
        
        int choice = GetInteger();
        string datafile;
        void UpdateDisplay();
        
        switch (choice) {
            case 1:
                cout << "Enter the name of the data file: ";
                datafile = GetLine();
                //datafile = "Small.txt";
                //datafile = "USA.txt";
                //datafile = "Stanford.txt";
                graph.clear();
                graphMap.clear();
                backgroundFile = ReadGraph(graph, graphMap, datafile);
                break;
            case 2:
                if (backgroundFile == "") {
                    cout << "No file is specified" << endl;
                }
                else {
                    UpdateDisplay();
                    MovePen(0,0);
                    DrawNamedPicture(backgroundFile);
                    DrawNodesAndArcs(graph);
                    cout << "(2) Finding shortest path using Dijkstra's algorithm" << endl;
                    HandleShortestPath(graph);
                }
                break;
            case 3:
                if (backgroundFile == "") {
                    cout << "No file is specified" << endl;
                }
                else {
                    cout << "(3) Computing the minimal spanning tree using Kruskal's algorithm" << endl;
                    UpdateDisplay();
                    MovePen(0,0);
                    DrawNamedPicture(backgroundFile);
                    //DrawNodesAndArcs(graph);
                    minimumSpanningTree(graph, graphMap);
                }
                break;
            case 4:
                if (backgroundFile == "") {
                    cout << "No file is specified" << endl;
                }
                else {
                    graphT graph2;
                    graph2.allNodes = graph;
                    
                    cout << "(4) Determining if the graph has cycles" << endl;
                    if (IsCyclicGraph(graph2))
                        cout << "Yes, it is cyclic" << endl;
                    else
                        cout << "No, it is not cyclic" << endl;
                }
                break;
            case 5:
                cout << "Thanks for using Pathfinder. Bye!" << endl;
                timeToQuit = true;
                break;
                
            default:
                cout << "Invalid choice" << endl;
                break;
        }
        
        if (timeToQuit) break;
        
    }
    return (0);
}
 /**
  * Subtraction operator, produces a new Integer
  * @param other the Integer to subtract (subtrahend)
  */
 virtual IntegerData *Subtract(const IntegerData *other) const
 {
   return new CppIntegerData(_integer.Minus(GetInteger(other)));
 }
Esempio n. 22
0
BOOL MonitorClipboardPage::OnInitDialog(CWindow /*focus*/,
                                        LPARAM /*init_param*/) {
  auto preferences = application_->GetPreferences(clipbrd::kPreferenceName);

  num_rings_ = preferences->GetInteger(clipbrd::kNumRingsKeyValue,
                                       clipbrd::kNumRingsDefault);
  num_entries_ = preferences->GetInteger(clipbrd::kNumEntriesKeyValue,
                                         clipbrd::kNumEntriesDefault);

  DoDataExchange(DDX_LOAD);

  num_rings_spin_.SetRange(kMinRings, kMaxRings);
  num_entries_spin_.SetRange(kMinEntries, kMaxEntries);

  UINT key_code, modifiers;

  key_code = preferences->GetInteger(clipbrd::kPrevRingKeyValue,
                                     clipbrd::kPrevRingKeyDefault);
  modifiers = preferences->GetInteger(clipbrd::kPrevRingModifiersValue,
                                      clipbrd::kPrevRingModifiersDefault);
  prev_ring_hotkey_.SetHotKey(key_code, modifiers);

  key_code = preferences->GetInteger(clipbrd::kNextRingKeyValue,
                                     clipbrd::kNextRingKeyDefault);
  modifiers = preferences->GetInteger(clipbrd::kNextRingModifiersValue,
                                      clipbrd::kNextRingModifiersDefault);
  next_ring_hotkey_.SetHotKey(key_code, modifiers);

  key_code = preferences->GetInteger(clipbrd::kPrevEntryKeyValue,
                                     clipbrd::kPrevEntryKeyDefault);
  modifiers = preferences->GetInteger(clipbrd::kPrevEntryModifiersValue,
                                      clipbrd::kPrevEntryModifiersDefault);
  prev_entry_hotkey_.SetHotKey(key_code, modifiers);

  key_code = preferences->GetInteger(clipbrd::kNextEntryKeyValue,
                                     clipbrd::kNextEntryKeyDefault);
  modifiers = preferences->GetInteger(clipbrd::kNextEntryModifiersValue,
                                      clipbrd::kNextEntryModifiersDefault);
  next_entry_hotkey_.SetHotKey(key_code, modifiers);

  key_code = preferences->GetInteger(clipbrd::kDeleteEntryKeyValue,
                                     clipbrd::kDeleteEntryKeyDefault);
  modifiers = preferences->GetInteger(clipbrd::kDeleteEntryModifiersValue,
                                      clipbrd::kDeleteEntryModifiersDefault);
  delete_hotkey_.SetHotKey(key_code, modifiers);

  return TRUE;
}
 /**
  * Division operator, produces a new Integer
  * @param divisor the Integer to divide into this
  */
 virtual IntegerData *Divide(const IntegerData *divisor) const
 {
   return new CppIntegerData(_integer.DividedBy(GetInteger(divisor)));
 }
Esempio n. 24
0
void MpGlobal::ParseOptions (int argc, const char *argv[], 
                             const char *application)
{
  // If the application name is given the parse the X resources data base.
  // This is done before the command line arguments to allow overriding

  if (application != NULL) ParseResources (application);

  // now parse the command line options

  for (int i = 1; i < argc; i++) {

    // toggles

    if (! MatchOption(argv[i],"-german",4) ) {
      Mp.Language = MpGerman;
            
    } else if (! MatchOption(argv[i],"-english",4) ) {
      Mp.Language = MpEnglish;

    // integers
            
    } else if (! MatchOption(argv[i],"-framewidth",7) ) {
        Mp.FrameWidth = GetInteger(argc,argv,++i);

    } else if (! MatchOption(argv[i],"-framemidwidth",7) ) {
        Mp.FrameMidWidth = GetInteger(argc,argv,++i);
            
    } else if (! MatchOption(argv[i],"-framestyle",7) ) {
        Mp.FrameStyle = GetInteger(argc,argv,++i);

    } else if (! MatchOption(argv[i],"-buttonheight",8) ) {
        Mp.ButtonHeight = GetInteger(argc,argv,++i);

    } else if (! MatchOption(argv[i],"-buttonwidth",8) ) {
        Mp.ButtonWidth = GetInteger(argc,argv,++i);

    } else if (! MatchOption(argv[i],"-shifterwidth",9) ) {
        Mp.ShifterWidth = GetInteger(argc,argv,++i);

    } else if (! MatchOption(argv[i],"-toggleimagesize",9) ) {
        Mp.ToggleImageSize = GetInteger(argc,argv,++i);
        
    } else if (! MatchOption(argv[i],"-pulldownimagesize",11) ) {
        Mp.PulldownImageSize = GetInteger(argc,argv,++i);
            
    } else if (! MatchOption(argv[i],"-radioimagesize",8) ) {
        Mp.RadioImageSize = GetInteger(argc,argv,++i);

    // strings

    } else if (! MatchOption(argv[i],"-printer",3) ) {
      if (++i < argc) 
        strncpy(DefaultPrinter,argv[i],str_max);

    } else if (! MatchOption(argv[i],"-viewer",3) ) {
      if (++i < argc) 
        strncpy(DefaultViewer,argv[i],str_max);

    } else if (! MatchOption(argv[i],"-psviewer",3) ) {
      if (++i < argc) 
        strncpy(DefaultPSViewer,argv[i],str_max);
    }
  }
}
 virtual IntegerData *Modulus(const IntegerData *modulus) const 
 {
   return new CppIntegerData(_integer % GetInteger(modulus));
 }
Esempio n. 26
0
Element CompositeIntegerGroup::Multiply(const Element &a, const Element &b) const
{
    return Element(new IntegerElementData((GetInteger(a).MultiplyMod(GetInteger(b), _p))));
}
 /**
  * Less than or equal
  * @param other the IntegerData to compare
  */
 virtual bool operator<=(const IntegerData *other) const
 {
   return _integer <= GetInteger(other);
 }
Esempio n. 28
0
Element CompositeIntegerGroup::Exponentiate(const Element &a, const Integer &exp) const
{
    return Element(new IntegerElementData(GetInteger(a).Pow(exp, _p)));
}
Esempio n. 29
0
struct TParameterList *NextParameter(
  struct TParameterList *ptParameterList,
  char *pcValue)
/****************************************************************************/
/* Determines which of the array of next pointers has to be choosen. This   */
/* array of next pointers is used to implement the union in function defi-  */
/* nitions. If there is no union, the normal next parameter is returned.    */
/****************************************************************************/
{
  int       iValue;
  char     *pcErrorLine;
  struct TParameterList *ptNewList;

  iValue = GetInteger(pcValue);

  if (ptParameterList->iFollowedByUnion == TRUE)
  {
    if ((iValue < 0) || (iValue > UNIONARRAYSIZE + 1))
    {
      pcErrorLine = (char *) malloc(64);
      sprintf(pcErrorLine, "Runtime error, %d out of union boundary", iValue);
      LogLine(pcErrorLine);
      free(pcErrorLine);
      return NULL;
    }
    else
    {
      ptNewList = ptParameterList->aptNext[iValue];
    }
  }
  else
  {
    ptParameterList->ptThis->iLoopCount = iValue;
    ptNewList = ptParameterList->aptNext[0];
  }

  if (ptNewList != NULL)
    while ((ptNewList != NULL) && (ptNewList->ptRepRec != NULL))
    {
      if (ptNewList->ptRepRec->iBegin)
      {
        /* We found the begin of a repeated block. Now find out how     */
        /* many times we can expect the referenced block..              */
        if (ptNewList->ptRepRec->ptParameter == NULL)
        {
          AddError2("Parameter %s should be eigther constant or unspecified",
                    ptNewList->ptRepRec->ptParameter->pcName);
          iValue = 0;
        }
        else
        {
          if (ptNewList->ptRepRec->ptParameter->ptValue == NULL)
          {
            AddError2("Parameter %s must be a constant!",
                      ptNewList->ptRepRec->ptParameter->pcName);
            iValue = 0;
          }
          else
            iValue = ptNewList->ptRepRec->ptParameter->iLoopCount;
        }

        if (iValue == 0)
          ptNewList = ptNewList->aptNext[1];
        else
          ptNewList->ptRepRec->iCounter = iValue;

        ptNewList = ptNewList->aptNext[0];
      }
      else
      {
        /* We found the end of a repeated block. Jump to the beginning */
        /* Decrement counter and continue..                            */

        ptNewList = ptNewList->aptNext[1];
        ptNewList->ptRepRec->iCounter--;

        if (ptNewList->ptRepRec->iCounter == 0)
          ptNewList = ptNewList->aptNext[1];
        ptNewList = ptNewList->aptNext[0];
      }
    }
  return ptNewList;
}
int main() {
    
    bool endSim = false;
    
    Randomize();
    
    while (true) {
        double invalidElectResult = 0;
        int voters;
        double spread;
        double votingError;
        int trialRuns;
        
        Vector<int> elections;
        
        while (true) {
            cout << "Enter number of voters (or 0 to end simulation): ";
            voters = GetInteger();
            if (voters == 0) {
                endSim = true;
                break;
            }
            else if (voters < 0)
                cout << "Enter a positive integer." << endl;
            else
                break;
        }
        
        if (endSim) break;
        
        while (true) {
            cout << "Enter percentage spread between candidates (0 - 1.0): ";
            spread = GetReal();
            if (spread >=0 && spread <= 1.0)
                break;
            else
                cout << "Spread must be between 0 and 1.0" << endl;
        }
        while (true) {
            cout << "Enter voting error percentage: (0 - 1.0): ";
            votingError = GetReal();
            if (votingError >=0 && votingError <= 1.0)
                break;
            else
                cout << "Voting error must be between 0 and 1.0" << endl;
        }
        while (true) {
            cout << "Enter number of times to run the trial: ";
            trialRuns = GetInteger();
            if (trialRuns >= 1)
                break;
            else
                cout << "Enter a positive integer" << endl;
        }
        
        for (int i = 0; i < trialRuns; i++) {
            invalidElectResult = RunElectionTrial(voters, spread, votingError);
            cout << "Trial " << i + 1 << ": ";
            cout <<  "Chance of an invalid election result after 500 trials = " << invalidElectResult << "%" << endl;
            elections.add(invalidElectResult);
        }
        
        scoreStatsT scores = calculateStatistics(elections);
        
        cout << "Scores: MIN = " << scores.min << endl;
        cout << "Scores: MAX = " << scores.max << endl;
        cout << "Scores: AVG = " << scores.avg << endl;
        cout << "Scores: NUM = " << scores.num << endl;

        cout << "********************************************************" << endl << endl;
        
    }
    
    
    return 0;
}