예제 #1
0
OpenCVReader::OpenCVReader(list<vector<string> > configList)
{
	int notLoaded = 0;
	int tempCameraInput = 0;
	notLoaded += FindValue(configList, "CVCameraInput", tempCameraInput);
	assert(!notLoaded);
	cameraInput = (tempCameraInput != 0);
	if (!cameraInput)
	{
		notLoaded += FindValue(configList, "CVMovieFileInput", fileName);
		assert(!notLoaded);
		cvImageReader = cvCaptureFromFile(fileName);
	}
	else
	{
		notLoaded += FindValue(configList, "CVCameraNumber", cameraNumber);
		assert(!notLoaded);
		cvImageReader = cvCaptureFromCAM(cameraNumber);
	}
	assert(cvImageReader);
	IplImage* cvImage = cvQueryFrame(cvImageReader);
	assert(cvImage);
	height = cvImage->height;
	width = cvImage->width;
	channels = cvImage->nChannels;
	reset();
	//cout << "Height: " << height << " Width: " << width << " Channels: " << channels << endl;
}
예제 #2
0
ImageProviderEnhancer::ImageProviderEnhancer(list<vector<string> > configList, ImageProvider *realProvider) : realProvider(realProvider), workerThreadRunning(false)
{
	assert(realProvider);
	int notLoaded = 0;
	int tempImageResize = 0;
	tempImageResize += FindValue(configList, "ImageEnhResizeWidth", resizeWidth);
	tempImageResize += FindValue(configList, "ImageEnhResizeHeight", resizeHeight);
	imageResizing = !tempImageResize;
	
	assert(!notLoaded);
}
예제 #3
0
파일: ardb.cpp 프로젝트: kouhate/ardb
	bool Ardb::DBExist(const DBID& db, DBID& nextdb)
	{
		KeyObject start(Slice(), KV, db);
		Iterator* iter = FindValue(start, false);
		bool found = false;
		nextdb = db;
		if (NULL != iter && iter->Valid())
		{
			Slice tmpkey = iter->Key();
			KeyObject* kk = decode_key(tmpkey, NULL);
			if (NULL != kk)
			{
				if (kk->db == db)
				{
					found = true;
				} else
				{
					nextdb = kk->db;
				}
			}
			DELETE(kk);
		}
		DELETE(iter);
		return found;
	}
예제 #4
0
bool HLXSListTest::HandleFindCmd(const UTVector<UTString>& info)
{
    bool ret = false;

    int value = 0;
    bool useCurrentPos = false;
    if (!UTParamUtil::GetInt(info[1], value) ||
	!UTParamUtil::GetBool(info[2], useCurrentPos))
    {
	DPRINTF(D_ERROR, ("npSList::HandleFindCmd : failed to convert parameter\n"));
    }
    else
    {
	LISTPOSITION pos = (useCurrentPos) ? m_pos : m_list.GetHeadPosition();

	void* pValue = 0;
	bool destroyValue = FindValue(value, pos, pValue);

	if (useCurrentPos)
	    m_pos = m_list.Find(pValue, pos);
	else
	    m_pos =  m_list.Find(pValue);

	if (destroyValue)
	    DestroyValue(pValue);

	ret = true;
    }

    return ret;
}
예제 #5
0
파일: ardb.cpp 프로젝트: kouhate/ardb
	int Ardb::FlushScripts()
	{
		KeyObject start(Slice(), SCRIPT, ARDB_GLOBAL_DB);
		Iterator* iter = FindValue(start, false);
		BatchWriteGuard guard(GetEngine());
		while (NULL != iter && iter->Valid())
		{
			Slice tmpkey = iter->Key();
			KeyObject* kk = decode_key(tmpkey, NULL);
			if (NULL != kk)
			{
				if (kk->type == SCRIPT)
				{
					DelValue(*kk);
				} else
				{
					break;
				}
			}
			DELETE(kk);
			iter->Next();
		}
		DELETE(iter);
		return 0;
	}
