Exemplo n.º 1
0
StatusCode QueryOperatorImpl::LoadCollectionQuery(QueryNodeImpl* target)
{
#if 0
	ClearMCATScratch();
	m_selval[DATA_GRP_NAME] = 1;

	INode* ptr = target;
	IMetadataNode* ptr_meta;

	int count = 0;

	StatusCode status;

	while(WINI_QUERY == ptr->GetType())
	{
		ptr_meta = (IMetadataNode*)ptr->GetChild(0);

		status = LoadCollectionQuery2(ptr_meta, count);

		if(!status.isOk())
			break;

		ptr = ptr->GetParent();

		if(NULL == ptr)
			break;
	}

	return status;
#endif
	return WINI_ERROR;
}
Exemplo n.º 2
0
/*
this function takes a char string. if the string begins
with a / it will perceive it as a relative path otherwise it will
take take the entire path as a name. trailing / may be
present or omitted.
*/
INode* UserNodeImpl::GetChild(const char* name)
{
	if((NULL == name)||(NULL == m_children))
		return NULL;

	INode* child;
	char *szname;
	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);

		if(NULL == child)
		{
			free(szname);
			return NULL;
		}

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

		free(szname);

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

	//should never reach here
	return NULL;
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
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;

}
Exemplo n.º 5
0
//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;
}
Exemplo n.º 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;
}