// -----------------------------------------------------------------------------
// CG711DecoderIntfcTestClass::EventName
// Return descriptor with the notification description
// -----------------------------------------------------------------------------
TPtrC CG711DecoderIntfcTestClass::EventName( TInt aKey )
{
	static TText* const badKeyword = (TText*)L"BadKeyword";
	static TText* const keywords[] =
		{

		(TText*)L"EInitializeComplete",
		(TText*)L"EMaoscOpenComplete",

		};



	if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) )
		{
		iLog->Log(_L("Keyword out of bounds"));
		TPtrC keyword( badKeyword );
		return keyword;
		}
	else
		{
		TPtrC keyword( keywords[aKey] );
		return keyword;
		}
}
Esempio n. 2
0
void Parser::keywordMessage(MethodGenerationContext* mgenc, bool super) {
    StdString kw = keyword();
    
    // special compilation for ifTrue and ifFalse
    if (!super && kw == "ifTrue:") {
        ifTrueMessage(mgenc);
        return;
    } else if (!super && kw == "ifFalse:") {
        ifFalseMessage(mgenc);
        return;
    }
    formula(mgenc);
    while (sym == Keyword) {
        kw.append(keyword());
        formula(mgenc);
    }

    VMSymbol* msg = GetUniverse()->SymbolFor(kw);

    mgenc->AddLiteralIfAbsent(msg);

    if (super)
        bcGen->EmitSUPERSEND(mgenc, msg);
    else
        bcGen->EmitSEND(mgenc, msg);

}
Esempio n. 3
0
ECLFilesComparator::ECLFilesComparator(int file_type, const std::string& basename1, const std::string& basename2, double absTolerance, double relTolerance):
    file_type(file_type), absTolerance(absTolerance), relTolerance(relTolerance) {

    std::string file1, file2;
    if (file_type == ECL_UNIFIED_RESTART_FILE) {
        file1 = basename1 + ".UNRST";
        file2 = basename2 + ".UNRST";
    }
    else if (file_type == ECL_INIT_FILE) {
        file1 = basename1 + ".INIT";
        file2 = basename2 + ".INIT";
    }
    else if (file_type == ECL_RFT_FILE) {
        file1 = basename1 + ".RFT";
        file2 = basename2 + ".RFT";
    }
    else {
        OPM_THROW(std::invalid_argument, "Unsupported filetype sent to ECLFilesComparator's constructor."
                << "Only unified restart (.UNRST), initial (.INIT) and .RFT files are supported.");
    }
    ecl_file1 = ecl_file_open(file1.c_str(), 0);
    ecl_file2 = ecl_file_open(file2.c_str(), 0);
    ecl_grid1 = ecl_grid_load_case(basename1.c_str());
    ecl_grid2 = ecl_grid_load_case(basename2.c_str());
    if (ecl_file1 == nullptr) {
        OPM_THROW(std::invalid_argument, "Error opening first file: " << file1);
    }
    if (ecl_file2 == nullptr) {
        OPM_THROW(std::invalid_argument, "Error opening second file: " << file2);
    }
    if (ecl_grid1 == nullptr) {
        OPM_THROW(std::invalid_argument, "Error opening first grid file: " << basename1);
    }
    if (ecl_grid2 == nullptr) {
        OPM_THROW(std::invalid_argument, "Error opening second grid file. " << basename2);
    }
    unsigned int numKeywords1 = ecl_file_get_num_distinct_kw(ecl_file1);
    unsigned int numKeywords2 = ecl_file_get_num_distinct_kw(ecl_file2);
    keywords1.reserve(numKeywords1);
    keywords2.reserve(numKeywords2);
    for (unsigned int i = 0; i < numKeywords1; ++i) {
        std::string keyword(ecl_file_iget_distinct_kw(ecl_file1, i));
        keywords1.push_back(keyword);
    }
    for (unsigned int i = 0; i < numKeywords2; ++i) {
        std::string keyword(ecl_file_iget_distinct_kw(ecl_file2, i));
        keywords2.push_back(keyword);
    }
}
Esempio n. 4
0
 boost::shared_ptr<database::entities::CKeyword> CKeywordManager::createNumeric(const std::string & name)
 {
    boost::shared_ptr<database::entities::CKeyword> keyword(new database::entities::CKeyword());
    keyword->Name = name;
    keyword->Type = m_typeNumeric;
    return keyword;
 }