예제 #6
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse a option group option. */
void ParseGroupOption(const TokenNode *tp, struct GroupType *group,
                      const char *option)
{
   int x;

   if(!option) {
      return;
   }

   /* Look up the option in the option map using binary search. */
   x = FindValue(OPTION_MAP, OPTION_MAP_COUNT, option);
   if(x >= 0) {
      AddGroupOption(group, (OptionType)x);
      return;
   }

   /* These options have arguments and so we handled them separately. */
   if(!strncmp(option, "layer:", 6)) {
      const WinLayerType layer = ParseLayer(tp, option + 6);
      AddGroupOptionUnsigned(group, OPTION_LAYER, layer);
   } else if(!strncmp(option, "desktop:", 8)) {
      const unsigned int desktop = (unsigned int)atoi(option + 8);
      AddGroupOptionUnsigned(group, OPTION_DESKTOP, desktop);
   } else if(!strncmp(option, "icon:", 5)) {
      AddGroupOptionString(group, OPTION_ICON, option + 5);
   } else if(!strncmp(option, "opacity:", 8)) {
      const unsigned int opacity = ParseOpacity(tp, option + 8);
      AddGroupOptionUnsigned(group, OPTION_OPACITY, opacity);
   } else {
      ParseError(tp, "invalid Group Option: %s", option);
   }

}
예제 #7
0
파일: ardb.cpp 프로젝트: kouhate/ardb
	void Ardb::Walk(WalkHandler* handler)
	{
		KeyObject start(Slice(), KV, 0);
		Iterator* iter = FindValue(start);
		uint32 cursor = 0;
		while (NULL != iter && iter->Valid())
		{
			Slice tmpkey = iter->Key();
			KeyObject* kk = decode_key(tmpkey, NULL);
			if (NULL == kk)
			{
				break;
			}
			ValueObject v;
			Buffer readbuf(const_cast<char*>(iter->Value().data()), 0, iter->Value().size());
			decode_value(readbuf, v, false);
			int ret = handler->OnKeyValue(kk, &v, cursor++);
			DELETE(kk);
			if (ret < 0)
			{
				break;
			}
			iter->Next();
		}
		DELETE(iter);
	}
예제 #8
0
파일: ardb.cpp 프로젝트: kouhate/ardb
	void Ardb::PrintDB(const DBID& db)
	{
		Slice empty;
		KeyObject start(empty, KV, db);
		Iterator* iter = FindValue(start);
		while (NULL != iter && iter->Valid())
		{
			Slice tmpkey = iter->Key();
			KeyObject* kk = decode_key(tmpkey, NULL);
			if (kk->db != db)
			{
				DELETE(kk);
				break;
			}
			ValueObject v;
			Buffer readbuf(const_cast<char*>(iter->Value().data()), 0, iter->Value().size());
			decode_value(readbuf, v, false);
			if (NULL != kk)
			{
				std::string str;
				DEBUG_LOG("[%d]Key=%s, Value=%s", kk->type, kk->key.data(), v.ToString(str).c_str());
			}
			DELETE(kk);
			iter->Next();
		}
		DELETE(iter);
	}
예제 #9
0
 NODE* Insert(unsigned int value)
 {
     NODE *p = root, *q = NULL;
     FindValue(value, p, q);
     if (p == nil) p = GetNode(value, q);
     Splay(p, nil);
     return p;
 }
예제 #10
0
 NODE* FindNextValue(unsigned int value)
 {
     NODE *p = root, *q = NULL;
     FindValue(value, p, q);
     Splay(p, nil);
     q = p->ch[1];
     while (q->ch[0] != nil) q = q->ch[0];
     return q;
 }
예제 #11
0
avtIVPField::Result
avtIVPFlashField::operator()( const double &t,
                              const avtVector &p,
                              const avtVector &v,
                              avtVector& retV ) const
{
    if (FindCell(t, p) != OK)
        return OUTSIDE_SPATIAL;

  avtVector B, E;
  if (FindValue(B_vtkDataArray, B) && FindValue(E_vtkDataArray, E))
  {
      retV = factor * (E + Cross(v, B) );
      return OK;
  }
  else
      return OUTSIDE_SPATIAL;
}
예제 #12
0
파일: parse.c 프로젝트: kuailexs/jwm
/** Parse popup style. */
void ParsePopupStyle(const TokenNode *tp)
{
   static const StringMappingType enable_mapping[] = {
      { "button", POPUP_BUTTON   },
      { "clock",  POPUP_CLOCK    },
      { "false",  POPUP_NONE     },
      { "pager",  POPUP_PAGER    },
      { "task",   POPUP_TASK     },
      { "true",   POPUP_ALL      }
   };
   const TokenNode *np;
   const char *str;
   char *tok;

   tok = FindAttribute(tp->attributes, "enabled");
   if(tok) {
      settings.popupMask = POPUP_NONE;
      tok = strtok(tok, ",");
      while(tok) {
         const int x = FindValue(enable_mapping,
                                 ARRAY_LENGTH(enable_mapping), tok);
         if(JLIKELY(x >= 0)) {
            settings.popupMask |= x;
         } else {
            ParseError(tp, "invalid value for 'enabled': \"%s\"", tok);
         }
         tok = strtok(NULL, ",");
      }
   }

   str = FindAttribute(tp->attributes, "delay");
   if(str) {
      settings.popupDelay = ParseUnsigned(tp, str);
   }

   for(np = tp->subnodeHead; np; np = np->next) {
      switch(np->type) {
      case TOK_FONT:
         SetFont(FONT_POPUP, np->value);
         break;
      case TOK_FOREGROUND:
         SetColor(COLOR_POPUP_FG, np->value);
         break;
      case TOK_BACKGROUND:
         SetColor(COLOR_POPUP_BG, np->value);
         break;
      case TOK_OUTLINE:
         SetColor(COLOR_POPUP_OUTLINE, np->value);
         break;
      default:
         InvalidTag(np, TOK_POPUPSTYLE);
         break;
      }
   }

}
예제 #13
0
파일: 9_4.cpp 프로젝트: Jungzhang/cPlusPlus
int main(int argc, char *argv[])
{
    std::vector<int> a = {1,2,3,4,5,6,7,8,9,10};
    std::vector<int> b = {0,9,234,432,56,12,532};

    if (FindValue(a, 7)) {
        std::cout << "找到" << std::endl;
    } else {
        std::cout << "未找到" << std::endl;
    }

    if (FindValue(b, 12345)) {
        std::cout << "找到" << std::endl;
    } else {
        std::cout << "未找到" << std::endl;
    }
    
    return EXIT_SUCCESS;
}
void
nsXBLContentSink::ConstructParameter(const PRUnichar **aAtts)
{
  if (!mMethod)
    return;

  const PRUnichar* name = nsnull;
  if (FindValue(aAtts, nsGkAtoms::name, &name)) {
    mMethod->AddParameter(nsDependentString(name));
  }
}
예제 #15
0
string CIniFile::GetValue( string const keyname, string const valuename, string const defValue) const
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return defValue;

  long valueID = FindValue( unsigned(keyID), valuename);
  if ( valueID == noID)
    return defValue;

  return keys[keyID].values[valueID];
}
예제 #16
0
void EditValue(HashTable* hashTable, char* key, char* value)
{
    if(hashTable != NULL && value != NULL)
    {
        Node* tmpNode = FindValue(hashTable, key);
        if(tmpNode != NULL)
        {
            tmpNode->value = (char*)realloc(tmpNode->value, strlen(value) + 1);
            strcpy(tmpNode->value, value);
        }
    }
}
void
nsXBLContentSink::ConstructResource(const PRUnichar **aAtts,
                                    nsIAtom* aResourceType)
{
  if (!mBinding)
    return;

  const PRUnichar* src = nsnull;
  if (FindValue(aAtts, nsGkAtoms::src, &src)) {
    mBinding->AddResource(aResourceType, nsDependentString(src));
  }
}
예제 #18
0
 void Delete(unsigned int value)
 {
     NODE *p = root, *q = NULL;
     FindValue(value, p, q);
     if (p != nil)
     {
         // printf("Enter Delete\n");
         Splay(p, nil);
         NODE *p1 = FindPrevValue(value); 
         NODE *p2 = FindNextValue(value); 
         Splay(p1, nil); Splay(p2, root);
         p2->ch[0] = nil;
     }
 }
