StatusCode QueryOperatorImpl::FetchCollections(QueryNodeImpl* target)
{
	return WINI_ERROR;
#if 0
	sprintf(m_qval[DATA_GRP_NAME]," = '%s'", m_binding->GetPath());

	StatusCode status = GetFirstChildCollection(target);

	if(status.isOk())
	{
		clearSqlResult(&m_result);
		sprintf(m_qval[DATA_GRP_NAME]," like '%s/%%'", m_binding->GetPath());
		status = GetChildCollections(target);
	}

	return status;
#endif
}
StatusCode QueryOperatorImpl::GetChildDatasets(QueryNodeImpl* target)
{
	return WINI_ERROR;
#if 0
	StatusCode status = srbGetDataDirInfo(m_conn, 0, m_qval, m_selval, &m_result, MAX_ROWS);

	if(!status.isOk())
		return status;

	filterDeleted(&m_result);

	char* szCollection = getFromResultStruct(&m_result,dcs_tname[DATA_GRP_NAME], dcs_aname[DATA_GRP_NAME]);
	char* szDataset = getFromResultStruct(&m_result,dcs_tname[DATA_NAME], dcs_aname[DATA_NAME]);

	char *szCPtr, *szDPtr;

	const char* path = m_binding->GetPath();
	int path_len = strlen(path);


	INode* parent = m_binding;
	INode *child, *dataset;

	for(int i = 0; i < m_result.row_count; i++)
	{
		szCPtr = szCollection;
		szDPtr = szDataset;

		szCPtr += i * MAX_DATA_SIZE;
		szDPtr += i * MAX_DATA_SIZE;

		szCPtr += path_len;
		//dataset?

		if(NULL == *szCPtr)
		{
			status = parent->GetChild(szDPtr, &dataset);
			if(!status.isOk())
				return WINI_ERROR;
			target->AddChild(dataset);
			continue;
		}

start:	status = ((CollectionNodeImpl*)parent)->GetChild(szCPtr, &child);

		CollectionOperatorImpl* collection_op = (CollectionOperatorImpl*)m_session->GetOperator(WINI_COLLECTION);

		switch(status.GetCode())
		{
		case WINI_OK:
			//dataset is in a child collection of the binding
			//child collection has been found
			//now locate the dataset
startd:		status = child->GetChild(szDPtr, &dataset);
			switch(status.GetCode())
			{
			case WINI_OK:
				target->AddChild(dataset);
				break;
			case WINI_ERROR_NOT_FILLED:
				collection_op->GetChildren((CollectionNodeImpl*)child);
				goto startd;
				break;
			default:
				return WINI_ERROR;
				break;
			}
			break;
		case WINI_ERROR_NOT_FILLED:
			//child is not opened yet
			//open the child and begin again
			collection_op->GetChildren((CollectionNodeImpl*)parent);
			goto start;
			break;
		default:
			return WINI_ERROR;
			break;
		}

	}

	//while(m_result.continuation_index >= 0)
	//{
		//add code for this later	
	//}

	return WINI_OK;
#endif
}
StatusCode QueryOperatorImpl::LoadCollectionQuery2(IMetadataNode* ptr, int& count)
{
	return WINI_ERROR;
#if 0
	if(NULL == ptr)
		return WINI_ERROR_INVALID_PARAMETER;

	MetadataNodeImpl* child;

	StatusCode status;

	switch(ptr->GetOperation())
	{
	case WINI_MD_AND:
		child = (MetadataNodeImpl*)ptr->GetChild(0);	//left hand child
		status = LoadCollectionQuery2(child, count);
		if(!status.isOk())
			return status;
		child = (MetadataNodeImpl*)ptr->GetChild(1);	//right hand child
		status = LoadCollectionQuery2(child, count);
		if(!status.isOk())
			return status;
		break;
	case WINI_MD_EQUAL:
	case WINI_MD_NOT_EQUAL:
	case WINI_MD_GREATER_THAN:
	case WINI_MD_LESS_THAN:
	case WINI_MD_GREATER_OR_EQUAL:
	case WINI_MD_LESS_OR_EQUAL:
	case WINI_MD_BETWEEN:
	case WINI_MD_NOT_BETWEEN:
	case WINI_MD_LIKE:
	case WINI_MD_NOT_LIKE:
	case WINI_MD_SOUNDS_LIKE:
	case WINI_MD_SOUNDS_NOT_LIKE:
		switch(++count)
		{
		case 1:
			sprintf(m_qval[UDSMD_COLL0]," = '%s'", ptr->GetAttribute());
			sprintf(m_qval[UDSMD_COLL1]," %s '%s'", ptr->GetOperationString(), ptr->GetValue());
			break;
		case 2:
			sprintf(m_qval[UDSMD_COLL0_1]," = '%s'", ptr->GetAttribute());
			sprintf(m_qval[UDSMD_COLL1_1]," %s '%s'", ptr->GetOperationString(), ptr->GetValue());
			break;
		case 3:
			sprintf(m_qval[UDSMD_COLL0_2]," = '%s'", ptr->GetAttribute());
			sprintf(m_qval[UDSMD_COLL1_2]," %s '%s'", ptr->GetOperationString(), ptr->GetValue());
			break;
		case 4:
			sprintf(m_qval[UDSMD_COLL0_3]," = '%s'", ptr->GetAttribute());
			sprintf(m_qval[UDSMD_COLL1_3]," %s '%s'", ptr->GetOperationString(), ptr->GetValue());
			break;
		case 5:
			sprintf(m_qval[UDSMD_COLL0_4]," = '%s'", ptr->GetAttribute());
			sprintf(m_qval[UDSMD_COLL1_4]," %s '%s'", ptr->GetOperationString(), ptr->GetValue());
			//could also put a ptr->GetValue(); here to reset a static int
			break;
		default:
			break;
		}
		return WINI_OK;
	default:
		return WINI_ERROR_INVALID_PARAMETER;
	}

	return status;
#endif
}
StatusCode CollectionNodeImpl::GetChild(const char* name, INode** result)
{
	if((NULL == name)||(NULL == result))
		return WINI_ERROR_INVALID_PARAMETER;

	INode* child;
	char *szname;
	int j;

	StatusCode status;

	if('/' == name[0])
	{
		szname = strdup(name);

		int len = strlen(name);

		for(j = 1; j < len; j++)
		{
			if('/' == szname[j])
			{
				szname[j] = 0;
				break;
			}
		}

		status = GetChild(&szname[1], &child);

		szname[j] = '/';

		if(!status.isOk())
		{
			free(szname);
			*result = child;
			return status;
		}

		if(j < len)
		{
			status = child->GetChild(&szname[j], &child);
		}

		free(szname);
		*result = child;
		return status;

	}

	if(m_children)
	{
		for(int i = 0; i < m_children->size(); i++)
		{
			child = m_children->at(i);
			if(0 == strcmp(name, child->GetName()))
			{
				*result = child;
				return WINI_OK;
			}
		}
	}else
	{
		*result = this;
		return WINI_ERROR_NOT_FILLED;
	}

	*result = NULL;
	return WINI_ERROR_CHILD_NOT_FOUND;

}
//if string begins with '/' it will be taken as a relative path
//else it will take ptr as the name of a child
//trailing / may be present or omitted
INode* CollectionNodeImpl::GetChild(const char* name)
{
	if(NULL == name)
		return NULL;

	INode* child;
	char *szname;

	StatusCode status;
	int j;

	if('/' == name[0])
	{
		szname = strdup(name);

		int len = strlen(name);
		

		for(j = 1; j < len; j++)
		{
			if('/' == szname[j])
			{
				szname[j] = 0;
				break;
			}
		}

		child = GetChild(&szname[1]);

		szname[j] = '/';

		if(!status.isOk())
		{
			free(szname);
			return child;
		}

		if(j < len)
		{
			child = child->GetChild(&szname[j]);
		}

		free(szname);
		return child;

	}

	char* myptr;// = (char*)child->GetName();
	if(m_children)
	{
		for(int i = 0; i < m_children->size(); i++)
		{
			child = m_children->at(i);
			myptr = (char*)child->GetName();
			if(0 == strcmp(name, myptr))
			{
				return child;
			}
		}
	}

	return NULL;
}
Beispiel #6
0
StatusCode UserNodeImpl::GetChild(const char* name, INode** result)
{
	if(NULL == name)
		return NULL;

	if(NULL == result)
		return NULL;

	INode* child;
	char *szname;
	int j;

	StatusCode status;

	if('/' == name[0])
	{
		szname = strdup(name);

		int len = strlen(name);

		for(j = 1; j < len; j++)
		{
			if('/' == szname[j])
			{
				szname[j] = 0;
				break;
			}
		}

		status = GetChild(&szname[1], &child);

		if(!status.isOk())
		{
			free(szname);
			*result = child;
			return status;
		}

		if(j < len)
		{
			status = child->GetChild(&szname[j+1], &child);
		}

		free(szname);
		*result = child;
		return status;

	}else
	{
		if(m_children)
		{
			for(int i = 0; i < m_children->size(); i++)
			{
				child = m_children->at(i);
				if(0 == strcmp(name, child->GetName()))
				{
					*result = child;
					return WINI_OK;
				}
			}
		}else
		{
			*result = this;
			return WINI_ERROR_NOT_FILLED;
		}
	}

	//should never reach here
	*result = NULL;
	return WINI_ERROR;
}