Esempio n. 5
0
KeywordP KeywordDataObject::getKeyword(const SetP& set) {
	KeywordP keyword(new Keyword());
	WrappedKeyword data = { set->game.get(), set->game->name(), keyword};
	deserialize_from_clipboard(data, *set, GetText());
	if (data.game_name != set->game->name()) return KeywordP(); // Keyword is from a different game
	else                                     return keyword;
}
void Foam::dictionaryEntry::write(Ostream& os) const
{
    // write keyword with indent but without trailing spaces
    os.indent();
    os.write(keyword());
    dictionary::write(os);
}
Esempio n. 7
0
void Parser::ifTrueMessage(MethodGenerationContext* mgenc) {
    size_t false_block_pos = bcGen->EmitJUMP_IF_FALSE(mgenc);
    if (sym == NewBlock) {
        inlinedBlock(mgenc);
    } else {
        formula(mgenc);
        VMSymbol* msg = GetUniverse()->SymbolFor("value");
        mgenc->AddLiteralIfAbsent(msg);
        bcGen->EmitSEND(mgenc, msg);
    }
    
    size_t after_pos = bcGen->EmitJUMP(mgenc);
    mgenc->PatchJumpTarget(false_block_pos);
    
    if (sym == Keyword) {
        StdString ifFalse = keyword();
        assert(ifFalse == "ifFalse:");
        if (sym == NewBlock) {
            inlinedBlock(mgenc);
        } else {
            formula(mgenc);
            VMSymbol* msg = GetUniverse()->SymbolFor("value");
            mgenc->AddLiteralIfAbsent(msg);
            bcGen->EmitSEND(mgenc, msg);
        }
    } else {
        VMSymbol* global = GetUniverse()->SymbolFor("nil");
        mgenc->AddLiteralIfAbsent(global);
        
        bcGen->EmitPUSHGLOBAL(mgenc, global);
    }
    mgenc->PatchJumpTarget(after_pos);
    
    assert(sym != Keyword);
}
Esempio n. 8
0
File: gram.c Progetto: joequant/iraf
/* If f is a valid parameter field spec, such as p_val, then overwrite *f
 *   with the proper FN_XXX character and return YES, else return NO.
 * Let the p_value field also be called p_filename, p_length and p_default.
 * Call error() if f starts with p_ but is not found or if ambiguous
 *   (and abbrevs are enabled).
 */
