Ejemplo n.º 1
0
libfalltergeist::Pro::File* ResourceManager::proFileType(unsigned int PID)
{
    unsigned int typeId = PID >> 24;
    std::string listFile;
    switch ((OBJECT_TYPE)typeId)
    {
        case OBJECT_TYPE::ITEM:
            listFile += "proto/items/items.lst";
            break;
        case OBJECT_TYPE::CRITTER:
            listFile += "proto/critters/critters.lst";
            break;
        case OBJECT_TYPE::SCENERY:
            listFile += "proto/scenery/scenery.lst";
            break;
        case OBJECT_TYPE::WALL:
            listFile += "proto/walls/walls.lst";
            break;
        case OBJECT_TYPE::TILE:
            listFile += "proto/tiles/tiles.lst";
            break;
        case OBJECT_TYPE::MISC:
            listFile += "proto/misc/misc.lst";
            break;
        default:
            Logger::error() << "ResourceManager::proFileType(unsigned int) - wrong PID: " << PID << std::endl;
            return nullptr;
    }

    auto lst = lstFileType(listFile);

    unsigned int index = 0x00000FFF & PID;

    if (index > lst->strings()->size())
    {
        Logger::error() << "ResourceManager::proFileType(unsigned int) - LST size < PID: " << PID << std::endl;
        return nullptr;
    }

    std::string protoName = lst->strings()->at(index-1);

    switch ((OBJECT_TYPE)typeId)
    {
        case OBJECT_TYPE::ITEM:
            return proFileType("proto/items/" + protoName);
        case OBJECT_TYPE::CRITTER:
            return proFileType("proto/critters/" + protoName);
        case OBJECT_TYPE::SCENERY:
            return proFileType("proto/scenery/" + protoName);
        case OBJECT_TYPE::WALL:
            return proFileType("proto/walls/" + protoName);
        case OBJECT_TYPE::TILE:
            return proFileType("proto/tiles/" + protoName);
        case OBJECT_TYPE::MISC:
            return proFileType("proto/misc/" + protoName);
    }
    return nullptr;
}
Ejemplo n.º 2
0
libfalltergeist::IntFileType * ResourceManager::intFileType(unsigned int SID)
{
    auto lst = lstFileType("scripts/scripts.lst");
    if (SID >= lst->strings()->size())
    {
        throw Exception("ResourceManager::intFileType() - wrong SID: " + std::to_string(SID));
    }

    return intFileType("scripts/" + lst->strings()->at(SID));
}
Ejemplo n.º 3
0
Archivo: strings.c Proyecto: stevej/ung
void real_main (int argc, char *const argv[]) {
    int i = 1;
    if (i == argc)
        strings (stdin, NULL);
    else
        for (; i < argc; ++i) {
            FILE *in = must_fopen (argv[i], "r");
            strings (in, argv[i]);
            must_fclose (in, argv[i]);
        }
    exit (status);
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[]) 
{
	int i; 

	opts.minlen = 4; 

	for (i=1; i<argc; i++) {
		char *t, *s = argv[i]; 
		t=0; /* shut up warnings */
		if (s[0] != '-' || s[1] == 0) 
			break; 
		if (s[1] == '-' && s[2] == 0) {
			++i;
			break; 
		}
		while (*++s) switch (*s) {
		          case '1': case '2': case '3': case '4': 
		case '5': case '6': case '7': case '8': case '9':
			s--; 
			/* FALLTHROUGH */ 
		case 'n': 
			opts.minlen = atoi(ARG()); 
			if (opts.minlen == 0) 
				USAGE(); 
			break;
		case 'f':
			opts.pr_fn++; 
			break; 
		case '?': 
		default: 
			USAGE();
			break;
		}
	}

	if ((seq_hold = malloc(opts.minlen*sizeof(char))) == NULL) {
		perror("malloc"); exit(2);
	}
	if (i == argc) {
		strings(0); 
	} else {
		for (; i<argc; i++) {
			char *s = argv[i]; 
			strings(s); 
		}
	}
	free(seq_hold); 
	return 0; 
}
Ejemplo n.º 5
0
int
main(int argc, char *argv[])
{
	FILE *fp;
	size_t len = 4;
	int ret = 0;
	char f;

	ARGBEGIN {
	case 'a':
		break;
	case 'n':
		len = estrtonum(EARGF(usage()), 1, LLONG_MAX);
		break;
	case 't':
		format = estrdup("%8l#: ");
		f = *EARGF(usage());
		if (f == 'd' || f == 'o' || f == 'x')
			format[3] = f;
		else
			usage();
		break;
	default:
		usage();
	} ARGEND;

	if (!argc) {
		strings(stdin, "<stdin>", len);
	} else {
		for (; *argv; argc--, argv++) {
			if (!strcmp(*argv, "-")) {
				*argv = "<stdin>";
				fp = stdin;
			} else if (!(fp = fopen(*argv, "r"))) {
				weprintf("fopen %s:", *argv);
				ret = 1;
				continue;
			}
			strings(fp, *argv, len);
			if (fp != stdin && fshut(fp, *argv))
				ret = 1;
		}
	}

	ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");

	return ret;
}
Ejemplo n.º 6
0
//write document info, author, fullname, title, about
void Document::processAssociatedStrings()
{
    kDebug(30513) ;
    wvWare::AssociatedStrings strings(m_parser->associatedStrings());
    if (!strings.author().isNull()) {
        m_metaWriter->startElement("meta:initial-creator");
        m_metaWriter->addTextSpan(Conversion::string(strings.author()));
        m_metaWriter->endElement();
    }
    if (!strings.title().isNull()) {
        m_metaWriter->startElement("dc:title");
        m_metaWriter->addTextSpan(Conversion::string(strings.title()));
        m_metaWriter->endElement();
    }
    if (!strings.subject().isNull()) {
        m_metaWriter->startElement("dc:subject");
        m_metaWriter->addTextSpan(Conversion::string(strings.subject()));
        m_metaWriter->endElement();
    }
    if (!strings.lastRevBy().isNull()) {
        m_metaWriter->startElement("dc:creator");
        m_metaWriter->addTextSpan(Conversion::string(strings.lastRevBy()));
        m_metaWriter->endElement();
    }
}
Ejemplo n.º 7
0
BOOST_LOG_EXPORT void basic_event_log_backend< CharT >::consume(record_type const& record)
{
    if (!m_pImpl->m_EventComposer.empty())
    {
        log::aux::cleanup_guard< insertion_list > cleaner(m_pImpl->m_Insertions);

        // Get event ID and construct insertions
        DWORD id = m_pImpl->m_EventComposer(record, m_pImpl->m_Insertions);
        WORD string_count = static_cast< WORD >(m_pImpl->m_Insertions.size());
        scoped_array< const char_type* > strings(new const char_type*[string_count]);
        for (WORD i = 0; i < string_count; ++i)
            strings[i] = m_pImpl->m_Insertions[i].c_str();

        // Get event type
        WORD event_type = EVENTLOG_INFORMATION_TYPE;
        if (!m_pImpl->m_LevelMapper.empty())
            event_type = static_cast< WORD >(m_pImpl->m_LevelMapper(record));

        WORD event_category = 0;
        if (!m_pImpl->m_CategoryMapper.empty())
            event_category = static_cast< WORD >(m_pImpl->m_CategoryMapper(record));

        report_event(
            m_pImpl->m_SourceHandle,       // Event log handle.
            event_type,                    // Event type.
            event_category,                // Event category.
            id,                            // Event identifier.
            NULL,                          // No user security identifier.
            string_count,                  // Number of substitution strings.
            0,                             // No data.
            strings.get(),                 // Pointer to strings.
            NULL);                         // No data.
    }
}
Ejemplo n.º 8
0
String DebriefingScreen::build_score_text(
        game_ticks your_time, game_ticks par_time, int your_loss, int par_loss, int your_kill,
        int par_kill) {
    Resource rsrc("text", "txt", 6000);
    String   text(utf8::decode(rsrc.data()));

    StringList strings(6000);

    const int your_mins  = duration_cast<secs>(your_time.time_since_epoch()).count() / 60;
    const int your_secs  = duration_cast<secs>(your_time.time_since_epoch()).count() % 60;
    const int par_mins   = duration_cast<secs>(par_time.time_since_epoch()).count() / 60;
    const int par_secs   = duration_cast<secs>(par_time.time_since_epoch()).count() % 60;
    const int your_score = score(your_time, par_time, your_loss, par_loss, your_kill, par_kill);
    const int par_score  = 100;

    string_replace(&text, strings.at(0), your_mins);
    string_replace(&text, strings.at(1), dec(your_secs, 2));
    if (par_time > game_ticks()) {
        string_replace(&text, strings.at(2), par_mins);
        String secs_string;
        print(secs_string, format(":{0}", dec(par_secs, 2)));
        string_replace(&text, strings.at(3), secs_string);
    } else {
        StringList data_strings(6002);
        string_replace(&text, strings.at(2), data_strings.at(8));  // = "N/A"
        string_replace(&text, strings.at(3), "");
    }
    string_replace(&text, strings.at(4), your_loss);
    string_replace(&text, strings.at(5), par_loss);
    string_replace(&text, strings.at(6), your_kill);
    string_replace(&text, strings.at(7), par_kill);
    string_replace(&text, strings.at(8), your_score);
    string_replace(&text, strings.at(9), par_score);
    return text;
}
Ejemplo n.º 9
0
void Highlighter::highlightPythonBlock(const QString &text)
{
	QRegExp expression("\\b+\\w\\b+");
	int index = text.indexOf(expression, 0);
	for (int i = 0; i < keywords.size(); i++) {
		QRegExp expression("\\b+" + keywords[i] + "\\b+");
		int index = text.indexOf(expression);
		while (index >= 0) {
			int length = expression.matchedLength();
			setFormat(index, length, keywordFormat);
			index = text.indexOf(expression, index + length);
		}
	}
	QRegExp strings( QRegExp("\"[^\"]*\""));
	index = text.indexOf(strings);
	while (index >= 0) {
		int length = strings.matchedLength();
		setFormat(index, length, quotationFormat);
		index = text.indexOf(strings, index + length);
	}
	strings = QRegExp("'[^'']*'");
	index = text.indexOf(strings);
	while (index >= 0) {
		int length = strings.matchedLength();
		setFormat(index, length, quotationFormat);
		index = text.indexOf(strings, index + length);
	}
	QRegExp expComment("#.*");
	index = text.indexOf(expComment);
	while (index >= 0) {
		int length = expComment.matchedLength();
		setFormat(index, length, singleLineCommentFormat);
		index = text.indexOf(expComment, index + length);
	}
}
Ejemplo n.º 10
0
int
main(int argc, char **argv)
{
	int ch, err;
	
	ErrorSetProgramName("strings");

	while ((ch = getopt(argc, argv, "n:")) != -1) {
		switch (ch) {
		case 'n':
			minStringLength = strtol(optarg, (char **) 0, 10);
			break;			
		default:
			UsagePrintLine("usage: strings [-n min.length] files...\n");
		}
	}
	
	argc -= optind;
	argv += optind;

	for (err = 0; 0 < argc; --argc, ++argv) {
		if (strings(*argv))
			err = 1;
	}

	return err;
}
Ejemplo n.º 11
0
void
nsDirectoryService::RegisterCategoryProviders()
{
    nsCOMPtr<nsICategoryManager> catman
        (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
    if (!catman)
        return;

    nsCOMPtr<nsISimpleEnumerator> entries;
    catman->EnumerateCategory(XPCOM_DIRECTORY_PROVIDER_CATEGORY,
                              getter_AddRefs(entries));

    nsCOMPtr<nsIUTF8StringEnumerator> strings(do_QueryInterface(entries));
    if (!strings)
        return;

    bool more;
    while (NS_SUCCEEDED(strings->HasMore(&more)) && more) {
        nsCAutoString entry;
        strings->GetNext(entry);

        nsXPIDLCString contractID;
        catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));

        if (contractID) {
            nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());
            if (provider)
                RegisterProvider(provider);
        }
    }
}
Ejemplo n.º 12
0
QByteArray IndexedString::byteArray() const {
  if(!m_index)
    return QByteArray();
  else if((m_index & 0xffff0000) == 0xffff0000)
    return QString(QChar((char)m_index & 0xff)).toUtf8();
  else
    return strings()->at(m_index).toUtf8(); /*arrayFromItem(globalIndexedStringRepository->itemFromIndex(m_index));*/
}
Ejemplo n.º 13
0
int IndexedString::length() const {
  if(!m_index)
    return 0;
  else if((m_index & 0xffff0000) == 0xffff0000)
    return 1;
  else
    return strings()->at(m_index).length(); /*globalIndexedStringRepository->itemFromIndex(m_index)->length;*/
}
Ejemplo n.º 14
0
QString IndexedString::str() const {
  if(!m_index)
    return QString();
  else if((m_index & 0xffff0000) == 0xffff0000)
    return QString(QChar((char)m_index & 0xff));
  else
    return strings()->at(m_index); /*stringFromItem(globalIndexedStringRepository->itemFromIndex(m_index));*/
}
Ejemplo n.º 15
0
// returns the index of the string, or -1 on failure
int SearchableCharPool::find (char const* string) const {
   for (unsigned i=0; i<strings(); ++i) {
      if (strcmp(string, getString(i)) == 0) {
         return i;
      }
   }
   return -1;
}
std::vector<std::string> CARCONTROLMAP_LOCAL::InitCarInputStrings()
{
	std::vector<std::string> strings(CARINPUT::INVALID);
	strings[CARINPUT::THROTTLE] = "gas";
	strings[CARINPUT::NOS] = "nos";
	strings[CARINPUT::BRAKE] = "brake";
	strings[CARINPUT::HANDBRAKE] = "handbrake";
	strings[CARINPUT::CLUTCH] = "clutch";
	strings[CARINPUT::STEER_LEFT] = "steer_left";
	strings[CARINPUT::STEER_RIGHT] = "steer_right";
	strings[CARINPUT::SHIFT_UP] = "disengage_shift_up";
	strings[CARINPUT::SHIFT_DOWN] = "disengage_shift_down";
	strings[CARINPUT::START_ENGINE] = "start_engine";
	strings[CARINPUT::ABS_TOGGLE] = "abs_toggle";
	strings[CARINPUT::TCS_TOGGLE] = "tcs_toggle";
	strings[CARINPUT::NEUTRAL] = "neutral";
	strings[CARINPUT::FIRST_GEAR] = "first_gear";
	strings[CARINPUT::SECOND_GEAR] = "second_gear";
	strings[CARINPUT::THIRD_GEAR] = "third_gear";
	strings[CARINPUT::FOURTH_GEAR] = "fourth_gear";
	strings[CARINPUT::FIFTH_GEAR] = "fifth_gear";
	strings[CARINPUT::SIXTH_GEAR] = "sixth_gear";
	strings[CARINPUT::REVERSE] = "reverse";
	strings[CARINPUT::ROLLOVER_RECOVER] = "rollover_recover";
	strings[CARINPUT::VIEW_REAR] = "rear_view";
	strings[CARINPUT::VIEW_PREV] = "view_prev";
	strings[CARINPUT::VIEW_NEXT] = "view_next";
	strings[CARINPUT::VIEW_HOOD] = "view_hood";
	strings[CARINPUT::VIEW_INCAR] = "view_incar";
	strings[CARINPUT::VIEW_CHASERIGID] = "view_chaserigid";
	strings[CARINPUT::VIEW_CHASE] = "view_chase";
	strings[CARINPUT::VIEW_ORBIT] = "view_orbit";
	strings[CARINPUT::VIEW_FREE] = "view_free";
	strings[CARINPUT::FOCUS_PREV] = "focus_prev_car";
	strings[CARINPUT::FOCUS_NEXT] = "focus_next_car";
	strings[CARINPUT::PAN_LEFT] = "pan_left";
	strings[CARINPUT::PAN_RIGHT] = "pan_right";
	strings[CARINPUT::PAN_UP] = "pan_up";
	strings[CARINPUT::PAN_DOWN] = "pan_down";
	strings[CARINPUT::ZOOM_IN] = "zoom_in";
	strings[CARINPUT::ZOOM_OUT] = "zoom_out";
	strings[CARINPUT::REPLAY_FF] = "replay_ff";
	strings[CARINPUT::REPLAY_RW] = "replay_rw";
	strings[CARINPUT::SCREENSHOT] = "screen_shot";
	strings[CARINPUT::PAUSE] = "pause";
	strings[CARINPUT::RELOAD_SHADERS] = "reload_shaders";
	strings[CARINPUT::RELOAD_GUI] = "reload_gui";
	strings[CARINPUT::GUI_LEFT] = "gui_left";
	strings[CARINPUT::GUI_RIGHT] = "gui_right";
	strings[CARINPUT::GUI_UP] = "gui_up";
	strings[CARINPUT::GUI_DOWN] = "gui_down";
	strings[CARINPUT::GUI_SELECT] = "gui_select";
	strings[CARINPUT::GUI_CANCEL] = "gui_cancel";
	return strings;
}
Ejemplo n.º 17
0
std::string CompositeStringSource::string() const
{
    std::stringstream source;

    for (const std::string & str : strings())
    {
        source << str << std::endl;
    }

    return source.str();
}
Ejemplo n.º 18
0
/*
 * Silently accepts the -a option
 */
