diff --git a/LightJSonBuilder.cpp b/LightJSonBuilder.cpp index 6401d87..5df878a 100644 --- a/LightJSonBuilder.cpp +++ b/LightJSonBuilder.cpp @@ -236,6 +236,19 @@ BOOL CLightJSonBuilder::AddObjectFormattedString(_In_z_ LPCSTR szNameA, _Printf_ return AddObjectString(szNameA, (LPCSTR)cStrTempA, cStrTempA.GetLength()); } +BOOL CLightJSonBuilder::AddObjectFormattedStringV(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCSTR szFormatA, _In_ va_list argptr) +{ + CStringA cStrTempA; + + MX_ASSERT(szFormatA != NULL); + + if (cStrTempA.FormatV(szFormatA, argptr) == FALSE) + return FALSE; + + //done + return AddObjectString(szNameA, (LPCSTR)cStrTempA, cStrTempA.GetLength()); +} + BOOL CLightJSonBuilder::AddObjectString(_In_z_ LPCSTR szNameA, _In_ LPCWSTR szValueW, _In_opt_ SIZE_T nValueLen) { MX_ASSERT(szNameA != NULL); @@ -286,6 +299,19 @@ BOOL CLightJSonBuilder::AddObjectFormattedString(_In_z_ LPCSTR szNameA, _Printf_ return AddObjectString(szNameA, (LPCWSTR)cStrTempW, cStrTempW.GetLength()); } +BOOL CLightJSonBuilder::AddObjectFormattedStringV(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCWSTR szFormatW, _In_ va_list argptr) +{ + CStringW cStrTempW; + + MX_ASSERT(szFormatW != NULL); + + if (cStrTempW.FormatV(szFormatW, argptr) == FALSE) + return FALSE; + + //done + return AddObjectString(szNameA, (LPCWSTR)cStrTempW, cStrTempW.GetLength()); +} + BOOL CLightJSonBuilder::AddObjectString(_In_z_ LPCSTR szNameA, _In_ PUNICODE_STRING Value) { MX_ASSERT(szNameA != NULL); @@ -540,6 +566,19 @@ BOOL CLightJSonBuilder::AddArrayFormattedString(_Printf_format_string_ LPCSTR sz return AddArrayString((LPCSTR)cStrTempA, cStrTempA.GetLength()); } +BOOL CLightJSonBuilder::AddArrayFormattedStringV(_Printf_format_string_ LPCSTR szFormatA, _In_ va_list argptr) +{ + CStringA cStrTempA; + + MX_ASSERT(szFormatA != NULL); + + if (cStrTempA.FormatV(szFormatA, argptr) == FALSE) + return FALSE; + + //done + return AddArrayString((LPCSTR)cStrTempA, cStrTempA.GetLength()); +} + BOOL CLightJSonBuilder::AddArrayString(_In_ LPCWSTR szValueW, _In_opt_ SIZE_T nValueLen) { MX_ASSERT(aNestedTypes.GetCount() > 0); @@ -584,6 +623,19 @@ BOOL CLightJSonBuilder::AddArrayFormattedString(_Printf_format_string_ LPCWSTR s return AddArrayString((LPCWSTR)cStrTempW, cStrTempW.GetLength()); } +BOOL CLightJSonBuilder::AddArrayFormattedStringV(_Printf_format_string_ LPCWSTR szFormatW, _In_ va_list argptr) +{ + CStringW cStrTempW; + + MX_ASSERT(szFormatW != NULL); + + if (cStrTempW.FormatV(szFormatW, argptr) == FALSE) + return FALSE; + + //done + return AddArrayString((LPCWSTR)cStrTempW, cStrTempW.GetLength()); +} + BOOL CLightJSonBuilder::AddArrayLong(_In_ LONG nValue) { CHAR szTempBufA[64]; diff --git a/LightJSonBuilder.h b/LightJSonBuilder.h index 9081086..7ee90ad 100644 --- a/LightJSonBuilder.h +++ b/LightJSonBuilder.h @@ -47,8 +47,10 @@ class CLightJSonBuilder : public CBaseMemObj, public CNonCopyableObj BOOL AddObjectBoolean(_In_z_ LPCSTR szNameA, _In_ BOOL bValue); BOOL AddObjectString(_In_z_ LPCSTR szNameA, _In_ LPCSTR szValueA, _In_opt_ SIZE_T nValueLen = (SIZE_T)-1); BOOL AddObjectFormattedString(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCSTR szFormatA, ...); + BOOL AddObjectFormattedStringV(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCSTR szFormatA, _In_ va_list argptr); BOOL AddObjectString(_In_z_ LPCSTR szNameA, _In_ LPCWSTR szValueW, _In_opt_ SIZE_T nValueLen = (SIZE_T)-1); BOOL AddObjectFormattedString(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCWSTR szFormatW, ...); + BOOL AddObjectFormattedStringV(_In_z_ LPCSTR szNameA, _Printf_format_string_ LPCWSTR szFormatW, _In_ va_list argptr); BOOL AddObjectString(_In_z_ LPCSTR szNameA, _In_ PUNICODE_STRING Value); BOOL AddObjectLong(_In_z_ LPCSTR szNameA, _In_ LONG nValue); BOOL AddObjectULong(_In_z_ LPCSTR szNameA, _In_ ULONG nValue, _In_opt_ BOOL bAsHexa = FALSE); @@ -61,8 +63,10 @@ class CLightJSonBuilder : public CBaseMemObj, public CNonCopyableObj BOOL AddArrayBoolean(_In_ BOOL bValue); BOOL AddArrayString(_In_ LPCSTR szValueA, _In_opt_ SIZE_T nValueLen = (SIZE_T)-1); BOOL AddArrayFormattedString(_Printf_format_string_ LPCSTR szFormatA, ...); + BOOL AddArrayFormattedStringV(_Printf_format_string_ LPCSTR szFormatA, _In_ va_list argptr); BOOL AddArrayString(_In_ LPCWSTR szValueW, _In_opt_ SIZE_T nValueLen = (SIZE_T)-1); BOOL AddArrayFormattedString(_Printf_format_string_ LPCWSTR szFormatW, ...); + BOOL AddArrayFormattedStringV(_Printf_format_string_ LPCWSTR szFormatW, _In_ va_list argptr); BOOL AddArrayLong(_In_ LONG nValue); BOOL AddArrayULong(_In_ ULONG nValue, _In_opt_ BOOL bAsHexa = FALSE); //IMPORTANT: ECMA-262 Sec 8.5 states max number is 9007199254740990 so, if larger, it is recommended to store it as string