int 
fieldcvt (register char *f)
{
	/* Field name and corresponding code tables.
	 */
	static char *fntbl[] = {
	    "p_name", "p_type", "p_mode", "p_value", "p_minimum",
	    "p_maximum", "p_prompt", "p_filename", "p_length", "p_default",
	    "p_xtype", NULL
	};
	static char fctbl[] = {
	    FN_NAME, FN_TYPE, FN_MODE, FN_VALUE, FN_MIN,
	    FN_MAX, FN_PROMPT, FN_VALUE, FN_LENGTH, FN_VALUE,
	    FN_XTYPE, NULL
	};

	int kentry;

	/* Do a quick screening first. returning NO just means that f does
	 * not even look like a field name.
	 */
	if (strncmp (f, "p_", 2))
	    return (NO);

	kentry = keyword (fntbl, f);
	if (kentry == KWBAD)
	    cl_error (E_UERR, "bad param field `%s'", f);
	else if (kentry == KWAMBIG)
	    cl_error (E_UERR, "ambiguous param field `%s'", f);

	*f = fctbl[kentry];
	return (YES);
}
static void setSchemaColors(const ColorSchemeData& customSchema){
    QString dirPath = ColorSchemeUtils::getColorsDir();
    QDir dir(dirPath);
    if(!dir.exists()){
        dir.mkpath(dirPath);
    }

    IOAdapterFactory* factory = AppContext::getIOAdapterRegistry()->getIOAdapterFactoryById(BaseIOAdapters::LOCAL_FILE);

    QScopedPointer<IOAdapter> io(factory->createIOAdapter());

    const QMap<char, QColor> & alphColors = customSchema.alpColors;
    const QString& file  = customSchema.name + ColorSchemeUtils::COLOR_SCHEME_NAME_FILTERS;
    bool defaultType = customSchema.defaultAlpType;

    QString keyword(customSchema.type == DNAAlphabet_AMINO ? ColorSchemeUtils::COLOR_SCHEME_AMINO_KEYWORD : (defaultType ? ColorSchemeUtils::COLOR_SCHEME_NUCL_DEFAULT_KEYWORD : ColorSchemeUtils::COLOR_SCHEME_NUCL_EXTENDED_KEYWORD));

    io->open(dir.filePath(file), IOAdapterMode_Write);
    // write header
    QByteArray header;
    header.append(QString("%1\n").arg(keyword));
    io->writeBlock(header);
    // write body
    QMapIterator<char, QColor> it(alphColors);
    while(it.hasNext()){
        it.next();
        QByteArray line;
        line.append(QString("%1=%2\n").arg(it.key()).arg(it.value().name()));
        io->writeBlock(line);
    }
}
Esempio n. 10
0
bool PlainExpression::ParseItem(const std::string& item) {
  const char *ptr = NULL;
  ptr = strstr(item.c_str(), ">");
  if (ptr == NULL) return false;
  Slice keyword(item.c_str(), ptr);
  keyword.StrTrim(" ");
  if (keyword == "min_interval") {
    key_index_ = 0;
  } else if (keyword == "mid_interval") {
    key_index_ = 1;
  } else if (keyword == "max_interval") {
    key_index_ = 2;
  } else {
    gLog("[%s][%d]: wrong keyword %s, item %s\n",
        __FILE__, __LINE__, keyword.ToStr().c_str(), item.c_str());
    return false;
  }
  ptr++;
  if (*ptr == '=') {
    ptr++;
    cmp_ = GreaterOrEqual;
  } else {
    cmp_ = Greater;
  }

  if (*ptr == '\0') {
    gLog("[%s][%d]: wrong syntax item %s\n", __FILE__, __LINE__, item.c_str());
    return false;
  }
  threshold_ = strtoul(ptr, NULL, 10);
  return threshold_ > 0;
}
Esempio n. 11
0
ParsingResult<ast::Define *> Parser::define() {
  ParsingResult<ast::Define *> result;

  if (keyword("define")) {
    ParsingResult<ast::Type *> next_type = type_namespace();

    ParsingResult<ast::Signature *> next_signature = signature();
    if (!next_signature.ok) return result;

    if (!forward_if_next_is('{')) return result;

    ast::Code *next_code = code();

    if (!forward_if_next_is('}')) return result;

    ast::Define *define = new ast::Define;

    result.ok = true;
    result.result = define;

    if (next_type) define->on.reset(next_type.result);
    define->signature.reset(next_signature.result);
    define->code.reset(next_code);
  }

  return result;
}
Esempio n. 12
0
ParsingResult<ast::Return *> Parser::ret() {
  // save();

  ParsingResult<ast::Return *> result;

  if (keyword("return")) {
    ParsingResult<ast::Value *> next_value = value();
    if (next_value.ok) {
      skip();

      if (forward_if_next_is(';')) {
        //   valid();

        ast::Return *ret = new ast::Return;

        ret->value.reset(next_value.result);

        result.ok = true;
        result.result = ret;
      }
    }
  }

  //  if (!result.ok) restaure();

  return result;
}
Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
:
    entry(key),
    ITstream(tokens)
{
    name() += "::" + keyword();
}
Esempio n. 14
0
void Foam::primitiveEntry::readEntry(const dictionary& dict, Istream& is)
{
    label keywordLineNumber = is.lineNumber();
    tokenIndex() = 0;

    if (read(dict, is))
    {
        setSize(tokenIndex());
        tokenIndex() = 0;
    }
    else
    {
        std::ostringstream os;
        os  << "ill defined primitiveEntry starting at keyword '"
            << keyword() << '\''
            << " on line " << keywordLineNumber
            << " and ending at line " << is.lineNumber();

        SafeFatalIOErrorIn
        (
            "primitiveEntry::readEntry(const dictionary&, Istream&)",
            is,
            os.str()
        );
    }
}
Esempio n. 15
0
void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
{
    if (!contentsOnly)
    {
        os.writeKeyword(keyword());
    }

    for (label i=0; i<size(); ++i)
    {
        const token& t = operator[](i);
        if (t.type() == token::VERBATIMSTRING)
        {
            // Bypass token output operator to avoid losing verbatimness.
            // Handle in Ostreams themselves
            os.write(t);
        }
        else
        {
            os  << t;
        }

        if (i < size()-1)
        {
            os  << token::SPACE;
        }
    }

    if (!contentsOnly)
    {
        os  << token::END_STATEMENT << endl;
    }
}
Esempio n. 16
0
std::string
ConsiderFilter::str() const{
  if(__keyword.empty())return std::string("");
  std::string res = (__method == eConsider?"consider: ":"ignore: ");
  res += keyword();
  return res;
}	
Esempio n. 17
0
ECLFilesComparator::ECLFilesComparator(eclFileEnum fileType, const std::string& basename1, const std::string& basename2, double absTolerance, double relTolerance):
    fileType(fileType), absTolerance(absTolerance), relTolerance(relTolerance) {

    std::string file1, file2;
    if (fileType == RESTARTFILE) {
        file1 = basename1 + ".UNRST";
        file2 = basename2 + ".UNRST";
    }
    else if (fileType == INITFILE) {
        file1 = basename1 + ".INIT";
        file2 = basename2 + ".INIT";
    }

    ecl_file1 = ecl_file_open(file1.c_str(), 0);
    ecl_file2 = ecl_file_open(file2.c_str(), 0);
    ecl_grid1 = ecl_grid_load_case(basename1.c_str());
    ecl_grid2 = ecl_grid_load_case(basename2.c_str());

    if (ecl_file1 == nullptr) {
        std::cout << "Tried to open: " << file1 << std::endl;
        OPM_THROW(std::runtime_error, "Error opening first file.");
    }
    if (ecl_file2 == nullptr) {
        std::cout << "Tried to open: " << file2 << std::endl;
        OPM_THROW(std::runtime_error, "Error opening second file.");
    }
    if (ecl_grid1 == nullptr) {
        std::cout << "Tried to open: " << basename1 + ".EGRID" << std::endl;
        OPM_THROW(std::runtime_error, "Error opening first file.");
    }
    if (ecl_grid2 == nullptr) {
        std::cout << "Tried to open: " << basename2 + ".EGRID" << std::endl;
        OPM_THROW(std::runtime_error, "Error opening second file.");
    }

    unsigned int numKeywords1 = ecl_file_get_num_distinct_kw(ecl_file1);
    unsigned int numKeywords2 = ecl_file_get_num_distinct_kw(ecl_file2);
    for (unsigned int i = 0; i < numKeywords1; ++i) {
        std::string keyword(ecl_file_iget_distinct_kw(ecl_file1, i));
        keywords1.push_back(keyword);
    }
    for (unsigned int i = 0; i < numKeywords2; ++i) {
        std::string keyword(ecl_file_iget_distinct_kw(ecl_file2, i));
        keywords2.push_back(keyword);
    }
}
Esempio n. 18
0
 boost::shared_ptr<database::entities::CKeyword> CKeywordManager::createEnumeration(const std::string & name, const std::string & enumValues)
 {
    boost::shared_ptr<database::entities::CKeyword> keyword(new database::entities::CKeyword());
    keyword->Name = name;
    keyword->Type = m_typeEnumeration;
    keyword->Parameters = enumValues;
    return keyword;
 }