int main(int argc, char **argv)
{
  if (argc > 1) {
    int i;
    for (i = 1; i < argc; i++) {
      FILE *pf;
      if (strcmp(argv[i], "-a") == 0) continue;

      if ((pf = fopen(argv[i],"rb")) == NULL) {
        perror("fopen");
        return(1);
      }
      strings(pf);
    }
  }
  else {
    strings(stdin);
  }
  return(0);
}
Ejemplo n.º 19
0
std::string VM::msgMessage(int msg_file_num, int msg_num)
{
    auto lst = ResourceManager::getInstance()->lstFileType("scripts/scripts.lst");
    auto scriptName = lst->strings()->at(msg_file_num - 1);
    auto msg = ResourceManager::getInstance()->msgFileType("text/english/dialog/" + scriptName.substr(0, scriptName.find(".int")).append(".msg"));
    if (!msg)
    {
        Logger::debug("SCRIPT") << "VM::msgMessage(file, num) not found. file: " + std::to_string(msg_file_num) + " num: " + std::to_string(msg_num) << std::endl;
        return "";
    }
    return msg->message(msg_num)->text();
}
Ejemplo n.º 20
0
void test_lazy_string_memory_intensive()
{
    lazy::lazy_string str_src("foobar");
    std::vector<lazy::lazy_string> strings(10000, str_src);
    str_src.set_at(2, '0');
    for (lazy::lazy_string &str : strings)
    {
        std::cout << str << std::endl;
    }
    std::cout << (str_src + str_src) << std::endl;
    std::cout << (str_src = "assign my rvalue!") << std::endl;
    std::cout << (str_src = str_src) << std::endl;
}
  std::vector<std::string> get_string_vector(std::string const& setting)
  {
    std::vector<std::string> vector;

    std::unique_ptr<gchar*[], void(*)(gchar**)> strings(g_settings_get_strv(settings_, setting.c_str()), g_strfreev);

    for (int i = 0; strings[i]; ++i)
    { 
      std::string value = strings[i];

      if (!value.empty())
        vector.push_back(value);
    }
    return vector;
  }
