本文整理汇总了C++中String函数的典型用法代码示例。如果您正苦于以下问题:C++ String函数的具体用法?C++ String怎么用?C++ String使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了String函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
String open (const BigInteger& inputChannels, const BigInteger& outputChannels,
double sampleRate, int bufferSizeSamples)
{
if (client == 0)
{
lastError = "No JACK client running";
return lastError;
}
lastError = String::empty;
close();
juce::jack_set_process_callback (client, processCallback, this);
juce::jack_on_shutdown (client, shutdownCallback, this);
juce::jack_activate (client);
isOpen_ = true;
if (! inputChannels.isZero())
{
const char** const ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput);
if (ports != 0)
{
const int numInputChannels = inputChannels.getHighestBit() + 1;
for (int i = 0; i < numInputChannels; ++i)
{
const String portName (ports[i]);
if (inputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName())
{
int error = juce::jack_connect (client, ports[i], juce::jack_port_name ((jack_port_t*) inputPorts[i]));
if (error != 0)
jack_Log ("Cannot connect input port " + String (i) + " (" + String (ports[i]) + "), error " + String (error));
}
}
free (ports);
}
}
if (! outputChannels.isZero())
{
const char** const ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput);
if (ports != 0)
{
const int numOutputChannels = outputChannels.getHighestBit() + 1;
for (int i = 0; i < numOutputChannels; ++i)
{
const String portName (ports[i]);
if (outputChannels[i] && portName.upToFirstOccurrenceOf (":", false, false) == getName())
{
int error = juce::jack_connect (client, juce::jack_port_name ((jack_port_t*) outputPorts[i]), ports[i]);
if (error != 0)
jack_Log ("Cannot connect output port " + String (i) + " (" + String (ports[i]) + "), error " + String (error));
}
}
free (ports);
}
}
return lastError;
}
示例2: _get_data_dir
static String _get_data_dir() {
JNIEnv *env = ThreadAndroid::get_env();
jstring s =(jstring)env->CallObjectMethod(godot_io,_getDataDir);
return String(env->GetStringUTFChars( s, NULL ));
}
示例3: UNUSED_PARAM
bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& repaintRect, SVGResourceFilter*& filter, SVGResourceFilter* rootFilter)
{
#if !ENABLE(FILTERS)
UNUSED_PARAM(filter);
UNUSED_PARAM(rootFilter);
#endif
ASSERT(object);
SVGElement* svgElement = static_cast<SVGElement*>(object->node());
ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
const RenderStyle* style = object->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
// Setup transparency layers before setting up filters!
float opacity = style->opacity();
if (opacity < 1.0f) {
paintInfo.context->clip(repaintRect);
paintInfo.context->beginTransparencyLayer(opacity);
}
if (ShadowData* shadow = svgStyle->shadow()) {
paintInfo.context->clip(repaintRect);
paintInfo.context->setShadow(IntSize(shadow->x, shadow->y), shadow->blur, shadow->color, style->colorSpace());
paintInfo.context->beginTransparencyLayer(1.0f);
}
#if ENABLE(FILTERS)
AtomicString filterId(svgStyle->filter());
#endif
AtomicString clipperId(svgStyle->clipPath());
AtomicString maskerId(svgStyle->maskElement());
Document* document = object->document();
#if ENABLE(FILTERS)
SVGResourceFilter* newFilter = getFilterById(document, filterId, object);
if (newFilter == rootFilter) {
// Catch <text filter="url(#foo)">Test<tspan filter="url(#foo)">123</tspan></text>.
// The filter is NOT meant to be applied twice in that case!
filter = 0;
filterId = String();
} else
filter = newFilter;
#endif
SVGResourceClipper* clipper = getClipperById(document, clipperId, object);
SVGResourceMasker* masker = getMaskerById(document, maskerId, object);
if (masker) {
masker->addClient(styledElement);
if (!masker->applyMask(paintInfo.context, object))
return false;
} else if (!maskerId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
if (clipper) {
clipper->addClient(styledElement);
clipper->applyClip(paintInfo.context, object->objectBoundingBox());
} else if (!clipperId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
#if ENABLE(FILTERS)
if (filter) {
filter->addClient(styledElement);
if (!filter->prepareFilter(paintInfo.context, object))
return false;
} else if (!filterId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
#endif
return true;
}
示例4: String
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {
return String();
}
示例5: _jobject_to_variant
Variant _jobject_to_variant(JNIEnv * env, jobject obj) {
jclass c = env->GetObjectClass(obj);
bool array;
String name = _get_class_name(env, c, &array);
//print_line("name is " + name + ", array "+Variant(array));
if (name == "java.lang.String") {
return String::utf8(env->GetStringUTFChars( (jstring)obj, NULL ));
};
if (name == "[Ljava.lang.String;") {
jobjectArray arr = (jobjectArray)obj;
int stringCount = env->GetArrayLength(arr);
//print_line("String array! " + String::num(stringCount));
DVector<String> sarr;
for (int i=0; i<stringCount; i++) {
jstring string = (jstring) env->GetObjectArrayElement(arr, i);
const char *rawString = env->GetStringUTFChars(string, 0);
sarr.push_back(String(rawString));
}
return sarr;
};
if (name == "java.lang.Boolean") {
jmethodID boolValue = env->GetMethodID(c, "booleanValue", "()Z");
bool ret = env->CallBooleanMethod(obj, boolValue);
return ret;
};
if (name == "java.lang.Integer") {
jclass nclass = env->FindClass("java/lang/Number");
jmethodID intValue = env->GetMethodID(nclass, "intValue", "()I");
int ret = env->CallIntMethod(obj, intValue);
return ret;
};
if (name == "[I") {
jintArray arr = (jintArray)obj;
int fCount = env->GetArrayLength(arr);
DVector<int> sarr;
sarr.resize(fCount);
DVector<int>::Write w = sarr.write();
env->GetIntArrayRegion(arr,0,fCount,w.ptr());
w = DVector<int>::Write();
return sarr;
};
if (name == "[B") {
jbyteArray arr = (jbyteArray)obj;
int fCount = env->GetArrayLength(arr);
DVector<uint8_t> sarr;
sarr.resize(fCount);
DVector<uint8_t>::Write w = sarr.write();
env->GetByteArrayRegion(arr,0,fCount,reinterpret_cast<signed char*>(w.ptr()));
w = DVector<uint8_t>::Write();
return sarr;
};
if (name == "java.lang.Float" || name == "java.lang.Double") {
jclass nclass = env->FindClass("java/lang/Number");
jmethodID doubleValue = env->GetMethodID(nclass, "doubleValue", "()D");
double ret = env->CallDoubleMethod(obj, doubleValue);
return ret;
};
if (name == "[D") {
jdoubleArray arr = (jdoubleArray)obj;
int fCount = env->GetArrayLength(arr);
RealArray sarr;
sarr.resize(fCount);
RealArray::Write w = sarr.write();
for (int i=0; i<fCount; i++) {
double n;
env->GetDoubleArrayRegion(arr, i, 1, &n);
w.ptr()[i] = n;
};
return sarr;
};
if (name == "[F") {
jfloatArray arr = (jfloatArray)obj;
//.........这里部分代码省略.........
示例6: String
void SubString::printOn(ostream& strm) const
// Print this SubString on output stream strm.
{
strm << String(*this);
}
示例7: clear_error
int
hstcpcli::response_recv(size_t& num_flds_r)
{
if (error_code < 0) {
return error_code;
}
clear_error();
if (num_req_bufd > 0 || num_req_sent == 0 || num_req_rcvd > 0 ||
response_end_offset != 0) {
close();
return set_error(-1, "response_recv: protocol out of sync");
}
cur_row_offset = 0;
num_flds_r = num_flds = 0;
if (fd.get() < 0) {
return set_error(-1, "read: closed");
}
size_t offset = 0;
while (true) {
const char *const lbegin = readbuf.begin() + offset;
const char *const lend = readbuf.end();
if (lbegin < lend)
{
const char *const nl = memchr_char(lbegin, '\n', lend - lbegin);
if (nl != 0) {
offset += (nl + 1) - lbegin;
break;
}
offset += lend - lbegin;
}
if (read_more() <= 0) {
close();
error_code = -1;
return error_code;
}
}
response_end_offset = offset;
--num_req_sent;
++num_req_rcvd;
char *start = readbuf.begin();
char *const finish = start + response_end_offset - 1;
const size_t resp_code = read_ui32(start, finish);
skip_one(start, finish);
num_flds_r = num_flds = read_ui32(start, finish);
if (resp_code != 0) {
skip_one(start, finish);
char *const err_begin = start;
read_token(start, finish);
char *const err_end = start;
String e = String(err_begin, err_end - err_begin, &my_charset_bin);
if (!e.length()) {
e = String("unknown_error", &my_charset_bin);
}
return set_error(resp_code, e);
}
cur_row_offset = start - readbuf.begin();
DBG(fprintf(stderr, "[%s] ro=%zu eol=%zu\n",
String(readbuf.begin(), readbuf.begin() + response_end_offset)
.c_str(),
cur_row_offset, response_end_offset));
DBG(fprintf(stderr, "RES 0\n"));
if (flds.max_element < num_flds)
{
if (allocate_dynamic(&flds, num_flds))
return set_error(-1, "out of memory");
}
flds.elements = num_flds;
return 0;
}
示例8: String
String NumberInputType::serialize(const Decimal& value) const
{
if (!value.isFinite())
return String();
return serializeForNumberType(value);
}
示例9: String
String RenderThemeChromiumAndroid::extraMediaControlsStyleSheet()
{
return String(mediaControlsAndroidUserAgentStyleSheet, sizeof(mediaControlsAndroidUserAgentStyleSheet));
}
示例10: ExecuteGameEvent
BOOLEAN ExecuteGameEvent( EVENT *pEvent )
{
SOLDIERTYPE *pSoldier;
// Switch on event type
switch( pEvent->uiEvent )
{
case E_PLAYSOUND:
memcpy( &EPlaySound, pEvent->pData, pEvent->uiDataSize );
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Play Sound");
PlayJA2Sample( EPlaySound.usIndex, EPlaySound.usRate, EPlaySound.ubVolume, EPlaySound.ubLoops, EPlaySound.uiPan );
break;
case S_CHANGESTATE:
memcpy( &SChangeState, pEvent->pData, pEvent->uiDataSize );
// Get soldier pointer from ID
if ( GetSoldier( &pSoldier, SChangeState.usSoldierID ) == FALSE )
{
// Handle Error?
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
break;
}
// check for error
if( pSoldier->uiUniqueSoldierIdValue != SChangeState.uiUniqueId )
{
break;
}
// Call soldier function
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Event Pump: ChangeState %S (%d)", gAnimControl[ SChangeState.ubNewState ].zAnimStr, SChangeState.usSoldierID ) );
pSoldier->EVENT_InitNewSoldierAnim( SChangeState.usNewState, SChangeState.usStartingAniCode, SChangeState.fForce );
break;
case S_CHANGEDEST:
memcpy( &SChangeDest, pEvent->pData, pEvent->uiDataSize );
// Get soldier pointer from ID
if ( GetSoldier( &pSoldier, SChangeDest.usSoldierID ) == FALSE )
{
// Handle Error?
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Event Pump: Invalid Soldier ID #%d", SChangeDest.usSoldierID) );
break;
}
// check for error
if( pSoldier->uiUniqueSoldierIdValue != SChangeDest.uiUniqueId )
{
break;
}
// Call soldier function
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Change Dest");
pSoldier->EVENT_SetSoldierDestination( (UINT8) SChangeDest.usNewDestination );
break;
case S_SETPOSITION:
memcpy( &SSetPosition, pEvent->pData, pEvent->uiDataSize );
// Get soldier pointer from ID
if ( GetSoldier( &pSoldier, SSetPosition.usSoldierID ) == FALSE )
{
// Handle Error?
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
break;
}
// check for error
if( pSoldier->uiUniqueSoldierIdValue != SSetPosition.uiUniqueId )
{
break;
}
// Call soldier function
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Event Pump: SetPosition ( %f %f ) ( %d )", SSetPosition.dNewXPos, SSetPosition.dNewYPos, SSetPosition.usSoldierID ) );
pSoldier->EVENT_SetSoldierPosition( SSetPosition.dNewXPos, SSetPosition.dNewYPos );
break;
case S_GETNEWPATH:
memcpy( &SGetNewPath, pEvent->pData, pEvent->uiDataSize );
// Get soldier pointer from ID
if ( GetSoldier( &pSoldier, SGetNewPath.usSoldierID ) == FALSE )
{
// Handle Error?
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Event Pump: Invalid Soldier ID");
break;
}
// check for error
if( pSoldier->uiUniqueSoldierIdValue != SGetNewPath.uiUniqueId )
{
break;
//.........这里部分代码省略.........
示例11: Show_Message
void TransitAccess::Read_Skims (Skim_Itr &itr)
{
int org, ndes, table, number;
Db_Mat_Ptr skim_ptr;
Doubles table_data, *table_ptr;
Dbls_Itr dbls_itr;
double *data;
skim_ptr = skim_files [itr->index];
number = itr->number;
Show_Message (String ("Reading %s -- Record") % skim_ptr->File_Type ());
Set_Progress ();
ndes = skim_ptr->Num_Des ();
//---- allocate skim matrix memory ----
if (itr->time.size () == 0) {
itr->time.assign (nzones, table_data);
itr->distance.assign (nzones, table_data);
for (dbls_itr = itr->time.begin (); dbls_itr != itr->time.end (); dbls_itr++) {
dbls_itr->assign (ndes, 0.0);
}
for (dbls_itr = itr->distance.begin (); dbls_itr != itr->distance.end (); dbls_itr++) {
dbls_itr->assign (ndes, 0.0);
}
}
//---- read the skim data into memory ----
if (itr->time_table < itr->dist_table) {
for (org=1; org <= nzones; org++) {
Show_Progress ();
table = itr->time_table;
table_ptr = &itr->time [org-1];
data = &table_ptr->at (0);
if (!skim_ptr->Read (data, org, table)) {
Error (String ("Reading Skim Group=%d, Time Table=%d, Origin=%d") % number % table % org);
}
table = itr->dist_table;
table_ptr = &itr->distance [org-1];
data = &table_ptr->at (0);
if (!skim_ptr->Read (data, org, table)) {
Error (String ("Reading Skim Group=%d, Distance Table=%d, Origin=%d") % number % table % org);
}
}
} else {
for (org=1; org <= nzones; org++) {
Show_Progress ();
table = itr->dist_table;
table_ptr = &itr->distance [org-1];
data = &table_ptr->at (0);
if (!skim_ptr->Read (data, org, table)) {
Error (String ("Reading Skim Group=%d, Distance Table=%d, Origin=%d") % number % table % org);
}
table = itr->time_table;
table_ptr = &itr->time [org-1];
data = &table_ptr->at (0);
if (!skim_ptr->Read (data, org, table)) {
Error (String ("Reading Skim Group=%d, Time Table=%d, Origin=%d") % number % table % org);
}
}
}
End_Progress ();
skim_ptr->Close ();
}
示例12: String
String FontPlatformData::description() const
{
return String();
}
示例13: scanForDevices
//==============================================================================
void scanForDevices()
{
hasScanned = true;
inputNames.clear();
inputIds.clear();
outputNames.clear();
outputIds.clear();
if (juce_libjackHandle == nullptr)
{
juce_libjackHandle = dlopen ("libjack.so", RTLD_LAZY);
if (juce_libjackHandle == nullptr)
return;
}
// open a dummy client
jack_status_t status;
jack_client_t* client = juce::jack_client_open ("JuceJackDummy", JackNoStartServer, &status);
if (client == 0)
{
dumpJackErrorMessage (status);
}
else
{
// scan for output devices
const char** ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsOutput);
if (ports != 0)
{
int j = 0;
while (ports[j] != 0)
{
String clientName (ports[j]);
clientName = clientName.upToFirstOccurrenceOf (":", false, false);
if (clientName != String (JUCE_JACK_CLIENT_NAME)
&& ! inputNames.contains (clientName))
{
inputNames.add (clientName);
inputIds.add (ports [j]);
}
++j;
}
free (ports);
}
// scan for input devices
ports = juce::jack_get_ports (client, 0, 0, /* JackPortIsPhysical | */ JackPortIsInput);
if (ports != 0)
{
int j = 0;
while (ports[j] != 0)
{
String clientName (ports[j]);
clientName = clientName.upToFirstOccurrenceOf (":", false, false);
if (clientName != String (JUCE_JACK_CLIENT_NAME)
&& ! outputNames.contains (clientName))
{
outputNames.add (clientName);
outputIds.add (ports [j]);
}
++j;
}
free (ports);
}
juce::jack_client_close (client);
}
}
示例14: errorCallback
static void errorCallback (const char* msg)
{
jack_Log ("JackAudioIODevice::errorCallback " + String (msg));
}
示例15: String
void TextCheckingParagraph::invalidateParagraphRangeValues()
{
m_checkingStart = m_checkingEnd = -1;
m_offsetAsRange = nullptr;
m_text = String();
}