Esempio n. 19
0
 boost::shared_ptr<database::entities::CKeyword> CKeywordManager::createNumeric(const std::string & name, double min, double max)
 {
    boost::shared_ptr<database::entities::CKeyword> keyword(new database::entities::CKeyword());
    keyword->Name = name;
    keyword->Type = m_typeNumeric;
    keyword->Minimum = min;
    keyword->Maximum = max;
    return keyword;
 }
Esempio n. 20
0
StringParsingResult Parser::module() {
  StringParsingResult result;

  if (keyword("module")) {
    result = identifier();
  }

  return result;
}
Esempio n. 21
0
 boost::shared_ptr<database::entities::CKeyword> CKeywordManager::createNumeric(const std::string & name, const std::string & units)
 {
    boost::shared_ptr<database::entities::CKeyword> keyword(new database::entities::CKeyword());
    keyword->Name = name;
    keyword->Type = m_typeNumeric;
    if(!units.empty())
       keyword->Units = units;
    return keyword;
 }
Esempio n. 22
0
void Parser::keywordPattern(MethodGenerationContext* mgenc) {
    StdString kw;
    do {
        kw.append(keyword());
        mgenc->AddArgumentIfAbsent(argument());
    } while (sym == Keyword);

    mgenc->SetSignature(GetUniverse()->SymbolFor(kw));
}
Esempio n. 23
0
static void test_parse_maketemp(CuTest *tc) {
    char cmd[32];
    order *ord;
    struct locale * lang = get_or_create_locale("en");

    locale_setstring(lang, keyword(K_MAKE), "MAKE");
    locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
    locale_setstring(lang, "TEMP", "TEMP");
    init_locale(lang);

    ord = parse_order("MAKET herp", lang);
    CuAssertPtrNotNull(tc, ord);
    CuAssertStrEquals(tc, "MAKETEMP herp", get_command(ord, cmd, sizeof(cmd)));
    CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord));
    CuAssertIntEquals(tc, K_MAKETEMP, init_order(ord));
    CuAssertStrEquals(tc, "herp", getstrtoken());
    free_order(ord);
}
/**
 * \brief Factory method to create metavalues with the right comments
 */
