Table of contents

Parameter and Runtime Settings Advanced Functions

Function Description
DBR_InitRuntimeSettingsWithFile Initialize runtime settings with the settings in a given JSON file.
DBR_InitRuntimeSettingsWithString Initialize runtime settings with the settings in a given JSON string.
DBR_AppendTplFileToRuntimeSettings Append a new template file to the current runtime settings.
DBR_AppendTplStringToRuntimeSettings Append a new template string to the current runtime settings.
DBR_GetParameterTemplateCount Get the count of the parameter templates.
DBR_GetParameterTemplateName Get the parameter template name by index.
DBR_OutputSettingsToFile Output runtime settings to a settings file (JSON file).
DBR_OutputSettingsToString Output runtime settings to a string.
DBR_OutputSettingsToStringPtr Output runtime settings to a string.
DBR_FreeSettingsString Free memory allocated for runtime settings string.

DBR_InitRuntimeSettingsWithFile

Initialize runtime settings with the parameters obtained from a JSON file.

DBR_API int DBR_InitRuntimeSettingsWithFile (void* barcodeReader, const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[], const int errorMsgBufferLen)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pFilePath The settings file path.
[in] conflictMode The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] errorMsgBuffer The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLen The length of allocated buffer.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_InitRuntimeSettingsWithString

Initialize runtime settings with the parameters obtained from a JSON string.

DBR_API int DBR_InitRuntimeSettingsWithString (void* barcodeReader, const char* content, const ConflictMode conflictMode, char errorMsgBuffer[], const int errorMsgBufferLen)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] content A JSON string that represents the content of the settings.
[in] conflictMode The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] errorMsgBuffer The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLen The length of allocated buffer.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithString(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_OVERWRITE, errorBuf, 512);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_AppendTplFileToRuntimeSettings

Append a new template file to the current runtime settings.

DBR_API int DBR_AppendTplFileToRuntimeSettings (void* barcodeReader, const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[], const int errorMsgBufferLen)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pFilePath The settings file path.
[in] conflictMode The parameter setting mode, which decides whether to inherit parameters from previous template settings or to overwrite previous settings with the new template.
[in,out] errorMsgBuffer The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLen The length of allocated buffer.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_AppendTplFileToRuntimeSettings(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_IGNORE, errorBuf, 512);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_AppendTplStringToRuntimeSettings

Append a new template string to the current runtime settings.

DBR_API int DBR_AppendTplStringToRuntimeSettings (void* barcodeReader, const char* content, const ConflictMode conflictMode, char errorMsgBuffer[], const int errorMsgBufferLen)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] content A JSON string that represents the content of the settings.
[in] conflictMode The parameter setting mode, which decides whether to inherit parameters from previous template setting or to overwrite previous settings with the new template.
[in,out] errorMsgBuffer The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLen The length of allocated buffer.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_GetParameterTemplateCount

Get count of parameter templates.

DBR_API int DBR_GetParameterTemplateCount (void* barcodeReader)

Parameters
[in] barcodeReader Handle of the barcode reader instance.

Return Value
Returns the count of parameter templates. Returns -1 if DBRERR_NULL_POINTER happens.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
int currentTemplateCount = DBR_GetParameterTemplateCount(barcodeReader);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_GetParameterTemplateName

Get parameter template name by index.

DBR_API int DBR_GetParameterTemplateName (void* barcodeReader, const int index, char nameBuffer[], const int nameBufferLen)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] index The index of parameter template array.
[in,out] nameBuffer The buffer is allocated by caller and the recommended length is 256. The template name will be copied to the buffer.
[in] nameBufferLen The length of allocated buffer.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
	int currentTemplateCount = DBR_GetParameterTemplateCount(barcodeReader);
	int templateIndex = 1;
	// notice that the value of 'templateIndex' should less than currentTemplateCount.
	char templateName[256];
	DBR_GetParameterTemplateName(barcodeReader, templateIndex, templateName, 256);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_OutputSettingsToFile

Outputs runtime settings and save them into a settings file (JSON file).

DBR_API int DBR_OutputSettingsToFile (void* barcodeReader, const char* pFilePath, const char* pSettingsName)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in] pFilePath The path of the output file which stores current settings.
[in] pSettingsName A unique name for declaring current runtime settings.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
	DBR_OutputSettingsToFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\CurrentRuntimeSettings.json", "currentRuntimeSettings");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_OutputSettingsToString

Output runtime settings to a string.

DBR_API int DBR_OutputSettingsToString (void* barcodeReader, char content[], const int contentLen, const char* pSettingsName)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in,out] content The output string which stores the contents of current settings.
[in] contentLen The length of output string.
[in] pSettingsName A unique name for declaring current runtime settings.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
	char pContent[256];
	DBR_OutputSettingsToString(barcodeReader, pContent, 256, "currentRuntimeSettings");
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_OutputSettingsToStringPtr

Output runtime settings to a string.

DBR_API int DBR_OutputSettingsToStringPtr (void* barcodeReader, char** content, const char* pSettingsName)

Parameters
[in] barcodeReader Handle of the barcode reader instance.
[in,out] content The output string which stores the contents of current settings.
[in] pSettingsName A unique name for declaring current runtime settings.

Return Value
Returns error code (returns 0 if the function operates successfully).
You can call DBR_GetErrorString to get detailed error message.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
	char* pContent = NULL;
	DBR_OutputSettingsToStringPtr(barcodeReader, &pContent, "currentRuntimeSettings");
	DBR_FreeSettingsString(&pContent);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

DBR_FreeSettingsString

Free memory allocated for runtime settings string.

DBR_API void DBR_FreeSettingsString (char** content)

Parameters
[in] content The runtime settings string.

Code Snippet

char errorBuf[512];
DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
void* barcodeReader = DBR_GetInstance();
if(barcodeReader != NULL)
{
	DBR_InitRuntimeSettingsWithFile(barcodeReader, "C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorBuf, 512);
	DBR_AppendTplStringToRuntimeSettings(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorBuf, 512);
	char* pContent = NULL;
	DBR_OutputSettingsToString(barcodeReader, &pContent, "currentRuntimeSettings");
	DBR_FreeSettingsString(&pContent);
    //... more process here
    DBR_RecycleInstance(barcodeReader);
}

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: