void __stdcall BlackConfigurator::Save(const StringT& filename)
{
    FILE* fp = NULL;    
    if (_tfopen_s(&fp, filename.c_str(), _T("wb+, ccs=UTF-8")) != 0) {
        SXLOG_INF(g_local_logger) << _X(" open file for write failed! filepath:") << filename.c_str() << LBT << END;
        return;
    }
    ConfItemDictFileWriter writer(this, fp, 0);
    writer.Write();
    fclose(fp);
}
bool __stdcall BlackConfigurator::Load(const StringT& filename)
{
    //Clear();
    FILE* fp = NULL;
    if (_tfopen_s(&fp, filename.c_str(), _T("rb+, ccs=UTF-8")) != 0) {
        SXLOG_INF(g_local_logger) << _X(" open file for read failed! filepath:") << filename.c_str() << LBT << END;
        return false;
    }
    ConfItemDictFileReader reader(fp);
    ConfItemDict* result_dict = reader.Read();
    return false;
}
Exemple #3
0
	Value * Compiler::lookup (Symbol * identifier) {
		StringT functionName = identifier->value();
		
		llvm::Function* code = m_engine->FindFunctionNamed(functionName.c_str());
		
		if (!code) {
			return NULL;
		}
		
		return new CompiledFunction(code);
	}
inline void
validate_identifier_name (StringT const &name, std::size_t line,
    std::size_t column, StringT const &file_name)
{
    using namespace std;    // some systems have strtoul in namespace std::

typename StringT::size_type pos = name.find_first_of('\\');

    while (StringT::npos != pos) {
    // the identifier name contains a backslash (must be universal char)
        BOOST_ASSERT('u' == name[pos+1] || 'U' == name[pos+1]);

    StringT uchar_val(name.substr(pos+2, ('u' == name[pos+1]) ? 4 : 8));
    universal_char_type type =
        classify_universal_char(strtoul(uchar_val.c_str(), 0, 16));

        if (universal_char_type_valid != type) {
        // an invalid char was found, so throw an exception
        StringT error_uchar(name.substr(pos, ('u' == name[pos+1]) ? 6 : 10));

            if (universal_char_type_invalid == type) {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_invalid,
                    error_uchar, line, column, file_name.c_str());
            }
            else if (universal_char_type_base_charset == type) {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_base_charset,
                    error_uchar, line, column, file_name.c_str());
            }
            else {
                BOOST_WAVE_LEXER_THROW(lexing_exception, universal_char_not_allowed,
                    error_uchar, line, column, file_name.c_str());
            }
        }

    // find next universal char (if appropriate)
        pos = name.find_first_of('\\', pos+2);
    }
}
void
WriteStringT( hid_t iParent,
              const std::string &iAttrName,
              const StringT &iString )
{
    // Verify that no NULL characters have been hidden in the string.
    CharT NullChar = ( CharT )0;
    ABCA_ASSERT( iString.find( NullChar ) == StringT::npos,
                 "Illegal NULL character found in string in WriteStringT" );

    // Create the dataspace.
    size_t len = iString.length();
    Dimensions dims( len + 1 );
    HDimensions hdims( dims );
    size_t npoints = hdims.numPoints();
    ABCA_ASSERT( npoints > 0,
                 "Cannot create degenerate dataspace" );

    hid_t dspaceId = H5Screate_simple( hdims.rank(), hdims.rootPtr(), NULL );
    DspaceCloser dspaceCloser( dspaceId );

    // Get the data.
    const CharT *data;
    if ( len == 0 )
    {
        data = &NullChar;
    }
    else
    {
        data = iString.c_str();
    }

    // Write into it.
    WriteDataToAttr( iParent, dspaceId, iAttrName,
                     GetFileDtype<CharT>(), GetNativeDtype<CharT>(),
                     ( const void * )data );
}
Exemple #6
0
    /** main method to perform options parsing
     *
     * @opts map to gather (item_name, value) association
     * @params container to gather parameters
     */
    int parse(int argc, char const* const* argv,
              map_type &opts,
              std::vector<char const*> &params) const
    {
        enum stages {
            option,
            opt_param
        };
        stages stage = option;
        StringT name;
        bool is_leave_param = false;

        auto parse_short = [&](char const *s, size_t len) {
            auto p = short_opts_.find(s[1]);
            if (p == short_opts_.end()) {
                params.push_back(s);
                return;
            }

            name = p->second;

            is_leave_param = (leave_in_params_.count(name) != 0);
            if (is_leave_param)
                params.push_back(s);

            if (!opt_with_params_.count(name)) {
                opts[name] = "";
            } else if (len > 2) {
                opts[name] = &s[2];
                if (is_leave_param)
                    params.push_back(&s[2]);
            } else {
                stage = opt_param;
            }
        };

        auto parse_long = [&](char const *s, size_t) {
            char const *pname = &s[2];
            char const *peq = strchr(pname, '=');
            name = (peq
                    ? std::string(pname, peq - pname)
                    : std::string(pname));

            auto p = long_opts_.find(name);
            if (p == long_opts_.end()) {
                params.push_back(s);
                return;
            }
            // unified name is taken from map
            name = p->second;

            is_leave_param = (leave_in_params_.count(name) != 0);
            if (is_leave_param)
                params.push_back(s);

            auto p_has = opt_with_params_.find(name);
            if (p_has == opt_with_params_.end()) {
                if (peq)
                    throw cor::Error("option %s, unexpected param %s",
                                     name.c_str(), peq);
                opts[name] = "";
            } else {
                if (peq)
                    opts[name] = &peq[1];
                else
                    stage = opt_param;
            }
        };

        auto parse_opt_param = [&](char const *s, size_t len) {
            if (len >= 1 && s[0] == '-')
                throw std::logic_error(s);
            opts[name] = s;
            if (is_leave_param)
                params.push_back(s);
            stage = option;
        };

        auto parse_option = [&](char const *s, size_t len) {
            if (s[0] == '-') {
                if (len > 2 && s[1] == '-') {
                    parse_long(s, len);
                } else {
                    parse_short(s, len);
                }
            } else {
                params.push_back(s);
            }
        };

        auto process = [&](char const *v) {
            size_t len = std::strlen(v);
            if (!len)
                return;
            switch (stage) {
            case option:
                parse_option(v, len);
                break;
            case opt_param:
                parse_opt_param(v, len);
                break;
            };
        };

        std::for_each(argv, argv + argc, process);
        return 0;
    }
	static int inline mg_write(struct mg_connection* conn, const StringT& string)
	{
		return mg_write(conn, string.c_str(), string.size());
	}