Metavalue	FITSKeywords::meta(const std::string& name,
			const std::string& value, const std::string& comment) {
	FITSKeyword	k = keyword(name);
	if (k.index == std::type_index(typeid(void))) {
		return Metavalue(name, k.index, "", value);
	} else {
		return Metavalue(name, k.index, value,
			(comment.size() == 0) ? k.comment : comment);
	}
}
Esempio n. 25
0
void TemplatePongo::match_workplace(Data& entry,const string& str){
	string keyword("工作地点:");
	std::size_t i =str.find(keyword);
	if (i != string::npos) {
		i += (keyword.length());
		int j = str.find_first_of(" ", i);
		string r = str.substr(i, j - i);
		int len = r.length();
		entry.workplace = new char[len + 1];
		strcpy(entry.workplace, r.c_str());
	}
}
Esempio n. 26
0
File: gram.c Progetto: joequant/iraf
/* Given a, possibly abbreviated, function name to run, look it up and
 * run it if found. it gets nargs arguments from the operand stack.
 */
void 
intrfunc (char *fname, int nargs)
{
	int	op_index, op;
	int	i, n, subi[2];
	int	trim_side = TRIM_LEFT|TRIM_RIGHT;
	char	*trim = " \t";
	char	sbuf[SZ_LINE+1];
	struct	operand o;


	op_index = keyword (ifnames, fname);
	if (op_index == KWBAD)
	    cl_error (E_UERR, "unknown function `%s'", fname);
	if (op_index == KWAMBIG)
	    cl_error (E_UERR, "ambiguous function `%s'", fname);

	op = optbl[op_index];

	/* if do this by shifting the cases and op to the right OP_BITS, this
	 * will compile as a jump table. not worth it until it gets larger.
	 */
	switch (op & ~OP_MASK) {
	case UNOP:
	    if (nargs != 1)
		cl_error (E_UERR, e_onearg, ifnames[op_index]);
	    unop (op & OP_MASK);
	    break;

	case BINOP:
	    if (nargs != 2)
		cl_error (E_UERR, e_twoargs, ifnames[op_index]);
	    binop (op & OP_MASK);
	    break;

	case MULTOP:
            multop (op & OP_MASK, op_index, nargs);
	    break;

        case VOCOP:
            vocop (op & OP_MASK, op_index, nargs);
            break;

        case SAMPOP:
            sampop (op & OP_MASK, op_index, nargs);
            break;

	default:
err:	    cl_error (E_IERR, e_badsw, op, "intrfunc()");
	}
}
Esempio n. 27
0
	void _read(const std::string name, _branch *branch, int depth = 0) throw(std::exception) {
		if(depth > 16) {
			throw exception("include depth > 16, possibly recursion occured");
		}
		branch->name = name;
		for(const std::string &n : _ignore) {
			if(n == name) {
				return;
			}
		}
		
		std::ifstream file;
		
		// try open file in each dir
		std::string fullname;
		for(const std::string &dir : _dirs) {
			fullname = dir + "/" + name;
			file.open(fullname);
			if(file) {
				break;
			}
		}
		if(!file) {
			throw exception("cannot open file '" + name + "'");
		}
		branch->fullname = fullname;
		
		// read file line by line
		std::string line;
		std::smatch match;
		std::regex include("^[ \t]*#include[ ]*[\"<]([^ ]*)[\">]"), pragma("^[  \t]*#pragma[ ]*([^ \t\n]*)");
		while(std::getline(file, line)) {
			if(std::regex_search(line, match, include)) {
				_branch *b = branch->add(branch->pos + branch->size);
				_read(std::string(match[1]), b, depth + 1);
				branch->size += b->size;
			} else if(std::regex_search(line, match, pragma)) {
				std::string keyword(match[1]);
				if(keyword == "omit") {
					break;
				} else if(keyword == "once") {
					_ignore.push_back(name);
				}
			} else {
				_data += line;
			}
			_data += "\n";
			branch->size += 1;
			branch->lsize += 1;
		}
	}
