Dev Center
Table of contents

C++ API Reference - CBarcodeReader Parameter and Runtime Settings Advanced Methods

Method Description
InitRuntimeSettingsWithFile Initialize runtime settings with the settings in a given JSON file.
InitRuntimeSettingsWithString Initialize runtime settings with the settings in a given JSON string.
AppendTplFileToRuntimeSettings Append a new template file to the current runtime settings.
AppendTplStringToRuntimeSettings Append a new template string to the current runtime settings.
GetParameterTemplateCount Get the count of the parameter templates.
GetParameterTemplateName Get the parameter template name by index.
OutputSettingsToFile Output runtime settings to a settings file (JSON file).
OutputSettingsToString Output runtime settings to a string.
OutputSettingsToStringPtr Output runtime settings to a string.
FreeSettingsString Free memory allocated for runtime settings string.

InitRuntimeSettingsWithFile

Initialize runtime settings with the settings in a given JSON file.

int CBarcodeReader::InitRuntimeSettingsWithFile (const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, int errorMsgBufferLen = 0)	

Parameters

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

Return value

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

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessage[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessage, 256);
delete reader;

InitRuntimeSettingsWithString

Initialize runtime settings with the settings in a given JSON string.

int CBarcodeReader::InitRuntimeSettingsWithString (const char* content, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, int errorMsgBufferLen = 0)	

Parameters

[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 and replace with the new template.
[in,out] errorMsgBufferOptional The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLenOptional The length of the allocated buffer.

Return value

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

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessage[256];
reader->InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_OVERWRITE, errorMessage, 256);
delete reader;

AppendTplFileToRuntimeSettings

Append a new template file to the current runtime settings.

int CBarcodeReader::AppendTplFileToRuntimeSettings (const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0)

Parameters

[in] pFilePath The path of the settings file.
[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] errorMsgBufferOptional The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLenOptional The length of the allocated buffer.

Return value

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

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessage[256];
reader->AppendTplFileToRuntimeSettings("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_IGNORE, errorMessage, 256);
delete reader;

AppendTplStringToRuntimeSettings

Append a new template string to the current runtime settings.

int CBarcodeReader::AppendTplStringToRuntimeSettings (const char* content, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0)	

Parameters

[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] errorMsgBufferOptional The buffer is allocated by caller and the recommended length is 256. The error message will be copied to the buffer.
[in] errorMsgBufferLenOptional The length of the allocated buffer.

Return value

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

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessage[256];
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessage, 256);
delete reader;

GetParameterTemplateCount

Gets the count of the parameter templates.

int CBarcodeReader::GetParameterTemplateCount ()	

Return value

Returns the count of parameter template.


Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
int currentTemplateCount = reader->GetParameterTemplateCount();
delete reader;

GetParameterTemplateName

Gets the parameter template name by index.

int CBarcodeReader::GetParameterTemplateName (const int index, char nameBuffer[], int nameBufferLen)	

Parameters

[in] index The index of the parameter template array.
[in,out] nameBuffer The buffer is allocated by caller and the recommended nameBufferLen 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 GetErrorString to get detailed error message.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
int currentTemplateCount = reader->GetParameterTemplateCount();
int templateIndex = 1;
// notice that the value of 'templateIndex' should less than currentTemplateCount.
char templateName[256];
reader->GetParameterTemplateName(templateIndex, templateName, 256);
delete reader;

OutputSettingsToFile

Output runtime settings to a settings file (JSON file).

int CBarcodeReader::OutputSettingsToFile (const char* pFilePath, const char* pSettingsName)	

Parameters

[in] pFilePath The output file path 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 GetErrorString to get detailed error message.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
reader->OutputSettingsToFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\CurrentRuntimeSettings.json", "currentRuntimeSettings");
delete reader;

OutputSettingsToString

Output runtime settings to a string.

int CBarcodeReader::OutputSettingsToString (char content[], const int contentLen, const char* pSettingsName)

Parameters

[in,out] content The output string which stores the contents of current settings.
[in] contentLen The length of the 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 GetErrorString to get detailed error message.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
char content[256];
reader->OutputSettingsToString(content, 256, "currentRuntimeSettings");
delete reader;

OutputSettingsToStringPtr

Output runtime settings to a string.

int CBarcodeReader::OutputSettingsToStringPtr (char** content, const char* pSettingsName)	

Parameters

[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 GetErrorString to get detailed error message.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
char* content = NULL;
reader->OutputSettingsToStringPtr(&content, "currentRuntimeSettings");
reader->FreeSettingsString(&content);
delete reader;

FreeSettingsString

Free memory allocated for runtime settings string.

void CBarcodeReader::FreeSettingsString (char** content	)	

Parameters

[in] content The runtime settings string.

Code Snippet

CBarcodeReader* reader = new CBarcodeReader();
reader->InitLicense("t0260NwAAAHV***************");
char errorMessageInit[256];
char errorMessageAppend[256];
reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256);
reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256);
char* content = NULL;
reader->OutputSettingsToStringPtr(&content, "currentRuntimeSettings");
reader->FreeSettingsString(&content);
delete reader;

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

version 7.6.0

  • Latest version
  • Version 10.x
    • Version 10.2.0
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.0
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
Change +