Exemple #1
0
void GxxArray::print()
{
	_println("[");
	for (ArrayValue::iterator it = arrayValues.begin(); it != arrayValues.end(); it++)
	{
		GxxString* pString = (*it)->getString();
		if (pString)
		{
			pString->print();
		}
		if ((*it)->getDictionary())
		{
			(*it)->getDictionary()->print();
		}
		if ((*it)->getArray())
		{
			(*it)->getArray()->print();
		}
	}
	_println("]");
}
Exemple #2
0
void GxxDictionary::print()
{
	_println("{");
	for (GxxValueMap::Iterator it = keyValues->FirstValue(); !keyValues->IsLastValue(it); keyValues->NextValue(it))
	{
		GxxString* pString = it->second->getString();
		_print(it->first);
		_print(": ");
		if (pString)
		{
			pString->print();
		}
		if (it->second->getDictionary())
		{
			it->second->getDictionary()->print();
		}
		if (it->second->getArray())
		{
			it->second->getArray()->print();
		}
	}
	_println("}");
}
Exemple #3
0
void GxxDictionary::print()
{
	_println("{");
	for (GxxValueMap::Iterator it = keyValues->FirstValue(); !keyValues->IsLastValue(it); keyValues->NextValue(it))
	{
		GxxValueMap::Pair* p = *it;
		GxxString* pString = p->value->getString();
		_print(p->key.c_str());
		_print(": ");
		if (pString)
		{
			pString->print();
		}
		if (p->value->getDictionary())
		{
			p->value->getDictionary()->print();
		}
		if (p->value->getArray())
		{
			p->value->getArray()->print();
		}
	}
	_println("}");
}
void GSMSendSMSProcessor::_timerHandler()
{
  // timed out waiting for acknowledge from GSM module, failing
  _println(F("GSM ERROR: response timedout!"));
  _state = State::ERROR;
}
Exemple #5
0
void GxxDictionary::setValueForKeyPath(GxxValuePtr& pValue, const char* keyPath)
{
	std::string segment;
	const char* first = keyPath;
	const char* p = keyPath;
	GxxValue* pCurrentValue = 0;
	while(*p)
	{
		if (*p == '.'){
			if (p - first < 1){
				++p;
				continue;
			}

			bool bIsArray = false;
			const char* temp = p;
			if (*(temp - 1) == ']'){
				while(temp != first)
				{
					if (*temp == '['){
						bIsArray = true;
						break;
					}
					--temp;
				}
			}
			if (bIsArray){
				segment.clear();
				segment.append(first, temp - first);
				if (pCurrentValue == 0) {
					pCurrentValue = this->valueForKey(segment.c_str());
				}
				else {
					if (pCurrentValue->getDictionary() == 0){
						return ;
					}
					pCurrentValue = pCurrentValue->getDictionary()->valueForKey(segment.c_str());
				}

				if (pCurrentValue == 0){
					_println("valueForKeyPath error: key not exist!");
					return;
				}
				if (pCurrentValue->getArray() == 0){
					_println("valueForKeyPath error: key is invalid, it is not a array object");
					return;
				}


				std::string strTmp;
				strTmp.append(temp+1, p - temp - 2);
				int nIndex = atoi(strTmp.c_str());
				pCurrentValue = pCurrentValue->getArray()->valueAtIndex(nIndex);
				if (pCurrentValue == 0){
					_println("valueForKeyPath error: invalid index");
					return;
				}
			}
			else{
				segment.clear();
				segment.append(first, temp - first);
				if (pCurrentValue == 0) {
					pCurrentValue = this->valueForKey(segment.c_str());
				}
				else {
					if (pCurrentValue->getDictionary() == 0){
						return ;
					}
					pCurrentValue = pCurrentValue->getDictionary()->valueForKey(segment.c_str());
				}

				if (pCurrentValue == 0){
					_println("valueForKeyPath error: key not exist!");
					return ;
				}
			}
			if (pCurrentValue->getDictionary() == 0){
				_println("valueForKeyPath error: key is invalid, it is not a dictionary object");
				return ;
			}
			first = p + 1;
		}
		++p;
	}
	if (p - first < 1){
		return;
	}

	bool bIsArray = false;
	const char* temp = p;
	if (*(temp - 1) == ']'){
		while(temp != first)
		{
			if (*temp == '['){
				bIsArray = true;
				break;
			}
			--temp;
		}
	}
	if (bIsArray){
		segment.clear();
		segment.append(first, temp - first);
		if (pCurrentValue == 0) {
			pCurrentValue = this->valueForKey(segment.c_str());
		}
		else {
			if (pCurrentValue->getDictionary() == 0){
				return;
			}
			pCurrentValue = pCurrentValue->getDictionary()->valueForKey(segment.c_str());
		}

		if (pCurrentValue == 0){
			_println("valueForKeyPath error: key not exist!");
			return;
		}
		if (pCurrentValue->getArray() == 0){
			_println("valueForKeyPath error: key is invalid, it is not a array object");
			return;
		}
		std::string strTmp;
		strTmp.append(temp+1, p - temp - 2);
		int nIndex = atoi(strTmp.c_str());

		GxxArray* pArray = pCurrentValue->getArray();
		if (nIndex >= 0 && nIndex < pArray->count()){
			pArray->setValue(pValue, nIndex);
		}else{
			pArray->addValue(pValue);
		}
	}
	else{
		segment.clear();
		segment.append(first, temp - first);
		if (pCurrentValue == 0) {
			this->setValueForKey(pValue, segment.c_str());
		}
		else {
			if (pCurrentValue->getDictionary() == 0){
				return ;
			}
			pCurrentValue->getDictionary()->setValueForKey(pValue, segment.c_str());
		}
	}
}
Exemple #6
0
void GxxString::print()
{
	_println(_string.c_str());
}