String XMLText::nodeNotFound(const String& nodeName) const { return getText("Node (%s) not found", nodeName.c_str()); }
void ProjLoad_fillProjectVarsInSourceFiles(StringTree&sourceTree, const String&templateSrcRoot, const String&projectSrcRoot, const String&subFolder, const String&projectName, const String&authorName, const String&projectNameAsIdentifier, const String&executableName, const String& productName) { ArrayList<String> members = sourceTree.getMembers(); String templateSrcCurrentFolder = templateSrcRoot; String projectSrcCurrentFolder = projectSrcRoot; if(!subFolder.equals("")) { templateSrcCurrentFolder += (String)"/" + subFolder; projectSrcCurrentFolder += (String)"/" + subFolder; } for(int i=0; i<members.size(); i++) { String filename = members.get(i); String filepath = templateSrcCurrentFolder + '/' + filename; String fileContents; bool loadedFile = FileTools::loadFileIntoString(filepath, fileContents); if(!loadedFile) { showSimpleMessageBox("Error loading ProjectData", (String)"Error loading file " + filepath); } else { ProjLoad_fillProjectVarsInString(fileContents, projectName, authorName, projectNameAsIdentifier, executableName, productName); String newFilename = filename; ProjLoad_fillProjectVarsInString(newFilename, projectName, authorName, projectNameAsIdentifier, executableName, productName); String saveFile = newFilename; //rename file if necessary bool couldRename = false; int matchChecks = 0; do { couldRename = sourceTree.renameMember(filename, saveFile); if(!couldRename) { matchChecks++; saveFile = newFilename + " (" + matchChecks + ')'; } } while (!couldRename); bool success = FileTools::writeStringToFile(projectSrcCurrentFolder + '/' + saveFile, fileContents); if(!success) { showSimpleMessageBox("Error creating new project", (String)"Error creating file " + projectSrcCurrentFolder + '/' + saveFile); } } } ArrayList<String> branchNames = sourceTree.getBranchNames(); for(int i=0; i<branchNames.size(); i++) { String branchname = branchNames.get(i); String branchpath = templateSrcCurrentFolder + '/' + branchname; String newBranchname = branchname; ProjLoad_fillProjectVarsInString(newBranchname, projectName, authorName, projectNameAsIdentifier, executableName, productName); String saveFolder = newBranchname; //rename file if necessary bool couldRename = false; int matchChecks = 0; do { couldRename = sourceTree.renameBranch(branchname, saveFolder); if(!couldRename) { matchChecks++; saveFolder = newBranchname + " (" + matchChecks + ')'; } } while (!couldRename); bool success = FileTools::createDirectory(projectSrcCurrentFolder + '/' + saveFolder); if(success) { StringTree*tree = sourceTree.getBranch(saveFolder); ProjLoad_fillProjectVarsInSourceFiles(*tree, templateSrcRoot, projectSrcRoot, subFolder + '/' + saveFolder, projectName, authorName, projectNameAsIdentifier, executableName, productName); } else { showSimpleMessageBox("Error creating new project", (String)"Error creating folder " + projectSrcCurrentFolder + '/' + saveFolder); } } }
void GraphicsContext3DInternal::bindAttribLocation(Platform3DObject program, GC3Duint index, const String& name) { m_impl->bindAttribLocation(program, index, name.utf8().data()); }
void TextBox::setText(String t) { txt_len = t.len(); strcpy(&txt[0], t.ptr()); }
static Array HHVM_FUNCTION(getopt, const String& options, const Variant& longopts /*=null */) { opt_struct *opts, *orig_opts; int len = parse_opts(options.data(), options.size(), &opts); if (!longopts.isNull()) { Array arropts = longopts.toArray(); int count = arropts.size(); /* the first <len> slots are filled by the one short ops * we now extend our array and jump to the new added structs */ opts = (opt_struct *)realloc(opts, sizeof(opt_struct) * (len + count + 1)); orig_opts = opts; opts += len; memset(opts, 0, count * sizeof(opt_struct)); for (ArrayIter iter(arropts); iter; ++iter) { String entry = iter.second().toString(); opts->need_param = 0; opts->opt_name = strdup(entry.data()); len = strlen(opts->opt_name); if ((len > 0) && (opts->opt_name[len - 1] == ':')) { opts->need_param++; opts->opt_name[len - 1] = '\0'; if ((len > 1) && (opts->opt_name[len - 2] == ':')) { opts->need_param++; opts->opt_name[len - 2] = '\0'; } } opts->opt_char = 0; opts++; } } else { opts = (opt_struct*) realloc(opts, sizeof(opt_struct) * (len + 1)); orig_opts = opts; opts += len; } /* php_getopt want to identify the last param */ opts->opt_char = '-'; opts->need_param = 0; opts->opt_name = NULL; static const StaticString s_argv("argv"); Array vargv = php_global(s_argv).toArray(); int argc = vargv.size(); char **argv = (char **)malloc((argc+1) * sizeof(char*)); std::vector<String> holders; int index = 0; for (ArrayIter iter(vargv); iter; ++iter) { String arg = iter.second().toString(); holders.push_back(arg); argv[index++] = (char*)arg.data(); } argv[index] = NULL; /* after our pointer arithmetic jump back to the first element */ opts = orig_opts; int o; char *php_optarg = NULL; int php_optind = 1; SCOPE_EXIT { free_longopts(orig_opts); free(orig_opts); free(argv); }; Array ret = Array::Create(); Variant val; int optchr = 0; int dash = 0; /* have already seen the - */ char opt[2] = { '\0' }; char *optname; int optname_len = 0; int php_optidx; while ((o = php_getopt(argc, argv, opts, &php_optarg, &php_optind, 0, 1, optchr, dash, php_optidx)) != -1) { /* Skip unknown arguments. */ if (o == '?') { continue; } /* Prepare the option character and the argument string. */ if (o == 0) { optname = opts[php_optidx].opt_name; } else { if (o == 1) { o = '-'; } opt[0] = o; optname = opt; } if (php_optarg != NULL) { /* keep the arg as binary, since the encoding is not known */ val = String(php_optarg, CopyString); } else { val = false; } /* Add this option / argument pair to the result hash. */ optname_len = strlen(optname); if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == KindOfInt64) { /* numeric string */ int optname_int = atoi(optname); if (ret.exists(optname_int)) { Variant &e = ret.lvalAt(optname_int); if (!e.isArray()) { ret.set(optname_int, make_packed_array(e, val)); } else { e.toArrRef().append(val); } } else { ret.set(optname_int, val); } } else { /* other strings */ String key(optname, strlen(optname), CopyString); if (ret.exists(key)) { Variant &e = ret.lvalAt(key); if (!e.isArray()) { ret.set(key, make_packed_array(e, val)); } else { e.toArrRef().append(val); } } else { ret.set(key, val); } } php_optarg = NULL; } return ret; }
void MediaPlayerPrivate::setCertificatePath(const String& caPath) { MMRPlayer::setCertificatePath(string(caPath.utf8().data())); }
int main(int argc, char* argv[]) { try { String url; String ns; String classname; // handle backwards compatible options, which was <URL> <namespace> <classname> // TODO: This is deprecated in 3.1.0, remove it post 3.1 if (argc == 4 && argv[1][0] != '-' && argv[2][0] != '-' && argv[3][0] != '-') { url = argv[1]; ns = argv[2]; classname = argv[3]; cerr << "This cmd line usage is deprecated!\n"; } else { CmdLineParser parser(argc, argv, g_options, CmdLineParser::E_NON_OPTION_ARGS_INVALID); if (parser.isSet(HELP_OPT)) { Usage(); return 0; } else if (parser.isSet(VERSION_OPT)) { cout << "owenumclassnames (OpenWBEM) " << OW_VERSION << '\n'; cout << "Written by Dan Nuffer.\n"; return 0; } url = parser.getOptionValue(URL_OPT, "http://localhost/root/cimv2"); ns = URL(url).namespaceName; if (ns.empty()) { cerr << "No namespace given as part of the url." << endl; Usage(); return 1; } classname = parser.getOptionValue(CLASSNAME_OPT); } ClientAuthCBIFCRef getLoginInfo(new GetLoginInfo); ClientCIMOMHandleRef rch = ClientCIMOMHandle::createFromURL(url, getLoginInfo); classNamePrinter handler; rch->enumClassNames(ns, classname, handler); return 0; } catch (CmdLineParserException& e) { printCmdLineParserExceptionMessage(e); Usage(); } catch(const Exception& e) { cerr << e << endl; } catch(const std::exception& e) { cerr << e.what() << endl; } catch(...) { cerr << "Caught unknown exception in main" << endl; } return 1; }
bool mm::parse(ID3_TagImpl& tag, ID3_Reader& rdr) { io::ExitTrigger et(rdr); ID3_Reader::pos_type end = rdr.getCur(); if (end < rdr.getBeg() + 48) { ID3D_NOTICE( "mm::parse: bailing, not enough bytes to parse, pos = " << end ); return false; } rdr.setCur(end - 48); String version; { if (io::readText(rdr, 32) != "Brava Software Inc. ") { ID3D_NOTICE( "mm::parse: bailing, couldn't find footer" ); return false; } version = io::readText(rdr, 4); if (version.size() != 4 || !isdigit(version[0]) || version[1] != '.' || !isdigit(version[2]) || !isdigit(version[3])) { ID3D_WARNING( "mm::parse: bailing, nonstandard version = " << version ); return false; } } ID3_Reader::pos_type beg = rdr.setCur(end - 48); et.setExitPos(beg); if (end < 68) { ID3D_NOTICE( "mm::parse: bailing, not enough bytes to parse offsets, pos = " << end ); return false; } rdr.setCur(end - 68); io::WindowedReader dataWindow(rdr); dataWindow.setEnd(rdr.getCur()); size_t offsets[5]; io::WindowedReader offsetWindow(rdr, 20); for (size_t i = 0; i < 5; ++i) { offsets[i] = io::readLENumber(rdr, sizeof(uint32)); } size_t metadataSize = 0; if (version <= "3.00") { // All MusicMatch tags up to and including version 3.0 had metadata // sections exactly 7868 bytes in length. metadataSize = 7868; } else { // MusicMatch tags after version 3.0 had three possible lengths for their // metadata sections. We can determine which it was by searching for // the version section signature that should precede the metadata section // by exactly 256 bytes. size_t possibleSizes[] = { 8132, 8004, 7936 }; for (size_t i = 0; i < sizeof(possibleSizes)/sizeof(size_t); ++i) { dataWindow.setCur(dataWindow.getEnd()); // Our offset will be exactly 256 bytes prior to our potential metadata // section size_t offset = possibleSizes[i] + 256; if (dataWindow.getCur() < offset) { // if our filesize is less than the offset, then it can't possibly // be the correct offset, so try again. continue; } dataWindow.setCur(dataWindow.getCur() - offset); // now read in the signature to see if it's a match if (io::readText(dataWindow, 8) == "18273645") { metadataSize = possibleSizes[i]; break; } } } if (0 == metadataSize) { // if we didn't establish a size for the metadata, then something is // wrong. probably should log this. ID3D_WARNING( "mm::parse: bailing, couldn't find meta data signature, end = " << end ); return false; } // parse the offset pointers to determine the actual sizes of all the // sections size_t sectionSizes[5]; size_t tagSize = metadataSize; // we already know the size of the last section sectionSizes[4] = metadataSize; size_t lastOffset = 0; for (int i = 0; i < 5; i++) { size_t thisOffset = offsets[i]; //ASSERT(thisOffset > lastOffset); if (i > 0) { size_t sectionSize = thisOffset - lastOffset; sectionSizes[i-1] = sectionSize; tagSize += sectionSize; } lastOffset = thisOffset; } // now check to see that our tag size is reasonable if (dataWindow.getEnd() < tagSize) { // Ack! The tag size doesn't jive with the tag's ending position in // the file. Bail! ID3D_WARNING( "mm::parse: bailing, tag size is too big, tag size = " << tagSize << ", end = " << end ); return false; } dataWindow.setBeg(dataWindow.getEnd() - tagSize); dataWindow.setCur(dataWindow.getBeg()); // Now calculate the adjusted offsets offsets[0] = dataWindow.getBeg(); for (size_t i = 0; i < 4; ++i) { offsets[i+1] = offsets[i] + sectionSizes[i]; } // now check for a tag header and adjust the tag_beg pointer appropriately if (dataWindow.getBeg() >= 256) { rdr.setCur(dataWindow.getBeg() - 256); if (io::readText(rdr, 8) == "18273645") { et.setExitPos(rdr.getCur() - 8); } else { et.setExitPos(dataWindow.getBeg()); } dataWindow.setCur(dataWindow.getBeg()); } // Now parse the various sections... // Parse the image extension at offset 0 dataWindow.setCur(offsets[0]); String imgExt = io::readTrailingSpaces(dataWindow, 4); // Parse the image binary at offset 1 dataWindow.setCur(offsets[1]); uint32 imgSize = io::readLENumber(dataWindow, 4); if (imgSize == 0) { // no image binary. don't do anything. } else { io::WindowedReader imgWindow(dataWindow, imgSize); if (imgWindow.getEnd() < imgWindow.getBeg() + imgSize) { // Ack! The image size given extends beyond the next offset! This is // not good... log? } else { BString imgData = io::readAllBinary(imgWindow); ID3_Frame* frame = new ID3_Frame(ID3FID_PICTURE); if (frame) { String mimetype("image/"); mimetype += imgExt; frame->GetField(ID3FN_MIMETYPE)->Set(mimetype.c_str()); frame->GetField(ID3FN_IMAGEFORMAT)->Set(""); frame->GetField(ID3FN_PICTURETYPE)->Set(static_cast<unsigned int>(0)); frame->GetField(ID3FN_DESCRIPTION)->Set(""); frame->GetField(ID3FN_DATA)->Set(reinterpret_cast<const uchar*>(imgData.data()), imgData.size()); tag.AttachFrame(frame); } } } //file.seekg(offsets[2]); //file.seekg(offsets[3]); dataWindow.setCur(offsets[4]); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_TITLE)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_ALBUM)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_LEADARTIST)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_CONTENTTYPE)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Tempo")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Mood")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Situation")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Preference")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_SONGLEN)); // The next 12 bytes can be ignored. The first 8 represent the // creation date as a 64 bit floating point number. The last 4 are // for a play counter. dataWindow.skipChars(12); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Path")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Serial")); // 2 bytes for track uint32 trkNum = io::readLENumber(dataWindow, 2); if (trkNum > 0) { String trkStr = toString(trkNum); ID3_Frame* frame = new ID3_Frame(ID3FID_TRACKNUM); if (frame) { frame->GetField(ID3FN_TEXT)->Set(trkStr.c_str()); tag.AttachFrame(frame); } } tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Notes")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_Bio")); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_UNSYNCEDLYRICS)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_WWWARTIST)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_WWWCOMMERCIALINFO)); tag.AttachFrame(readTextFrame(dataWindow, ID3FID_COMMENT, "MusicMatch_ArtistEmail")); // email? return true; }
DebuggerProxyPtr Debugger::GetProxy() { SystemGlobals *g = (SystemGlobals*)get_global_variables(); String id = g->GV(_SERVER)["HPHP_SANDBOX_ID"]; return s_debugger.findProxy(id.data()); }
void LocaleWin::initializeLocalizerData() { if (m_didInitializeNumberData) return; Vector<String, DecimalSymbolsSize> symbols; enum DigitSubstitution { DigitSubstitutionContext = 0, DigitSubstitution0to9 = 1, DigitSubstitutionNative = 2, }; DWORD digitSubstitution = DigitSubstitution0to9; getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, digitSubstitution); if (digitSubstitution == DigitSubstitution0to9) { symbols.append("0"); symbols.append("1"); symbols.append("2"); symbols.append("3"); symbols.append("4"); symbols.append("5"); symbols.append("6"); symbols.append("7"); symbols.append("8"); symbols.append("9"); } else { String digits = getLocaleInfoString(LOCALE_SNATIVEDIGITS); ASSERT(digits.length() >= 10); for (unsigned i = 0; i < 10; ++i) symbols.append(digits.substring(i, 1)); } ASSERT(symbols.size() == DecimalSeparatorIndex); symbols.append(getLocaleInfoString(LOCALE_SDECIMAL)); ASSERT(symbols.size() == GroupSeparatorIndex); symbols.append(getLocaleInfoString(LOCALE_STHOUSAND)); ASSERT(symbols.size() == DecimalSymbolsSize); String negativeSign = getLocaleInfoString(LOCALE_SNEGATIVESIGN); enum NegativeFormat { NegativeFormatParenthesis = 0, NegativeFormatSignPrefix = 1, NegativeFormatSignSpacePrefix = 2, NegativeFormatSignSuffix = 3, NegativeFormatSpaceSignSuffix = 4, }; DWORD negativeFormat = NegativeFormatSignPrefix; getLocaleInfo(LOCALE_INEGNUMBER, negativeFormat); String negativePrefix = emptyString(); String negativeSuffix = emptyString(); switch (negativeFormat) { case NegativeFormatParenthesis: negativePrefix = "("; negativeSuffix = ")"; break; case NegativeFormatSignSpacePrefix: negativePrefix = negativeSign + " "; break; case NegativeFormatSignSuffix: negativeSuffix = negativeSign; break; case NegativeFormatSpaceSignSuffix: negativeSuffix = " " + negativeSign; break; case NegativeFormatSignPrefix: // Fall through. default: negativePrefix = negativeSign; break; } m_didInitializeNumberData = true; setLocalizerData(symbols, emptyString(), emptyString(), negativePrefix, negativeSuffix); }
void ScriptTextEditor::_load_theme_settings() { get_text_edit()->clear_colors(); /* keyword color */ get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); get_text_edit()->add_color_override("font_color",EDITOR_DEF("text_editor/text_color",Color(0,0,0))); get_text_edit()->add_color_override("font_selected_color",EDITOR_DEF("text_editor/text_selected_color",Color(1,1,1))); get_text_edit()->add_color_override("selection_color",EDITOR_DEF("text_editor/selection_color",Color(0.2,0.2,1))); Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2)); get_text_edit()->set_syntax_coloring(true); List<String> keywords; script->get_language()->get_reserved_words(&keywords); for(List<String>::Element *E=keywords.front();E;E=E->next()) { get_text_edit()->add_keyword_color(E->get(),keyword_color); } //colorize core types Color basetype_color= EDITOR_DEF("text_editor/base_type_color",Color(0.3,0.3,0.0)); get_text_edit()->add_keyword_color("Vector2",basetype_color); get_text_edit()->add_keyword_color("Vector3",basetype_color); get_text_edit()->add_keyword_color("Plane",basetype_color); get_text_edit()->add_keyword_color("Quat",basetype_color); get_text_edit()->add_keyword_color("AABB",basetype_color); get_text_edit()->add_keyword_color("Matrix3",basetype_color); get_text_edit()->add_keyword_color("Transform",basetype_color); get_text_edit()->add_keyword_color("Color",basetype_color); get_text_edit()->add_keyword_color("Image",basetype_color); get_text_edit()->add_keyword_color("InputEvent",basetype_color); //colorize engine types Color type_color= EDITOR_DEF("text_editor/engine_type_color",Color(0.0,0.2,0.4)); List<String> types; ObjectTypeDB::get_type_list(&types); for(List<String>::Element *E=types.front();E;E=E->next()) { get_text_edit()->add_keyword_color(E->get(),type_color); } //colorize comments Color comment_color = EDITOR_DEF("text_editor/comment_color",Color::hex(0x797e7eff)); List<String> comments; script->get_language()->get_comment_delimiters(&comments); for(List<String>::Element *E=comments.front();E;E=E->next()) { String comment = E->get(); String beg = comment.get_slice(" ",0); String end = comment.get_slice_count(" ")>1?comment.get_slice(" ",1):String(); get_text_edit()->add_color_region(beg,end,comment_color,end==""); } //colorize strings Color string_color = EDITOR_DEF("text_editor/string_color",Color::hex(0x6b6f00ff)); List<String> strings; script->get_language()->get_string_delimiters(&strings); for (List<String>::Element *E=strings.front();E;E=E->next()) { String string = E->get(); String beg = string.get_slice(" ",0); String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String(); get_text_edit()->add_color_region(beg,end,string_color,end==""); } //colorize symbols Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff)); get_text_edit()->set_symbol_color(symbol_color); }
double LocaleWin::parseDate(const Vector<DateFormatToken>& tokens, int baseYear, const String& input) { ensureShortMonthLabels(); ensureMonthLabels(); const double NaN = numeric_limits<double>::quiet_NaN(); unsigned inputIndex = 0; int day = -1, month = -1, year = -1; for (unsigned i = 0; i < tokens.size(); ++i) { switch (tokens[i].type) { case DateFormatToken::Literal: { String data = tokens[i].data; unsigned literalLength = data.length(); if (input.substring(inputIndex, literalLength) == data) inputIndex += literalLength; // Go ahead even if the input doesn't have this string. break; } case DateFormatToken::Day1: case DateFormatToken::Day2: day = parseNumber(input, inputIndex); if (day < 1 || day > 31) return NaN; break; case DateFormatToken::Month1: case DateFormatToken::Month2: case DateFormatToken::Month3: case DateFormatToken::Month4: month = parseNumberOrMonth(input, inputIndex); if (month < 0 || month > 11) return NaN; break; case DateFormatToken::Year1: { unsigned oldIndex = inputIndex; year = parseNumber(input, inputIndex); if (year <= 0) return NaN; if (inputIndex - oldIndex == 1) { int shortYear = baseYear % 10; int decade = baseYear - shortYear; if (shortYear >= 5) year += shortYear - 4 <= year ? decade : decade + 10; else year += shortYear + 5 >= year ? decade : decade - 10; } break; } case DateFormatToken::Year2: { unsigned oldIndex = inputIndex; year = parseNumber(input, inputIndex); if (year <= 0) return NaN; if (inputIndex - oldIndex == 2) { int shortYear = baseYear % 100; int century = baseYear - shortYear; if (shortYear >= 50) year += shortYear - 49 <= year ? century : century + 100; else year += shortYear + 50 >= year ? century : century - 100; } break; } case DateFormatToken::Year4: year = parseNumber(input, inputIndex); if (year <= 0) return NaN; break; } } if (year <= 0 || month < 0 || day <= 0) return NaN; return dateToDaysFrom1970(year, month, day) * msPerDay; }
// See http://msdn.microsoft.com/en-us/library/dd317787(v=vs.85).aspx static Vector<DateFormatToken> parseDateFormat(const String format) { Vector<DateFormatToken> tokens; StringBuilder literalBuffer; bool inQuote = false; bool lastQuoteCanBeLiteral = false; for (unsigned i = 0; i < format.length(); ++i) { UChar ch = format[i]; if (inQuote) { if (ch == '\'') { inQuote = false; ASSERT(i); if (lastQuoteCanBeLiteral && format[i - 1] == '\'') { literalBuffer.append('\''); lastQuoteCanBeLiteral = false; } else lastQuoteCanBeLiteral = true; } else literalBuffer.append(ch); continue; } if (ch == '\'') { inQuote = true; if (lastQuoteCanBeLiteral && i > 0 && format[i - 1] == '\'') { literalBuffer.append(ch); lastQuoteCanBeLiteral = false; } else lastQuoteCanBeLiteral = true; } else if (isYearSymbol(ch)) { commitLiteralToken(literalBuffer, tokens); unsigned count = countContinuousLetters(format, i); i += count - 1; if (count == 1) tokens.append(DateFormatToken(DateFormatToken::Year1)); else if (count == 2) tokens.append(DateFormatToken(DateFormatToken::Year2)); else tokens.append(DateFormatToken(DateFormatToken::Year4)); } else if (isMonthSymbol(ch)) { commitLiteralToken(literalBuffer, tokens); unsigned count = countContinuousLetters(format, i); i += count - 1; if (count == 1) tokens.append(DateFormatToken(DateFormatToken::Month1)); else if (count == 2) tokens.append(DateFormatToken(DateFormatToken::Month2)); else if (count == 3) tokens.append(DateFormatToken(DateFormatToken::Month3)); else tokens.append(DateFormatToken(DateFormatToken::Month4)); } else if (isDaySymbol(ch)) { commitLiteralToken(literalBuffer, tokens); unsigned count = countContinuousLetters(format, i); i += count - 1; if (count == 1) tokens.append(DateFormatToken(DateFormatToken::Day1)); else tokens.append(DateFormatToken(DateFormatToken::Day2)); } else if (isEraSymbol(ch)) { // Just ignore era. // HTML5 date supports only A.D. } else literalBuffer.append(ch); } commitLiteralToken(literalBuffer, tokens); return tokens; }
String XMLText::unsupportedParser(const String& parserType) const { return getText("Unsupported parser type: (%s) ", parserType.c_str()); }
uint32_t NexRtc::read_rtc_time(char *time,uint32_t len) { char time_buf[22] = {"0000/00/00 00:00:00 0"}; uint32_t year,mon,day,hour,min,sec,week; String cmd; cmd = "get rtc0"; sendCommand(cmd.c_str()); recvRetNumber(&year); cmd = ""; cmd = "get rtc1"; sendCommand(cmd.c_str()); recvRetNumber(&mon); cmd = ""; cmd = "get rtc2"; sendCommand(cmd.c_str()); recvRetNumber(&day); cmd = ""; cmd = "get rtc3"; sendCommand(cmd.c_str()); recvRetNumber(&hour); cmd = ""; cmd = "get rtc4"; sendCommand(cmd.c_str()); recvRetNumber(&min); cmd = ""; cmd = "get rtc5"; sendCommand(cmd.c_str()); recvRetNumber(&sec); cmd = ""; cmd = "get rtc6"; sendCommand(cmd.c_str()); recvRetNumber(&week); time_buf[0] = year/1000 + '0'; time_buf[1] = (year/100)%10 + '0'; time_buf[2] = (year/10)%10 + '0'; time_buf[3] = year%10 + '0'; time_buf[5] = mon/10 + '0'; time_buf[6] = mon%10 + '0'; time_buf[8] = day/10 + '0'; time_buf[9] = day%10 + '0'; time_buf[11] = hour/10 + '0'; time_buf[12] = hour%10 + '0'; time_buf[14] = min/10 + '0'; time_buf[15] = min%10 + '0'; time_buf[17] = sec/10 + '0'; time_buf[18] = sec%10 + '0'; time_buf[20] = week + '0'; time_buf[21] = '\0'; if(len >= 22) { for(int i=0;i<22;i++) { time[i] = time_buf[i]; } } else{ for(int i=0;i<len;i++) { time[i] = time_buf[i]; } } }
Result Result::fail (const String& errorMessage) noexcept { return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage); }
void Item::toString( String &target ) const { target.size(0); switch( this->type() ) { case FLC_ITEM_NIL: target = "Nil"; break; case FLC_ITEM_UNB: target = "_"; break; case FLC_ITEM_BOOL: target = asBoolean() ? "true" : "false"; break; case FLC_ITEM_INT: target.writeNumber( this->asInteger() ); break; case FLC_ITEM_RANGE: target = "["; target.writeNumber( (int64) this->asRangeStart() ); target += ":"; if ( ! this->asRangeIsOpen() ) { target.writeNumber( (int64) this->asRangeEnd() ); if ( this->asRangeStep() != 0 ) { target += ":"; target.writeNumber( (int64) this->asRangeStep() ); } } target += "]"; break; case FLC_ITEM_NUM: { target.writeNumber( this->asNumeric(), "%.16g" ); } break; case FLC_ITEM_MEMBUF: target = "MemBuf( "; target.writeNumber( (int64) this->asMemBuf()->length() ); target += ", "; target.writeNumber( (int64) this->asMemBuf()->wordSize() ); target += " )"; break; case FLC_ITEM_STRING: target = *asString(); break; case FLC_ITEM_LBIND: if ( isFutureBind() ) { String temp; asFutureBind().toString(temp); target = *asLBind() + "|" + temp; } else target = "&" + *asLBind(); break; case FLC_ITEM_REFERENCE: dereference()->toString( target ); break; case FLC_ITEM_OBJECT: target = "Object from " + asObjectSafe()->generator()->symbol()->name(); break; case FLC_ITEM_ARRAY: target = "Array"; break; case FLC_ITEM_DICT: target = "Dictionary"; break; case FLC_ITEM_FUNC: target = "Function " + this->asFunction()->symbol()->name(); break; case FLC_ITEM_CLASS: target = "Class " + this->asClass()->symbol()->name(); break; case FLC_ITEM_METHOD: { Item orig; this->getMethodItem( orig ); String temp; orig.dereference()->toString( temp ); target = "Method (" + temp + ")." + this->asMethodFunc()->name(); } break; case FLC_ITEM_CLSMETHOD: target = "ClsMethod " + this->asMethodClass()->symbol()->name(); break; default: target = "<?>"; } }
void FILEFile::init() { // Open mode for file's open const char *omode = "rb"; if (OpenFlags & Open_Truncate) { if (OpenFlags & Open_Read) omode = "w+b"; else omode = "wb"; } else if (OpenFlags & Open_Create) { if (OpenFlags & Open_Read) omode = "a+b"; else omode = "ab"; } else if (OpenFlags & Open_Write) omode = "r+b"; #if defined(OVR_OS_MS) SysErrorModeDisabler disabler(FileName.ToCStr()); #endif #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) wchar_t womode[16]; wchar_t *pwFileName = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(FileName.ToCStr())+1) * sizeof(wchar_t)); UTF8Util::DecodeString(pwFileName, FileName.ToCStr()); OVR_ASSERT(strlen(omode) < sizeof(womode)/sizeof(womode[0])); UTF8Util::DecodeString(womode, omode); fs = _wfsopen(pwFileName, womode, _SH_DENYWR); // Allow others to read the file when we are writing it. OVR_FREE(pwFileName); #else fs = fopen(FileName.ToCStr(), omode); #endif if (fs) rewind (fs); Opened = (fs != NULL); // Set error code if (!Opened) ErrorCode = SFerror(); else { // If we are testing file seek correctness, pre-load the entire file so // that we can do comparison tests later. #ifdef OVR_FILE_VERIFY_SEEK_ERRORS TestPos = 0; fseek(fs, 0, SEEK_END); FileTestLength = ftell(fs); fseek(fs, 0, SEEK_SET); pFileTestBuffer = (uint8_t*)OVR_ALLOC(FileTestLength); if (pFileTestBuffer) { OVR_ASSERT(FileTestLength == (unsigned)Read(pFileTestBuffer, FileTestLength)); Seek(0, Seek_Set); } #endif ErrorCode = 0; } LastOp = 0; }
void run_helper (const String &uuid, const String &config, const String &display) { SCIM_DEBUG_MAIN(1) << "run_helper (" << uuid << "," << config << "," << display << ")\n"; for (size_t i = 0; i < __helpers.size (); ++i) { if (__helpers [i].first.uuid == uuid && __helpers [i].second.length ()) { int pid; pid = fork (); if (pid < 0) return; if (pid == 0) { char * argv [] = { const_cast<char*> (SCIM_HELPER_LAUNCHER_PROGRAM), const_cast<char*> ("--daemon"), const_cast<char*> ("--config"), const_cast<char*> (config.c_str ()), const_cast<char*> ("--display"), const_cast<char*> (display.c_str ()), const_cast<char*> (__helpers [i].second.c_str ()), const_cast<char*> (__helpers [i].first.uuid.c_str ()), 0}; SCIM_DEBUG_MAIN(2) << " Call scim-helper-launcher.\n"; execv (SCIM_HELPER_LAUNCHER_PROGRAM, argv); exit (-1); } int status; waitpid (pid, &status, 0); break; } } SCIM_DEBUG_MAIN(2) << " exit run_helper ().\n"; }
const char* FILEFile::GetFilePath() { return FileName.ToCStr(); }
bool NetscapePlugin::initialize(const Parameters& parameters) { uint16_t mode = parameters.isFullFramePlugin ? NP_FULL : NP_EMBED; m_shouldUseManualLoader = parameters.shouldUseManualLoader; CString mimeTypeCString = parameters.mimeType.utf8(); ASSERT(parameters.names.size() == parameters.values.size()); Vector<CString> paramNames; Vector<CString> paramValues; for (size_t i = 0; i < parameters.names.size(); ++i) { String parameterName = parameters.names[i]; #if PLUGIN_ARCHITECTURE(MAC) if (m_pluginModule->pluginQuirks().contains(PluginQuirks::WantsLowercaseParameterNames)) parameterName = parameterName.lower(); #endif paramNames.append(parameterName.utf8()); paramValues.append(parameters.values[i].utf8()); } // The strings that these pointers point to are kept alive by paramNames and paramValues. Vector<const char*> names; Vector<const char*> values; for (size_t i = 0; i < paramNames.size(); ++i) { names.append(paramNames[i].data()); values.append(paramValues[i].data()); } #if PLUGIN_ARCHITECTURE(MAC) if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeTransparentIfBackgroundAttributeExists)) { for (size_t i = 0; i < parameters.names.size(); ++i) { if (equalIgnoringCase(parameters.names[i], "background")) { setIsTransparent(true); break; } } } m_layerHostingMode = parameters.layerHostingMode; #endif NetscapePlugin* previousNPPNewPlugin = currentNPPNewPlugin; m_inNPPNew = true; currentNPPNewPlugin = this; NPError error = NPP_New(const_cast<char*>(mimeTypeCString.data()), mode, names.size(), const_cast<char**>(names.data()), const_cast<char**>(values.data()), 0); m_inNPPNew = false; currentNPPNewPlugin = previousNPPNewPlugin; if (error != NPERR_NO_ERROR) return false; m_isStarted = true; // FIXME: This is not correct in all cases. m_npWindow.type = NPWindowTypeDrawable; if (!platformPostInitialize()) { destroy(); return false; } // Load the src URL if needed. if (!parameters.shouldUseManualLoader && !parameters.url.isEmpty() && shouldLoadSrcURL()) loadURL("GET", parameters.url.string(), String(), HTTPHeaderMap(), Vector<uint8_t>(), false, 0); return true; }
bool ScriptElementData::shouldExecuteAsJavaScript() const { /* Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only javascript1.1 - javascript1.3. Mozilla 1.8 and WinIE 7 both accept javascript and livescript. WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. We want to accept all the values that either of these browsers accept, but not other values. */ String type = m_scriptElement->typeAttributeValue(); if (!type.isEmpty()) { if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower())) return false; } else { String language = m_scriptElement->languageAttributeValue(); if (!language.isEmpty() && !isSupportedJavaScriptLanguage(language)) return false; } // No type or language is specified, so we assume the script to be JavaScript. // We don't yet support setting event listeners via the 'for' attribute for scripts. // If there is such an attribute it's likely better to not execute the script than to do so // immediately and unconditionally. // FIXME: After <rdar://problem/4471751> / https://bugs.webkit.org/show_bug.cgi?id=16915 are resolved // and we support the for syntax in script tags, this check can be removed and we should just // return 'true' here. String forAttribute = m_scriptElement->forAttributeValue(); String eventAttribute = m_scriptElement->eventAttributeValue(); if (forAttribute.isEmpty() || eventAttribute.isEmpty()) return true; forAttribute = forAttribute.stripWhiteSpace(); eventAttribute = eventAttribute.stripWhiteSpace(); return equalIgnoringCase(forAttribute, "window") && (equalIgnoringCase(eventAttribute, "onload") || equalIgnoringCase(eventAttribute, "onload()")); }
bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) { generatedFilename = m_page->injectedBundleUIClient().shouldGenerateFileForUpload(m_page, path); return !generatedFilename.isNull(); }
bool SVGViewSpec::parseViewSpec(const String& viewSpec) { const UChar* currViewSpec = viewSpec.characters(); const UChar* end = currViewSpec + viewSpec.length(); if (currViewSpec >= end) return false; if (!skipString(currViewSpec, end, svgViewSpec, sizeof(svgViewSpec) / sizeof(UChar))) return false; if (currViewSpec >= end || *currViewSpec != '(' ) return false; currViewSpec++; while (currViewSpec < end && *currViewSpec != ')') { if (*currViewSpec == 'v') { if (skipString(currViewSpec, end, viewBoxSpec, sizeof(viewBoxSpec) / sizeof(UChar))) { if (currViewSpec >= end || *currViewSpec != '(') return false; currViewSpec++; FloatRect viewBox; if (!parseViewBox(m_contextElement->document(), currViewSpec, end, viewBox, false)) return false; setViewBoxBaseValue(viewBox); if (currViewSpec >= end || *currViewSpec != ')') return false; currViewSpec++; } else if (skipString(currViewSpec, end, viewTargetSpec, sizeof(viewTargetSpec) / sizeof(UChar))) { if (currViewSpec >= end || *currViewSpec != '(') return false; const UChar* viewTargetStart = ++currViewSpec; while (currViewSpec < end && *currViewSpec != ')') currViewSpec++; if (currViewSpec >= end) return false; setViewTargetString(String(viewTargetStart, currViewSpec - viewTargetStart)); currViewSpec++; } else return false; } else if (*currViewSpec == 'z') { if (!skipString(currViewSpec, end, zoomAndPanSpec, sizeof(zoomAndPanSpec) / sizeof(UChar))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; currViewSpec++; if (!parseZoomAndPan(currViewSpec, end)) return false; if (currViewSpec >= end || *currViewSpec != ')') return false; currViewSpec++; } else if (*currViewSpec == 'p') { if (!skipString(currViewSpec, end, preserveAspectRatioSpec, sizeof(preserveAspectRatioSpec) / sizeof(UChar))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; currViewSpec++; bool result = false; setPreserveAspectRatioBaseValue(SVGPreserveAspectRatio::parsePreserveAspectRatio(currViewSpec, end, false, result)); if (!result) return false; if (currViewSpec >= end || *currViewSpec != ')') return false; currViewSpec++; } else if (*currViewSpec == 't') { if (!skipString(currViewSpec, end, transformSpec, sizeof(transformSpec) / sizeof(UChar))) return false; if (currViewSpec >= end || *currViewSpec != '(') return false; currViewSpec++; SVGTransformable::parseTransformAttribute(m_transform.get(), currViewSpec, end, SVGTransformable::DoNotClearList); if (currViewSpec >= end || *currViewSpec != ')') return false; currViewSpec++; } else return false; if (currViewSpec < end && *currViewSpec == ';') currViewSpec++; } if (currViewSpec >= end || *currViewSpec != ')') return false; return true; }
// return -1 if error, 0 if nothing, and 1 if the node was processed. int32_t OTOffer::ProcessXMLNode(irr::io::IrrXMLReader*& xml) { int32_t nReturnVal = 0; // Here we call the parent class first. // If the node is found there, or there is some error, // then we just return either way. But if it comes back // as '0', then nothing happened, and we'll continue executing. // // -- Note you can choose not to call the parent if // you don't want to use any of those xml tags. // As I do below, in the case of OTAccount. // if (nReturnVal = OTContract::ProcessXMLNode(xml)) // return nReturnVal; if (!strcmp("marketOffer", xml->getNodeName())) { m_strVersion = xml->getAttributeValue("version"); String strIsSelling; strIsSelling = xml->getAttributeValue("isSelling"); if (strIsSelling.Compare("true")) m_bSelling = true; else m_bSelling = false; m_strContractType.Set((m_bSelling ? "ASK" : "BID")); const String strNotaryID(xml->getAttributeValue("notaryID")), strInstrumentDefinitionID( xml->getAttributeValue("instrumentDefinitionID")), strCurrencyTypeID(xml->getAttributeValue("currencyTypeID")); const Identifier NOTARY_ID(strNotaryID), INSTRUMENT_DEFINITION_ID(strInstrumentDefinitionID), CURRENCY_TYPE_ID(strCurrencyTypeID); SetNotaryID(NOTARY_ID); SetInstrumentDefinitionID(INSTRUMENT_DEFINITION_ID); SetCurrencyID(CURRENCY_TYPE_ID); const String strScale = xml->getAttributeValue("marketScale"); const int64_t lScale = strScale.Exists() ? strScale.ToLong() : 0; // if it doesn't exist, // the 0 here causes the // below error to fire. if (!isPowerOfTen(lScale)) { otOut << "OTOffer::ProcessXMLNode: Failure: marketScale *must* be " "1, or a power of 10. Instead I got: " << lScale << ".\n"; return (-1); } else SetScale(lScale); const String strPriceLimit = xml->getAttributeValue("priceLimit"); const int64_t lPriceLimit = strPriceLimit.Exists() ? strPriceLimit.ToLong() : 0; // if it doesn't exist, the 0 here // causes the below error to fire. // NOTE: Market Orders (new) have a 0 price, so this error condition was // changed. if (!strPriceLimit.Exists()) // if (lPriceLimit < 1) { otOut << "OTOffer::ProcessXMLNode: Failure: priceLimit *must* be " "provided(" << lPriceLimit << ").\n"; return (-1); } else SetPriceLimit(lPriceLimit); const String strTotal = xml->getAttributeValue("totalAssetsOnOffer"); const int64_t lTotal = strTotal.Exists() ? strTotal.ToLong() : 0; // if it doesn't exist, // the 0 here causes the // below error to fire. if (lTotal < 1) { otOut << "OTOffer::ProcessXMLNode: Failure: totalAssetsOnOffer " "*must* be larger than 0. Instead I got: " << lTotal << ".\n"; return (-1); } else SetTotalAssetsOnOffer(lTotal); const String strFinished = xml->getAttributeValue("finishedSoFar"); const int64_t lFinished = strFinished.Exists() ? strFinished.ToLong() : 0; // if it doesn't exist, the 0 here // causes the below error to fire. if (lFinished < 0) { otOut << "OTOffer::ProcessXMLNode: Failure: finishedSoFar *must* " "be 0 or larger. Instead I got: " << lFinished << ".\n"; return (-1); } else SetFinishedSoFar(lFinished); const String strMinInc = xml->getAttributeValue("minimumIncrement"); // if it doesn't exist, the 0 here causes the below error to fire. const int64_t lMinInc = strMinInc.Exists() ? strMinInc.ToLong() : 0; if ((lMinInc < 1) || (lMinInc > lTotal)) // Minimum increment cannot // logically be higher than the // total assets on offer... { otOut << "OTOffer::ProcessXMLNode: Failure: minimumIncrement " "*must* be 1 or larger, \n" "and must also be less than the total assets on offer. " "Instead I got: " << lMinInc << ".\n"; return (-1); } else SetMinimumIncrement(lMinInc); const String strTransNum = xml->getAttributeValue("transactionNum"); const int64_t lTransNum = strTransNum.Exists() ? strTransNum.ToLong() : 0; SetTransactionNum(lTransNum); const String str_valid_from = xml->getAttributeValue("validFrom"); const String str_valid_to = xml->getAttributeValue("validTo"); int64_t tValidFrom = str_valid_from.Exists() ? parseTimestamp(str_valid_from.Get()) : 0; int64_t tValidTo = str_valid_to.Exists() ? parseTimestamp(str_valid_to.Get()) : 0; if ((tValidTo < tValidFrom) && (tValidTo != 0)) { otOut << "OTOffer::" << __FUNCTION__ << ": Failure: validTo date (" << tValidFrom << ") cannot be earlier than " "validFrom date (" << tValidTo << ").\n"; return (-1); } SetValidFrom(OTTimeGetTimeFromSeconds(tValidFrom)); SetValidTo(OTTimeGetTimeFromSeconds(tValidTo)); otLog4 << "\n\nOffer. Transaction Number: " << m_lTransactionNum << "\n Valid From: " << tValidFrom << "\n Valid To: " << tValidTo << "\n" " InstrumentDefinitionID: " << strInstrumentDefinitionID << "\n CurrencyTypeID: " << strCurrencyTypeID << "\n NotaryID: " << strNotaryID << "\n" " Price Limit: " << GetPriceLimit() << ", Total Assets on Offer: " << GetTotalAssetsOnOffer() << ", " << (m_bSelling ? "sold" : "bought") << " so far: " << GetFinishedSoFar() << "\n " " Scale: " << GetScale() << ". Minimum Increment: " << GetMinimumIncrement() << ". This offer is a" << (m_bSelling ? "n ASK" : " BID") << ".\n"; nReturnVal = 1; } return nReturnVal; }
void ImageDesignManager::updateCustomization(CreatureObject* imageDesigner, const String& customizationName, float value, CreatureObject* creo) { if (creo == NULL) return; if (value < 0 || value > 1) return; String speciesGender = getSpeciesGenderString(creo); ManagedReference<CreatureObject*> creatureObject = creo; CustomizationData* customData = getCustomizationData(speciesGender, customizationName); if (customData == NULL) { //System::out << "Unable to get CustomizationData for " + speciesGender + "_" + customizationName << endl; return; } String variables = customData->getVariables(); String type = customData->getType(); String skillMod = customData->getImageDesignSkillMod(); if (imageDesigner->getSkillMod(skillMod) < customData->getSkillModValue()) return; if (customData->getIsScale()) { float minScale = customData->getMinScale(); float maxScale = customData->getMaxScale(); float height = minScale + value * (maxScale - minScale); creatureObject->setHeight(MAX(MIN(height, maxScale), minScale)); return; } Vector<String> fullVariables; StringTokenizer tokenizer(variables); tokenizer.setDelimeter(","); while (tokenizer.hasMoreTokens()) { String var; tokenizer.getStringToken(var); fullVariables.add(var); } String appearanceFilename = creo->getObjectTemplate()->getAppearanceFilename(); VectorMap<String, Reference<CustomizationVariable*> > variableLimits; AssetCustomizationManagerTemplate::instance()->getCustomizationVariables(appearanceFilename.hashCode(), variableLimits, false); for (int i = 0; i < fullVariables.size(); ++i) { String var = fullVariables.get(i); for (int j = 0; j < variableLimits.size(); ++j) { String fullVariableNameLimit = variableLimits.elementAt(j).getKey(); if (fullVariableNameLimit.contains(var)) { BasicRangedIntCustomizationVariable* ranged = dynamic_cast<BasicRangedIntCustomizationVariable*>(variableLimits.elementAt(j).getValue().get()); if (ranged == NULL) { error("variable " + fullVariableNameLimit + " is not ranged"); continue; } int min = ranged->getMinValueInclusive(); int max = ranged->getMaxValueExclusive(); int count = max - min; int setVal; float currentValue = value; if (fullVariables.size() > 1) { // examples for var count = 2 // ex: received value 0 is for i == 0 -> 1.0, i == 1 -> 0.0 // ex: received value 0.5 is for i == 0 -> 0.0, i == 1 -> 0.0 // ex: received value 1 is for i == 0 -> 0.0, i == 1 -> 1.0 // pre: i Û [0, 1] && value Û [0, 1] // post f Û [0, 1] currentValue = MAX(0, ((value - 0.5) * 2) * (-1 + (i * 2))); } if (customData->getReverse()) { setVal = float(max - 1) - currentValue * (float(count) - 1); } else { setVal = float(min) + currentValue * (float(count) - 1); } creatureObject->setCustomizationVariable(fullVariableNameLimit, setVal, true); //info("setting " + fullVariableNameLimit + " to " + String::valueOf(setVal), true); } } } }
ProjectData_struct*ProjLoad_prepareProjectFromTemplate(const char*category, const char*templateName, const char*templatesRoot) { ProjectData_struct*projDataStruct = ProjLoad_loadProjectDataFromTemplate(category, templateName, templatesRoot); if(projDataStruct==NULL) { return NULL; } ProjectData&projData = *((ProjectData*)ProjectData_getData(projDataStruct)); //path variables String execDir = FileTools_getExecutableDirectory(); String homeDir = getenv("HOME"); String templateRoot = execDir + "/Project Templates/" + category + '/' + templateName; const String&savedProjectsRoot = savedProjectsFolder; //create the project info fields String var_projectName = ProjLoad_getIntendedProjectNameField(); String var_authorName = ProjLoad_getIntendedProjectAuthorField(); String var_projectNameAsIdentifier = ProjectData::createBundlenameFromName(var_projectName); String var_executableName = var_projectNameAsIdentifier; String var_productName = var_projectNameAsIdentifier; //finds and replaces instances of project variables withing the ProjectData object String field = projData.getName(); ProjLoad_fillProjectVarsInString(field, var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); projData.setName(field); field = projData.getAuthor(); ProjLoad_fillProjectVarsInString(field, var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); projData.setAuthor(field); field = projData.getBundleIdentifier(); ProjLoad_fillProjectVarsInString(field, var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); projData.setBundleIdentifier(field); field = projData.getExecutableName(); ProjLoad_fillProjectVarsInString(field, var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); projData.setExecutableName(field); field = projData.getProductName(); ProjLoad_fillProjectVarsInString(field, var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); projData.setProductName(field); //set save folder name String saveFolder = projData.getName(); String projectName = projData.getName(); ArrayList<String> currentProjects = FileTools::getFoldersInDirectory(savedProjectsRoot, false); int matchChecks = 0; //make sure there aren't any project folders with the same folder name //rename save folder if necessary (ex: "miniCode" becomes "miniCode (1)" or "miniCode (2)" etc.) bool matchedName = false; do { matchedName = false; for(int i=0; i<currentProjects.size(); i++) { if(saveFolder.equals(currentProjects.get(i))) { matchedName = true; i = currentProjects.size(); } } if(matchedName) { matchChecks++; saveFolder = projectName + " (" + matchChecks + ')'; } } while(matchedName); projData.setFolderName(saveFolder); String projectRoot = savedProjectsRoot + '/' + saveFolder; //create the project folder bool didMakeDirectory = FileTools::createDirectory(projectRoot); //checks for errors making the save folder if(!didMakeDirectory) { showSimpleMessageBox("", (String)"Error creating project folder " + projectRoot); ProjectData_destroyInstance(projDataStruct); return NULL; } //loop to create the subfolders inside the project folder const char*projFolders[4] = {"src", "res", "ext", "bin"}; for(int i=0; i<4; i++) { //create the subfolder didMakeDirectory = FileTools::createDirectory(projectRoot + '/' + projFolders[i]); //checks for errors making the subfolder if(!didMakeDirectory) { showSimpleMessageBox("", (String)"Error creating " + projFolders[i] + " folder in project folder " + projectRoot); ProjectData_destroyInstance(projDataStruct); return NULL; } } //go through source files, load the files, replace instances within the files, save the files (or attempt to) ProjLoad_fillProjectVarsInSourceFiles(projData.getSourceFiles(), templateRoot+"/src", projectRoot+"/src", "", var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); //go through resource files, save the files with renamed file name (or attempt to) ProjLoad_fillProjectVarsInResourceFiles(projData.getResourceFiles(), templateRoot+"/res", projectRoot+"/res", "", var_projectName,var_authorName,var_projectNameAsIdentifier,var_executableName,var_productName); //copy include and lib dirs bool success = FileTools::copyFolder(templateRoot + "/ext", projectRoot + "/ext"); if(!success) { showSimpleMessageBox("Error creating project", "Problem occured copying \"ext\" folder"); } FileTools::copyFile(templateRoot + "/project.plist", projectRoot + "/project.plist"); success = ProjectData_saveProjectPlist(projDataStruct); if(!success) { showSimpleMessageBox("Error creating project", "Problem occurred saving project.plist"); } ProjectSettings_struct projSettings = ProjectData_getProjectSettings(projDataStruct); success = ProjectSettings_saveSettingsPlist(&projSettings, projDataStruct); if(!success) { showSimpleMessageBox("Error", (String)"Unable to save settings.plist for project " + projData.getFolderName()); } return projDataStruct; }
void loop() { // Run Timers for(int i=0; i<NUMBER_OF_CHEMOSTATS; i++) { Timers[i].run(); } // Initialized empty command. String command = ""; // Check for command. delay(100); while(Serial.available()) { char c = Serial.read(); if(c == '\n') { break; } command += c; } if(command.length() <= 0) return; // Check for valid arguements. int argCount = 0; for(int i=0; i<command.length(); i++) { if(command[i] == '-') argCount += 2; } if(argCount <= 0) return; // Separate command arguements. String args[argCount]; int row = 0; boolean record = true; for(int i=0; i<command.length(); i++) { if(record && command[i] != ' ') args[row] += command[i]; else if(record && command[i] == ' ') record = false; else if (!record && command[i] != ' ') { record = true; row++; args[row] += command[i]; } } // Execute arguments String action = args[0]; int pumpId = args[1].toInt(); if(action == "-stop") { Chemostats[pumpId].StopPump(); Serial.print("(Ministat "); Serial.print(pumpId); Serial.println(") Pump deactived and stopped."); } else { for(int i=2; i<argCount; i+=2) { if(action == "-set") { Serial.println("Value has beem set."); if(args[i] == "-rpin") { int val = args[i+1].toInt(); Chemostats[pumpId].SetReadPin(val); //Serial.println("Read pin has been set."); } else if(args[i] == "-wpin") { int val = args[i+1].toInt(); Chemostats[pumpId].SetWritePin(val); //Serial.println("Write pin has been set."); } else if(args[i] == "-power") { int val = args[i+1].toInt(); Chemostats[pumpId].SetPower(val); //Serial.println("Power has been set."); } else if(args[i] == "-pwid") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetPulseWidth(val); //Serial.println("Pulse width has been set."); } else if(args[i] == "-pfreq") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetPulseFrequency(val); //Serial.println("Pulse frequency has been set."); } else if(args[i] == "-pvol") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetPulseVolume(val); //Serial.println("Pulse volume has been set."); } else if(args[i] == "-prep") { int val = args[i+1].toInt(); Chemostats[pumpId].SetPulseRepeat(val); //Serial.println("Pulse repeat has been set."); } else if(args[i] == "-rvol") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetReactorVolume(val); //Serial.println("Reactor volume has been set."); } else if(args[i] == "-rmass") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetReactorMass(val); //Serial.println("Reactor mass has been set."); } else if(args[i] == "-rden") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetReactorDensity(val); //Serial.println("Reactor volume has been set."); } else if(args[i] == "-rdil") { float val = args[i+1].toFloat(); Chemostats[pumpId].SetReactorDilutionRate(val); //Serial.println("Reactor dilution rate has been set."); } else { Serial.print("Invalid command: "); Serial.println(args[i]); break; } } else if(action == "-get") { Serial.print("Pump "); Serial.print(pumpId); if(args[i] == "-rpin") { Serial.print(" read pin: "); Serial.println(Chemostats[pumpId].GetReadPin()); break; } else if(args[i] == "-wpin") { Serial.print(" write pin: "); Serial.println(Chemostats[pumpId].GetWritePin()); } else if(args[i] == "-power") { Serial.print(" power: "); Serial.println(Chemostats[pumpId].GetPower()); } else if(args[i] == "-pwid") { Serial.print(" pulse width: "); Serial.println(Chemostats[pumpId].GetPulseWidth()); } else if(args[i] == "-pfreq") { Serial.print(" pulse frequency: "); Serial.println(Chemostats[pumpId].GetPulseFrequency()); } else if(args[i] == "-pvol") { Serial.print(" - Pulse Volume: "); Serial.println(Chemostats[pumpId].GetPulseVolume()); } else if(args[i] == "-prep") { Serial.print(" pulse repeat: "); Serial.println(Chemostats[pumpId].GetPulseRepeat()); } else if(args[i] == "-rvol") { Serial.print(" reactor volume: "); Serial.println(Chemostats[pumpId].GetReactorVolume()); } else if(args[i] == "-rmass") { Serial.print(" reactor mass: "); Serial.println(Chemostats[pumpId].GetReactorMass()); } else if(args[i] == "-rden") { Serial.print(" reactor density: "); Serial.println(Chemostats[pumpId].GetReactorDensity()); } else if(args[i] == "-rdil") { Serial.print(" reactor dilution: "); Serial.println(Chemostats[pumpId].GetReactorDilutionRate()); } } else if(action == "-start") { if(args[i] == "-cont") { Serial.print("(Ministat "); Serial.print(pumpId); Serial.println(") Pump started in continuous mode."); Chemostats[pumpId].ContinuousPump(); } else if(args[i] == "-pulse") { Serial.print("(Ministat "); Serial.print(pumpId); Serial.println(") Pump started in pulse mode."); Chemostats[pumpId].PulsePump(); } else if(args[i] == "-auto") { Serial.print("Ministat "); Serial.print(pumpId); Serial.println(") Pump started in automated mode."); Chemostats[pumpId].AutomatePump(); if(pumpId==0) { Pump0_ON(); } else if(pumpId==1) { Pump1_ON(); } else if(pumpId==2) { Pump2_ON(); } else if(pumpId==3) { Pump3_ON(); } else if(pumpId==4) { Pump4_ON(); } else if(pumpId==5) { Pump5_ON(); } } } else { Serial.println("Unknown command received."); } } } }
GC3Dint GraphicsContext3DInternal::getAttribLocation(Platform3DObject program, const String& name) { return m_impl->getAttribLocation(program, name.utf8().data()); }
String XMLText::parserError(const String& errorDetail) const { return getText("Parser error; details (%s)", errorDetail.c_str()); }