Example #1
0
void StatementListVisitor::Visit(StatementList* list)
{
	if (list == NULL) return;

	const int32 n = list->Size();
	for (int32 i = 0; i < n; i ++) {
		Statement* statement = list->StatementAt(i);
		GroupStatement group(statement);
		if (group.IsOpenGroup()) {
			BeginGroup(&group);
			fLevel ++;
		} else if (statement->IsValueStatement()) {
			DoValue(statement);
		} else if (statement->IsDefaultStatement()) {
			DoDefault(statement);
		} else if (statement->IsQueryStatement()) {
			DoQuery(statement);
		} else if (statement->IsParamStatement()) {
			DoParam(statement);
		}		
		
		StatementList* children = statement->GetChildren();
		if (children != NULL) {
			Visit(children);
		}
		
		// Close statements have been removed
		if (group.IsOpenGroup()) {
			fLevel --;
			EndGroup(&group);
		}
	}
}
Example #2
0
DAPI_(HRESULT) JsonWriteString(
    __in JSON_WRITER* pWriter,
    __in_z LPCWSTR wzValue
    )
{
    HRESULT hr = S_OK;
    LPWSTR sczJsonString = NULL;

    hr = SerializeJsonString(&sczJsonString, wzValue);
    ExitOnFailure(hr, "Failed to allocate string JSON.");

    hr = DoValue(pWriter, sczJsonString);
    ExitOnFailure(hr, "Failed to add string to JSON.");

LExit:
    ReleaseStr(sczJsonString);
    return hr;
}
Example #3
0
DAPI_(HRESULT) JsonWriteNumber(
    __in JSON_WRITER* pWriter,
    __in DWORD dwValue
    )
{
    HRESULT hr = S_OK;
    LPWSTR sczValue = NULL;

    hr = StrAllocFormatted(&sczValue, L"%u", dwValue);
    ExitOnFailure(hr, "Failed to convert number to string.");

    hr = DoValue(pWriter, sczValue);
    ExitOnFailure(hr, "Failed to add number to JSON.");

LExit:
    ReleaseStr(sczValue);
    return hr;
}
Example #4
0
DAPI_(HRESULT) JsonWriteBool(
    __in JSON_WRITER* pWriter,
    __in BOOL fValue
    )
{
    HRESULT hr = S_OK;
    LPWSTR sczValue = NULL;

    hr = StrAllocString(&sczValue, fValue ? L"true" : L"false", 0);
    ExitOnFailure(hr, "Failed to convert boolean to string.");

    hr = DoValue(pWriter, sczValue);
    ExitOnFailure(hr, "Failed to add boolean to JSON.");

LExit:
    ReleaseStr(sczValue);
    return hr;
}