Esempio n. 1
0
 public slot_option option(string name)
 {
     if (!string.IsNullOrEmpty(name))
     {
         return(m_options.find(name));
     }
     return(null);
 }
Esempio n. 2
0
        // immdediately call a notifier for all outputs
        //template <typename T> void notify_all(T &&notifier) const
        //{
        //    for (auto const &item : m_itemtable)
        //        notifier(item.second.name().c_str(), item.second.get());
        //}


        // map a name to a unique ID
        //u32 name_to_id(const char *outname);


        // map a unique ID back to a name
        //const char *id_to_name(u32 id);


        /*-------------------------------------------------
        *   find_item - find an item based on a string
        *  -------------------------------------------------*/
        output_item find_item(string str)
        {
            var item = m_itemtable.find(str);

            if (item != null)
            {
                return(item);
            }

            return(null);
        }
Esempio n. 3
0
        public entry get_entry(string name)
        {
            var curentry = m_entrymap.find(name);

            return((curentry != null) ? curentry : null);
        }
Esempio n. 4
0
        ptokenizer_token_t get_token_internal()
        {
            // skip ws
            char c = getc();                     //pstring::value_type c = getc();

            while (m_whitespace.find(c) != npos) //while (m_whitespace.find(c) != pstring::npos)
            {
                c = getc();
                if (eof())
                {
                    return(new ptokenizer_token_t(ptokenizer_token_type.ENDOFFILE));
                }
            }

            if (m_support_line_markers && c == '#')
            {
                string lm = "#";
                do
                {
                    c = getc();
                    if (eof())
                    {
                        return(new ptokenizer_token_t(ptokenizer_token_type.ENDOFFILE));
                    }

                    if (c == '\r' || c == '\n')
                    {
                        return(new ptokenizer_token_t(ptokenizer_token_type.LINEMARKER, lm));
                    }

                    lm += c;
                } while (true);
            }

            if (m_number_chars_start.find(c) != npos)  //if (m_number_chars_start.find(c) != pstring::npos)
            {
                // read number while we receive number or identifier chars
                // treat it as an identifier when there are identifier chars in it
                ptokenizer_token_type ret = ptokenizer_token_type.NUMBER;
                string tokstr             = "";
                while (true)
                {
                    if (m_identifier_chars.find(c) != npos && m_number_chars.find(c) == npos)  //if (m_identifier_chars.find(c) != pstring::npos && m_number_chars.find(c) == pstring::npos)
                    {
                        ret = ptokenizer_token_type.IDENTIFIER;
                    }
                    else if (m_number_chars.find(c) == npos)  //else if (m_number_chars.find(c) == pstring::npos)
                    {
                        break;
                    }

                    tokstr += c;
                    c       = getc();
                }

                ungetc(c);
                return(new ptokenizer_token_t(ret, tokstr));
            }

            // not a number, try identifier
            if (m_identifier_chars.find(c) != npos)  //if (m_identifier_chars.find(c) != pstring::npos)
            {
                // read identifier till non identifier char
                string tokstr = "";
                while (m_identifier_chars.find(c) != npos)  //while (m_identifier_chars.find(c) != pstring::npos)
                {
                    tokstr += c;
                    c       = getc();
                }

                ungetc(c);
                var id = m_tokens.find(tokstr);
                return((id != default) ?
                       new ptokenizer_token_t(id, tokstr)
                    :   new ptokenizer_token_t(ptokenizer_token_type.IDENTIFIER, tokstr));
            }

            if (c == m_string)
            {
                string tokstr = "";
                c = getc();
                while (c != m_string)
                {
                    tokstr += c;
                    c       = getc();
                }

                return(new ptokenizer_token_t(ptokenizer_token_type.STRING, tokstr));
            }
            else
            {
                // read identifier till first identifier char or ws
                string tokstr = "";
                while ((m_identifier_chars.find(c) == npos) && (m_whitespace.find(c) == npos))  //while ((m_identifier_chars.find(c) == pstring::npos) && (m_whitespace.find(c) == pstring::npos))
                {
                    tokstr += c;
                    // expensive, check for single char tokens
                    if (tokstr.length() == 1)
                    {
                        var id = m_tokens.find(tokstr);
                        if (id != default)
                        {
                            return(new ptokenizer_token_t(id, tokstr));
                        }
                    }

                    c = getc();
                }

                {
                    ungetc(c);
                    var id = m_tokens.find(tokstr);
                    return((id != default) ?
                           new ptokenizer_token_t(id, tokstr)
                        :   new ptokenizer_token_t(ptokenizer_token_type.UNKNOWN, tokstr));
                }
            }
        }