本文整理汇总了C++中StringToDouble函数的典型用法代码示例。如果您正苦于以下问题:C++ StringToDouble函数的具体用法?C++ StringToDouble怎么用?C++ StringToDouble使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringToDouble函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitString
void PipeDevice::ParseCommand(const std::string& command)
{
std::vector<std::string> tokens;
SplitString(command, ' ', tokens);
if (tokens.size() < 2 || tokens.size() > 4)
return;
if (tokens[0] == "PRESS" || tokens[0] == "RELEASE")
{
auto search = m_buttons.find(tokens[1]);
if (search != m_buttons.end())
search->second->SetState(tokens[0] == "PRESS" ? 1.0 : 0.0);
}
else if (tokens[0] == "SET")
{
if (tokens.size() == 3)
{
double value = StringToDouble(tokens[2]);
SetAxis(tokens[1], (value / 2.0) + 0.5);
}
else if (tokens.size() == 4)
{
double x = StringToDouble(tokens[2]);
double y = StringToDouble(tokens[3]);
SetAxis(tokens[1] + " X", x);
SetAxis(tokens[1] + " Y", y);
}
}
}
示例2: DoubleCoerce
void DoubleCoerce (FProduction *&prod1, FProduction *&prod2)
{
if (prod1->Type == PROD_String)
{
prod1 = StringToDouble (prod1);
}
if (prod2->Type == PROD_String)
{
prod2 = StringToDouble (prod2);
}
}
示例3: Autotune
void ChoiceForm::AutotuneButton_Clicked(GraphicsUI::UI_Base *)
{
if (currentShaderName.Length())
{
Autotune((float)StringToDouble(timeBudgetTextBox->GetText()));
}
}
示例4: GetQuantumInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% G e t Q u a n t u m I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetQuantumInfo() initializes the QuantumInfo structure to default values.
%
% The format of the GetQuantumInfo method is:
%
% GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o quantum_info: the quantum info.
%
*/
MagickExport void GetQuantumInfo(const ImageInfo *image_info,
QuantumInfo *quantum_info)
{
const char
*option;
assert(quantum_info != (QuantumInfo *) NULL);
(void) ResetMagickMemory(quantum_info,0,sizeof(*quantum_info));
quantum_info->quantum=8;
quantum_info->maximum=1.0;
quantum_info->scale=QuantumRange;
quantum_info->pack=MagickTrue;
quantum_info->semaphore=AllocateSemaphoreInfo();
quantum_info->signature=MagickSignature;
if (image_info == (const ImageInfo *) NULL)
return;
option=GetImageOption(image_info,"quantum:format");
if (option != (char *) NULL)
quantum_info->format=(QuantumFormatType) ParseCommandOption(
MagickQuantumFormatOptions,MagickFalse,option);
option=GetImageOption(image_info,"quantum:minimum");
if (option != (char *) NULL)
quantum_info->minimum=StringToDouble(option,(char **) NULL);
option=GetImageOption(image_info,"quantum:maximum");
if (option != (char *) NULL)
quantum_info->maximum=StringToDouble(option,(char **) NULL);
if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0))
quantum_info->scale=0.0;
else
if (quantum_info->minimum == quantum_info->maximum)
{
quantum_info->scale=(MagickRealType) QuantumRange/quantum_info->minimum;
quantum_info->minimum=0.0;
}
else
quantum_info->scale=(MagickRealType) QuantumRange/(quantum_info->maximum-
quantum_info->minimum);
option=GetImageOption(image_info,"quantum:scale");
if (option != (char *) NULL)
quantum_info->scale=StringToDouble(option,(char **) NULL);
option=GetImageOption(image_info,"quantum:polarity");
if (option != (char *) NULL)
quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ?
MagickTrue : MagickFalse;
quantum_info->endian=image_info->endian;
ResetQuantumState(quantum_info);
}
示例5: StringToDouble
double Utils::GetDoubleFromJsonValue(Json::Value &value, double defaultValue) {
double res = defaultValue;
/* some json responses have doubles formated as strings,
or an expected double is formated as an int */
if (value.isString())
res = StringToDouble(value.asString());
else if (value.isInt() || value.isDouble())
res = value.asDouble();
return res;
}
示例6: num_string
Value* JSONReader::DecodeNumber(const Token& token)
{
const std::wstring num_string(token.begin, token.length);
int num_int;
if(StringToInt(WideToUTF8(num_string), &num_int))
{
return Value::CreateIntegerValue(num_int);
}
double num_double;
if(StringToDouble(WideToUTF8(num_string), &num_double) &&
base::IsFinite(num_double))
{
return Value::CreateDoubleValue(num_double);
}
return NULL;
}
示例7: IsSceneGeometry
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ I s S c e n e G e o m e t r y %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% IsSceneGeometry() returns MagickTrue if the geometry is a valid scene
% specification (e.g. [1], [1-9], [1,7,4]).
%
% The format of the IsSceneGeometry method is:
%
% MagickBooleanType IsSceneGeometry(const char *geometry,
% const MagickBooleanType pedantic)
%
% A description of each parameter follows:
%
% o geometry: This string is the geometry specification.
%
% o pedantic: A value other than 0 invokes a more restrictive set of
% conditions for a valid specification (e.g. [1], [1-4], [4-1]).
%
*/
MagickExport MagickBooleanType IsSceneGeometry(const char *geometry,
const MagickBooleanType pedantic)
{
char
*p;
double
value;
if (geometry == (const char *) NULL)
return(MagickFalse);
p=(char *) geometry;
value=StringToDouble(geometry,&p);
(void) value;
if (p == geometry)
return(MagickFalse);
if (strspn(geometry,"0123456789-, ") != strlen(geometry))
return(MagickFalse);
if ((pedantic != MagickFalse) && (strchr(geometry,',') != (char *) NULL))
return(MagickFalse);
return(MagickTrue);
}
示例8: ParseAffineGeometry
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% P a r s e A f f i n e G e o m e t r y %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ParseAffineGeometry() returns an affine matrix as defined by the geometry
% string.
%
% The format of the ParseAffineGeometry method is:
%
% MagickStatusType ParseAffineGeometry(const char *geometry,
% AffineMatrix *affine_matrix,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o geometry: The geometry (e.g. 1.0,0.0,0.0,1.0,3.2,1.2).
%
% o affine_matrix: the affine matrix as defined by the geometry string.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport MagickStatusType ParseAffineGeometry(const char *geometry,
AffineMatrix *affine_matrix,ExceptionInfo *exception)
{
char
token[MaxTextExtent];
const char
*p;
double
determinant;
MagickStatusType
flags;
register ssize_t
i;
GetAffineMatrix(affine_matrix);
flags=NoValue;
p=(char *) geometry;
for (i=0; (*p != '\0') && (i < 6); i++)
{
GetMagickToken(p,&p,token);
if (*token == ',')
GetMagickToken(p,&p,token);
switch (i)
{
case 0: affine_matrix->sx=StringToDouble(token); break;
case 1: affine_matrix->rx=StringToDouble(token); break;
case 2: affine_matrix->ry=StringToDouble(token); break;
case 3: affine_matrix->sy=StringToDouble(token); break;
case 4: affine_matrix->tx=StringToDouble(token); flags|=XValue; break;
case 5: affine_matrix->ty=StringToDouble(token); flags|=YValue; break;
}
}
determinant=(affine_matrix->sx*affine_matrix->sy-affine_matrix->rx*
affine_matrix->ry);
if (fabs(determinant) < MagickEpsilon)
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"InvalidGeometry","`%s'",geometry);
return(flags);
}
示例9: assert
//.........这里部分代码省略.........
status=GetMatrixElement(equivalences,ox,0,&object);
while (object != root)
{
status=GetMatrixElement(equivalences,ox,0,&object);
status=SetMatrixElement(equivalences,ox,0,&root);
}
oy=offset+neighbor_offset;
status=GetMatrixElement(equivalences,oy,0,&object);
while (object != root)
{
status=GetMatrixElement(equivalences,oy,0,&object);
status=SetMatrixElement(equivalences,oy,0,&root);
}
status=SetMatrixElement(equivalences,y*image->columns+x,0,&root);
p++;
}
}
}
image_view=DestroyCacheView(image_view);
/*
Label connected components.
*/
n=0;
component_view=AcquireAuthenticCacheView(component_image,exception);
for (y=0; y < (ssize_t) component_image->rows; y++)
{
register PixelPacket
*restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
q=QueueCacheViewAuthenticPixels(component_view,0,y,component_image->columns,
1,exception);
if (q == (PixelPacket *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) component_image->columns; x++)
{
ssize_t
id,
offset;
offset=y*image->columns+x;
status=GetMatrixElement(equivalences,offset,0,&id);
if (id == offset)
{
id=n++;
status=SetMatrixElement(equivalences,offset,0,&id);
}
else
{
status=GetMatrixElement(equivalences,id,0,&id);
status=SetMatrixElement(equivalences,offset,0,&id);
}
q->red=(Quantum) (id > (ssize_t) QuantumRange ? (ssize_t) QuantumRange :
id);
q->green=q->red;
q->blue=q->red;
q++;
}
if (SyncCacheViewAuthenticPixels(component_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
proceed=SetImageProgress(image,ConnectedComponentsImageTag,progress++,
image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
component_view=DestroyCacheView(component_view);
equivalences=DestroyMatrixInfo(equivalences);
if (n > (ssize_t) QuantumRange)
{
component_image=DestroyImage(component_image);
ThrowImageException(ResourceLimitError,"TooManyObjects");
}
artifact=GetImageArtifact(image,"connected-components:area-threshold");
area_threshold=0.0;
if (artifact != (const char *) NULL)
area_threshold=StringToDouble(artifact,(char **) NULL);
if (area_threshold > 0.0)
status=MergeConnectedComponents(component_image,(size_t) n,area_threshold,
exception);
artifact=GetImageArtifact(image,"connected-components:verbose");
if (IsMagickTrue(artifact) != MagickFalse)
status=StatisticsComponentsStatistics(image,component_image,(size_t) n,
exception);
if (status == MagickFalse)
component_image=DestroyImage(component_image);
return(component_image);
}
示例10: StreamImageCommand
//.........这里部分代码省略.........
if (interpolate < 0)
ThrowStreamException(OptionError,"UnrecognizedInterpolateMethod",
argv[i]);
break;
}
ThrowStreamException(OptionError,"UnrecognizedOption",option)
}
case 'l':
{
if (LocaleCompare("limit",option+1) == 0)
{
char
*p;
double
value;
ssize_t
resource;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowStreamException(OptionError,"MissingArgument",option);
resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
argv[i]);
if (resource < 0)
ThrowStreamException(OptionError,"UnrecognizedResourceType",
argv[i]);
i++;
if (i == (ssize_t) argc)
ThrowStreamException(OptionError,"MissingArgument",option);
value=StringToDouble(argv[i],&p);
(void) value;
if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
ThrowStreamInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("list",option+1) == 0)
{
ssize_t
list;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowStreamException(OptionError,"MissingArgument",option);
list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
if (list < 0)
ThrowStreamException(OptionError,"UnrecognizedListType",argv[i]);
status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
argv+j,exception);
DestroyStream();
return(status != 0 ? MagickFalse : MagickTrue);
}
if (LocaleCompare("log",option+1) == 0)
{
if (*option == '+')
break;
i++;
if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
ThrowStreamException(OptionError,"MissingArgument",option);
break;
}
示例11: assert
//.........这里部分代码省略.........
proceed;
proceed=SetImageProgress(image,ConnectedComponentsImageTag,progress++,
image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
component_view=DestroyCacheView(component_view);
image_view=DestroyCacheView(image_view);
equivalences=DestroyMatrixInfo(equivalences);
if (n > (ssize_t) MaxColormapSize)
{
object=(CCObjectInfo *) RelinquishMagickMemory(object);
component_image=DestroyImage(component_image);
ThrowImageException(ResourceLimitError,"TooManyObjects");
}
component_image->colors=(size_t) n;
for (i=0; i < (ssize_t) component_image->colors; i++)
{
object[i].bounding_box.width-=(object[i].bounding_box.x-1);
object[i].bounding_box.height-=(object[i].bounding_box.y-1);
object[i].color.red=object[i].color.red/object[i].area;
object[i].color.green=object[i].color.green/object[i].area;
object[i].color.blue=object[i].color.blue/object[i].area;
object[i].color.alpha=object[i].color.alpha/object[i].area;
object[i].color.black=object[i].color.black/object[i].area;
object[i].centroid.x=object[i].centroid.x/object[i].area;
object[i].centroid.y=object[i].centroid.y/object[i].area;
}
artifact=GetImageArtifact(image,"connected-components:area-threshold");
area_threshold=0.0;
if (artifact != (const char *) NULL)
area_threshold=StringToDouble(artifact,(char **) NULL);
if (area_threshold > 0.0)
{
/*
Merge object below area threshold.
*/
component_view=AcquireAuthenticCacheView(component_image,exception);
for (i=0; i < (ssize_t) component_image->colors; i++)
{
double
census;
RectangleInfo
bounding_box;
register ssize_t
j;
size_t
id;
if (status == MagickFalse)
continue;
if ((double) object[i].area >= area_threshold)
continue;
for (j=0; j < (ssize_t) component_image->colors; j++)
object[j].census=0;
bounding_box=object[i].bounding_box;
for (y=0; y < (ssize_t) bounding_box.height+2; y++)
{
register const Quantum
*magick_restrict p;
示例12: test_string_to_double
static void test_string_to_double(void)
{
assert_true(1234.1234 == StringToDouble("1234.1234"));
}
示例13: ImportImageCommand
//.........这里部分代码省略.........
break;
i++;
if (i == (ssize_t) argc)
ThrowImportException(OptionError,"MissingArgument",option);
status=SetImageOption(image_info,"label",argv[i]);
if (status == MagickFalse)
ThrowImportException(OptionError,"UnrecognizedOption",argv[i]);
break;
}
if (LocaleCompare("limit",option+1) == 0)
{
char
*p;
double
value;
ssize_t
resource;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowImportException(OptionError,"MissingArgument",option);
resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
argv[i]);
if (resource < 0)
ThrowImportException(OptionError,"UnrecognizedResourceType",
argv[i]);
i++;
if (i == (ssize_t) argc)
ThrowImportException(OptionError,"MissingArgument",option);
value=StringToDouble(argv[i],&p);
(void) value;
if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
ThrowImportInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("list",option+1) == 0)
{
ssize_t
list;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowImportException(OptionError,"MissingArgument",option);
list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
if (list < 0)
ThrowImportException(OptionError,"UnrecognizedListType",argv[i]);
status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
argv+j,exception);
DestroyImport();
return(status != 0 ? MagickFalse : MagickTrue);
}
if (LocaleCompare("log",option+1) == 0)
{
if (*option == '+')
break;
i++;
if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
ThrowImportException(OptionError,"MissingArgument",option);
break;
}
示例14: CompareImageCommand
//.........这里部分代码省略.........
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("depth",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("dissimilarity-threshold",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
if (*option == '+')
dissimilarity_threshold=DefaultDissimilarityThreshold;
else
dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL);
break;
}
if (LocaleCompare("duration",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) (argc-1))
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'e':
{
if (LocaleCompare("encipher",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) (argc-1))
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("extract",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) (argc-1))
示例15: assert
//.........这里部分代码省略.........
if (isspace((int) ((unsigned char) keyword[i])) != 0)
break;
keyword[i]=tolower((int) ((unsigned char) keyword[i]));
}
keyword[i]='\0';
count=ReadBlob(image,72,(unsigned char *) value);
if (count != 72)
break;
value[72]='\0';
p=value;
if (*p == '=')
{
p+=2;
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
}
if (LocaleCompare(keyword,"end") == 0)
break;
if (LocaleCompare(keyword,"extend") == 0)
fits_info.extend=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
if (LocaleCompare(keyword,"simple") == 0)
fits_info.simple=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
if (LocaleCompare(keyword,"bitpix") == 0)
fits_info.bits_per_pixel=StringToLong(p);
if (LocaleCompare(keyword,"naxis") == 0)
fits_info.number_axes=StringToLong(p);
if (LocaleCompare(keyword,"naxis1") == 0)
fits_info.columns=StringToLong(p);
if (LocaleCompare(keyword,"naxis2") == 0)
fits_info.rows=StringToLong(p);
if (LocaleCompare(keyword,"naxis3") == 0)
fits_info.number_planes=StringToLong(p);
if (LocaleCompare(keyword,"datamax") == 0)
fits_info.max_data=StringToDouble(p);
if (LocaleCompare(keyword,"datamin") == 0)
fits_info.min_data=StringToDouble(p);
if (LocaleCompare(keyword,"bzero") == 0)
fits_info.zero=StringToDouble(p);
if (LocaleCompare(keyword,"bscale") == 0)
fits_info.scale=StringToDouble(p);
if (LocaleCompare(keyword,"comment") == 0)
{
if (comment == (char *) NULL)
comment=ConstantString(p);
else
(void) ConcatenateString(&comment,p);
}
if (LocaleCompare(keyword,"xendian") == 0)
{
if (LocaleNCompare(p,"big",3) == 0)
fits_info.endian=MSBEndian;
else
fits_info.endian=LSBEndian;
}
(void) FormatMagickString(property,MaxTextExtent,"fits:%s",keyword);
(void) SetImageProperty(image,property,p);
}
c=0;
while (((TellBlob(image) % FITSBlocksize) != 0) && (c != EOF))
c=ReadBlobByte(image);
if (fits_info.extend == MagickFalse)
break;
number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
if ((fits_info.simple != MagickFalse) && (fits_info.number_axes >= 1) &&
(fits_info.number_axes <= 4) && (number_pixels != 0))
break;