void
nsXBLContentSink::ConstructMethod(const PRUnichar **aAtts)
{
  mMethod = nsnull;

  const PRUnichar* name = nsnull;
  if (FindValue(aAtts, nsGkAtoms::name, &name)) {
    mMethod = new nsXBLProtoImplMethod(name);
  }

  if (mMethod) {
    AddMember(mMethod);
  }
}
예제 #20
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse a key binding. */
void ParseKey(const TokenNode *tp) {

   const char *key;
   const char *code;
   const char *mask;
   const char *action;
   const char *command;
   KeyType k;

   Assert(tp);

   mask = FindAttribute(tp->attributes, "mask");
   key = FindAttribute(tp->attributes, "key");
   code = FindAttribute(tp->attributes, "keycode");

   action = tp->value;
   if(JUNLIKELY(action == NULL)) {
      ParseError(tp, "no action specified for Key");
      return;
   }

   command = NULL;
   k = KEY_NONE;
   if(!strncmp(action, "exec:", 5)) {
      k = KEY_EXEC;
      command = action + 5;
   } else if(!strncmp(action, "root:", 5)) {
      k = KEY_ROOT;
      command = action + 5;
   } else {
      /* Look up the option in the key map using binary search. */
      const int x = FindValue(KEY_MAP, KEY_MAP_COUNT, action);
      if(x >= 0) {
         k = (KeyType)x;
      }
   }

   /* Insert the binding if it's valid. */
   if(JUNLIKELY(k == KEY_NONE)) {

      ParseError(tp, "invalid Key action: \"%s\"", action);

   } else {

      InsertBinding(k, mask, key, code, command);

   }

}
예제 #21
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse layer. */
WinLayerType ParseLayer(const TokenNode *tp, const char *str)
{
   static const StringMappingType mapping[] = {
      { "above",  LAYER_ABOVE    },
      { "below",  LAYER_BELOW    },
      { "normal", LAYER_NORMAL   }
   };
   const int x = FindValue(mapping, ARRAY_LENGTH(mapping), str);
   if(JLIKELY(x >= 0)) {
      return x;
   }  else {
      ParseError(tp, "invalid layer: %s", str);
      return LAYER_NORMAL;
   }
}
예제 #22
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse a string using a string mapping. */
int ParseAttribute(const StringMappingType *mapping, int count,
                   const TokenNode *tp, const char *attr, int def)
{
   const char *str = FindAttribute(tp->attributes, attr);
   if(str == NULL) {
      return def;
   } else {
      const int x = FindValue(mapping, count, str);
      if(JLIKELY(x >= 0)) {
         return x;
      } else {
         ParseError(tp, "invalid value for %s: \"%s\"", attr, str);
         return def;
      }
   }
}
예제 #23
0
파일: parse.c 프로젝트: Nehamkin/jwm
/** Parse a token value using a string mapping. */
int ParseTokenValue(const StringMappingType *mapping, int count,
                    const TokenNode *tp, int def)
{
   if(JUNLIKELY(tp->value == NULL)) {
      ParseError(tp, "%s is empty", GetTokenName(tp));
      return def;
   } else {
      const int x = FindValue(mapping, count, tp->value);
      if(JLIKELY(x >= 0)) {
         return x;
      } else {
         ParseError(tp, "invalid %s: \"%s\"", GetTokenName(tp), tp->value);
         return def;
      }
   }
}
예제 #24
0
// Check if a string(aToken) is present in another string(aLine). If present, then find the last position 
//where aDelimiter is present in aLine. Store the string after aDelimiter in aValue.
//@return	bool	return true if a value is retrieved after aToken match and aDelimiter match
//@param	aLine		modified string that contains the part of the string after aToken
//@param	aToken		string that needs to be searched for
//@param	aDelimiter	generally a single character string like ",", ".", etc.
//@param	aValue		string containing the value, i.e., the part of the string after aDelimiter.
bool TestTzUtil::FindValue(string& aLine, const string& aToken, string& aDelimiter, string& aValue)
	{
	bool rc = false;
	string::size_type loc;
	
	loc = aLine.find(aToken.c_str());
	if (loc != string::npos)
		{
		int tokenLength = aToken.length();

		aLine = aLine.substr(loc+tokenLength);

		rc = FindValue(aLine, aDelimiter, aValue);
		}
		return rc;
	}
예제 #25
0
파일: ardb.cpp 프로젝트: ericcapricorn/ardb
	void Ardb::Walk(KeyObject& key, bool reverse, WalkHandler* handler)
	{
		bool isFirstElement = true;
		Iterator* iter = FindValue(key);
		if (NULL != iter && !iter->Valid() && reverse)
		{
			iter->SeekToLast();
			isFirstElement = false;
		}
		uint32 cursor = 0;
		while (NULL != iter && iter->Valid())
		{
			Slice tmpkey = iter->Key();
			KeyObject* kk = decode_key(tmpkey, &key);
			if (NULL == kk || kk->type != key.type
			        || kk->key.compare(key.key) != 0)
			{
				DELETE(kk);
				if (reverse && isFirstElement)
				{
					iter->Prev();
					isFirstElement = false;
					continue;
				}
				break;
			}
			ValueObject v;
			Buffer readbuf(const_cast<char*>(iter->Value().data()), 0,
			        iter->Value().size());
			decode_value(readbuf, v, false);
			int ret = handler->OnKeyValue(kk, &v, cursor++);
			DELETE(kk);
			if (ret < 0)
			{
				break;
			}
			if (reverse)
			{
				iter->Prev();
			}
			else
			{
				iter->Next();
			}
		}
		DELETE(iter);
	}
avtVector
avtIVPVTKOffsetField::operator()( const double &t, const avtVector &p ) const
{
    avtVector zeros(0, 0, 0);
    std::vector<avtVector> velocities(3);
    for ( size_t j = 0; j < 3; ++j )
    {

        if (FindCell(t, p) != OK)
        {
            // ghost cells on the base mesh may be required to avoid this failure
            debug5 <<"avtIVPVTKOffsetField::operator() - UNABLE TO FIND CELL!" 
                   <<std::endl;
            return zeros;
        }

        avtVector displ = GetPositionCorrection( j );
        avtVector pCorrected = p - displ;


        avtVector displ2 = displ;
        if (FindCell(t, pCorrected) != OK)
        {
            // the displacement seen from the base target position may be 
            // a little different.
            displ2 = GetPositionCorrection( j );
        }

        pCorrected = p - 0.5*(displ2 + displ);
        if (FindCell(t, pCorrected) != OK)
        {
            debug5 <<"avtIVPVTKOffsetField::operator() - UNABLE TO FIND CORRECTED CELL!" 
                   <<std::endl;
            return zeros;
        }        

        // velocity for this staggering
        FindValue(velData, velocities[j]);
    }

    // compose the velocity, assuming each component is purely 
    // aligned to each axis. How should this be generalized when
    // the velocites are not alog axes? 
    avtVector vel( velocities[0].x, velocities[1].y, velocities[2].z );
    return vel;
}
예제 #27
0
파일: lex.c 프로젝트: KarlGodt/jwm
/** Get the token for a tag name. */
TokenType LookupType(const char *name, TokenNode *np)
{
   const int x = FindValue(TOKEN_MAP, TOKEN_MAP_COUNT, name);
   if(x >= 0) {
      if(np) {
         np->type = x;
      }
      return x;
   }

   if(JUNLIKELY(np)) {
      np->type = TOK_INVALID;
      np->invalidName = CopyString(name);
   }

   return TOK_INVALID;

}
예제 #28
0
bool CIniFile::DeleteValue( string const keyname, string const valuename)
{
  long keyID = FindKey( keyname);
  if ( keyID == noID)
    return false;

  long valueID = FindValue( unsigned(keyID), valuename);
  if ( valueID == noID)
    return false;

  // This looks strange, but is neccessary.
  vector<string>::iterator npos = keys[keyID].names.begin() + valueID;
  vector<string>::iterator vpos = keys[keyID].values.begin() + valueID;
  keys[keyID].names.erase( npos, npos + 1);
  keys[keyID].values.erase( vpos, vpos + 1);

  return true;
}
예제 #29
0
/* Matches python dict.get(key, [default]) */
PyObject *CListValue::Pyget(PyObject *args)
{
	char *key;
	PyObject *def = Py_None;

	if (!PyArg_ParseTuple(args, "s|O:get", &key, &def))
		return NULL;

	CValue *item = FindValue((const char *)key);
	if (item) {
		PyObject *pyobj = item->ConvertValueToPython();
		if (pyobj)
			return pyobj;
		else
			return item->GetProxy();
	}
	Py_INCREF(def);
	return def;
}
예제 #30
0
파일: tray.c 프로젝트: Nehamkin/jwm
/** Set the vertical tray alignment. */
void SetTrayVerticalAlignment(TrayType *tp, const char *str)
{
   static const StringMappingType mapping[] = {
      { "bottom",    TALIGN_BOTTOM  },
      { "center",    TALIGN_CENTER  },
      { "fixed",     TALIGN_FIXED   },
      { "top",       TALIGN_TOP     }
   };

   if(!str) {
      tp->valign = TALIGN_FIXED;
   } else {
      const int x = FindValue(mapping, ARRAY_LENGTH(mapping), str);
      if(JLIKELY(x >= 0)) {
         tp->valign = x;
      } else {
         Warning(_("invalid tray vertical alignment: \"%s\""), str);
         tp->valign = TALIGN_FIXED;
      }
   }
}