vector<pair<string, string>> ForwardSearchFifoQueue::push(string topItem) {
    vector<pair<string, string>> searchResults;
    queue1.pop_back();
    queue1.push_front(topItem);
    //if right item is a keyword
    if (keyword(topItem)) {
        for(int i=0; i< queue1.size(); i++) {
            //if left item is the other keyword
            if (otherKeyWord(queue1[i], topItem)) {
                searchResults.push_back((make_pair(queue1[i],topItem)));
            }
        }
    }
    return searchResults;
}
Esempio n. 29
0
/**
    NOME2 = KEYWORD NOME1?
*/
int nome2(const char* schema, int offset, dynamic_str_t* fissi, dynamic_str_t*
        keywords) {
    int ret = keyword(schema, offset, keywords);
    if (ret == -1)
        return -1;
    if (fissi)
        if (!fissi->size)
            append_str(fissi, "");  // patch per "fake" fisso, per fare iniziare sempre con fissi
    int ret2 = nome1(schema, ret, fissi, keywords);
    if (ret2 == -1) {
        // TODO: rimuovere da fissi e da keywords gli ultimi elementi
        return ret;
    }
    return ret2;
}
Esempio n. 30
0
void SSE::getKeywords(byte docBytes[], size_t size, unordered_set<string, stringhash>& keywords){
	clock_t startTime = clock();
	string content(reinterpret_cast<char*>(docBytes), size);
//	cout << "Content is " << content << endl;
	boost::tokenizer<> tok(content);

	tok.assign(content.begin(), content.end());
	for(boost::tokenizer<>::iterator it = tok.begin(); it != tok.end(); ++it){
		string keyword(*it);
		std::transform(keyword.begin(), keyword.end(), keyword.begin(), ::tolower);
		keywords.insert(keyword);
	}
	cout << "Number of keywords " << keywords.size() << endl; 
	cout << "Keyword generation took " << ((double)(clock() - startTime)/(double)CLOCKS_PER_SEC) << endl;;
}