Ejemplo n.º 22
0
/*! @brief Takes in an action and returns an array of strings describing the state of the simulation before the action.

    This function formats the members of the passed action - xrot, yrot, zrot, scale, and frame.
    It then puts them in a string array "strings" and returns it.

*/
std::vector<QString> getStateStrings(Action action) {
    QString x, y, z, sc, fr;
    x = QString::number(action.xrot, 'f', 2);
    y = QString::number(action.yrot, 'f', 2);
    z = QString::number(action.zrot, 'f', 2);
    sc = QString::number(action.scale, 'f', 2);
    fr = QString::number(action.frame);
    std::vector<QString> strings (5);
    strings[0] = x;
    strings[1] = y;
    strings[2] = z;
    strings[3] = sc;
    strings[4] = fr;
    return strings;
}
Ejemplo n.º 23
0
LoadingScreen::LoadingScreen(Handle<Level> level, bool* cancelled)
        : InterfaceScreen("loading", {0, 0, 640, 480}, true),
          _state(TYPING),
          _level(level),
          _cancelled(cancelled),
          _next_update(now() + kTypingDelay),
          _chars_typed(0),
          _current(0),
          _max(1) {
    StringList strings(kLevelNameID);
    _name_text.reset(new StyledText(sys.fonts.title));
    _name_text->set_fore_color(GetRGBTranslateColorShade(PALE_GREEN, VERY_LIGHT));
    _name_text->set_retro_text(strings.at(_level->levelNameStrNum - 1));
    _name_text->set_tab_width(220);
    _name_text->wrap_to(640, 0, 2);
}
RCP<ParameterEntryValidator> StringValidatorXMLConverter::convertXML(
  const XMLObject& xmlObj,
  const IDtoValidatorMap& /*validatorIDsMap*/) const
{
  Array<std::string> strings(xmlObj.numChildren());
  if(xmlObj.numChildren()!=0){
    for(int i=0; i<xmlObj.numChildren(); ++i){
      XMLObject currentChild = xmlObj.getChild(i);
      TEUCHOS_TEST_FOR_EXCEPTION(currentChild.getTag() != getStringTagName(), 
        BadTagException,  
        "Error converting xmlObject to StringValidator." << std::endl << 
		    "Unrecognized tag: " << currentChild.getTag());
        strings[i] = (currentChild.getRequired(getStringValueAttributeName()));
    }
  }
  return rcp(new StringValidator(strings));
}
Ejemplo n.º 25
0
void
GMMIMEParser::ParseContentDisposition
	(
	const JString&	val,
	GMIMEHeader*	header
	)
{
	// we first need to strip the type. this will be found before the
	// first ';' which will be followed by the parameters.
	JString tVal	= val;
	tVal.TrimWhitespace();
	JSize length	= tVal.GetLength();

	JIndex findex;
	if (tVal.LocateSubstring(";", &findex) && (findex > 1))
		{
		tVal.RemoveSubstring(1, findex);
		tVal.TrimWhitespace();
		}
	else
		{
		return;
		}

	JPtrArray<JString> strings(JPtrArrayT::kDeleteAll);
	ParseContentParameters(tVal, &strings);
	JSize count = strings.GetElementCount();
	for (JIndex i = 1; i <= count; i += 2)
		{
		JString* str = strings.NthElement(i);
		if ((*str == "filename") &&
			(strings.IndexValid(i+1)))
			{
			str	= strings.NthElement(i+1);
			if (str->LocateLastSubstring("/", &findex))
				{
				str->RemoveSubstring(1, findex);
				}
			if (str->LocateLastSubstring("\\", &findex))
				{
				str->RemoveSubstring(1, findex);
				}
			header->SetFileName(*str);
			}
		}
}
Ejemplo n.º 26
0
int main(int ac, char* av[])
{
    cpu::tube::context context(CPUTUBE_CONTEXT_ARGS(ac, av));
    int size(ac == 1? 0: atoi(av[1]));
    int const max = 100000;
    std::vector<string_type> strings(make_strings(2 * (size? size: max * 20)));
    if (size) {
        run_tests(context, size, strings);
    }
    else {
        for (int i(10); i <= max; i *= 10) {
            for (int j(1); j < 10; j *= 2) {
                run_tests(context, i * j, strings);
            }
        }
    }
}
Ejemplo n.º 27
0
void initialize(FILE *fp) {
	//Header
	header(fp);
	//Strings array
	strings(fp);
	//Types array
	types(fp);
	//Fields
	fields(fp);
	//Prototypes array
	protos(fp);
	//Methods
	methods(fp);
	//Class Data array
	class_defs(fp);
	//Class Data Item array
	class_data_item(fp);
	//Code Item
	code_item(fp);
}
Ejemplo n.º 28
0
/* strings main: find printable strings in files */
int main(int argc, char *argv[])
{
	int i;
	FILE *fin;

	setprogname("strings");
	if (argc == 1)
		eprintf("usage: strings filenames");
	else {
		for (i = 1; i < argc; i++) {
			if ((fin = fopen(argv[i], "rb")) == NULL)
				weprintf("can't open %s:", argv[i]);
			else {
				strings(argv[i], fin);
				fclose(fin);
			}
		}
	}
	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "max (1,2) is " << max(1,2) << std::endl;
    std::cout << "max (4,3) is " << max(4,3) << std::endl;
    std::cout << "max (5,6) is " << max(5,6) << std::endl;

    // use a called out specialization..  this requires the use of a specific
    // implementation when things may be ambiguous..
    std::cout << "max (33,2.0) is " << max<double>(33,2.0) << std::endl;


    // use our class template
    Accum<int> integers(0);

    integers += 3;
    integers += 7;
    std::cout << integers.GetTotal() << std::endl;

    Accum<std::string> strings("");

    strings += "hello";
    strings += " ";
    strings += "world";
    std::cout << strings.GetTotal()  << std::endl;

    //integers += "testing";
    //strings += 4;

    Accum<Something> somethings(0);

    Something some1(55);
    Something some2(66);

    somethings += some1;
    somethings += some2;

    std::cout << somethings.GetTotal() << std::endl;


	return 0;
}
Ejemplo n.º 30
0
    AcqusHandler::AcqusHandler(const String & filename)
    {
      params_.clear();

      std::ifstream is(filename.c_str());
      if (!is)
      {
        throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
      }

      //temporary variables
      String line;
      std::vector<String> strings(2);

      //read lines
      while (getline(is, line, '\n'))
      {
        if (line.size() < 5)
          continue;                    // minimal string = "##x=x"
        if (line.prefix(2) != String("##"))
          continue;

        if (line.split('=', strings))
        {
          if (strings.size() == 2)
          {
            params_[strings[0].substr(2)] = strings[1].trim();
          }
        }
      }

      // TOF calibration params
      dw_ = params_[String("$DW")].toDouble();
      delay_ = (Size)params_[String("$DELAY")].toInt();
      ml1_ = params_[String("$ML1")].toDouble();
      ml2_ = params_[String("$ML2")].toDouble();
      ml3_ = params_[String("$ML3")].toDouble();
      td_ = (Size) params_[String("$TD")].toInt();

      is.close();
    }