コード例 #1
0
ファイル: iomanip_pdf.cpp プロジェクト: apextw/Ramen
void pdf_format::stack_event(stream_type& os, bool is_push)
{
    const format_element_t& top(stack_top());
    name_t                  self(top.tag());
    name_t                  parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
    name_t                  grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());

    if (self == atom_name_g)
    {
        handle_atom(os, is_push);
    }
    else if (is_push)
    {
        if (self == static_name_t("pdf"))
        {
            os << "% start pdf" << std::endl;
        }
        else if (self == bag_name_g)
        {
            os << "<<";

            up();
        }
        else if (self == seq_name_g && parent != bag_name_g)
        {
            os << "[ ";
        }
    }
    else
    {
        if (self == static_name_t("pdf"))
        {
            os << "\n% end pdf";
        }
        else if (self == bag_name_g)
        {
            down();

            if (top.num_out_m > 0)
                os << '\n' << indents(depth());
            else
                os << ' ';

            os << ">>";
        }
        else if (self == seq_name_g && parent != bag_name_g)
        {
            if (top.num_out_m > 0)
                os << ' ';

            os << ']';
        }
    }
}
コード例 #2
0
// sheet .
bool adam_test_parser::is_sheet() {
    if (!is_keyword(name_t("sheet")))
        return false;
    putback();
    sheets_m.push_back(new queryable_sheet_t(*this));
    return true;
}
コード例 #3
0
void asl_cel_format::stack_event(stream_type& os, bool is_push) {
    const format_element_t& top(stack_top());
    name_t self(top.tag());
    name_t parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());

    if (self == atom_name_g) {
        handle_atom(os, is_push);
    } else if (is_push) {
        if (self == bag_name_g) {
            os << '{';

            up();
        } else if (self == seq_name_g && parent != bag_name_g) {
            os << "[ ";
        }
    } else {
        if (self == bag_name_g) {
            down();

            if (top.num_out_m > 0)
                os << '\n' << indents(depth());
            else
                os << ' ';

            os << '}';
        } else if (self == seq_name_g && parent != bag_name_g) {
            if (top.num_out_m > 0)
                os << ' ';

            os << ']';
        }
    }
}
コード例 #4
0
ファイル: iomanip.hpp プロジェクト: Ablu/freeorion
 explicit format_element_t(name_t             tag = name_t(),
                           const std::string& ident = std::string()) :
     ident_m(ident),
     num_out_m(0),
     tag_m(tag),
     value_m(0)
 { }
コード例 #5
0
ファイル: FunctionHandlerDDL.cpp プロジェクト: DavidPH/DH-dlc
T FunctionHandlerDDL<T>::operator () (std::vector<std::string> const & args) const
{
	obj_t funcObj = LevelObject::create();

	obj_t returnType = LevelObject::create(type_t::type_type(), type_t::type_auto<T>());
	funcObj->addObject(name_t::name_return_type, returnType);

	obj_t argcObj = LevelObject::create(type_t::type_shortint(), int_s_t(args.size()));
	funcObj->addObject(name_t(key_name_argc()), argcObj);

	for (size_t index = 0; index < args.size(); ++index)
	{
		// TODO: Should make an arg_t for undefined types.
		obj_t argObj;
		if (index < _argt.size())
			obj_t argObj = LevelObject::create(_argt[index], args[index]);
		else
			obj_t argObj = LevelObject::create(type_t::type_string(), string_t(args[index]));

		name_t argName(parse_name(key_name_arg() + make_string(index)));

		funcObj->addObject(argName, argObj);
	}

	funcObj->addData(_data);

	obj_t returnValue = funcObj->getObject(name_t::name_return_value);
	return convert<T, obj_t>(returnValue);
}
コード例 #6
0
ファイル: name.cpp プロジェクト: Tarek-Samy/js2model
name_t nameFromJsonData(const char *data, size_t len) {

    std::vector<char> buffer(len + 1);

    std::memcpy(&buffer[0], data, len);

    Document doc;

    doc.ParseInsitu(&buffer[0]);

    return name_t(doc);
}
コード例 #7
0
void adam_test_parser::populate_dict(dictionary_t& dict, const queryable_sheet_t::index_t& index,
                                     const queryable_sheet_t& qs, bool want_contributors,
                                     bool want_active) const {
    for (queryable_sheet_t::index_t::iterator iter = index.begin(), e = index.end(); iter != e;
         ++iter) {
        std::size_t i(iter->second);

        if (want_contributors) {
            dictionary_t cell_dict;
            cell_dict[name_t("contributors")] = any_regular_t(qs.cell_contributors()[i]);
            if (want_active) {
                cell_dict[name_t("active")] = any_regular_t(qs.cell_active()[i]);
                cell_dict[name_t("priority_accessed")] =
                    any_regular_t(qs.cell_priority_accessed()[i]);
            }
            cell_dict[name_t("_value")] = qs.cell_value()[i];
            dict[qs.cell_name()[i]] = any_regular_t(cell_dict);

        } else
            dict[qs.cell_name()[i]] = qs.cell_value()[i];
    }
}
コード例 #8
0
NEOIP_NAMESPACE_BEGIN

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//                       open/close
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

/** \brief Open a directory dir_path (MUST NOT be null)
 * 
 * - this is valid to open an already opened file_dir_t
 *   - the content obtained from the previous open(), will be overwritten by the new one
 */
file_err_t	file_dir_t::open(const file_path_t &dir_path)			throw()
{	
	GError *	gerror	= NULL;
	const gchar *	name;
	// sanity check - the dir_path MUST NOT be null
	DBG_ASSERT( !dir_path.is_null() );

	// zero the file database
	name_db	= std::vector<name_t>();	
	// open the directory
	GDir *	g_dir	= g_dir_open(dir_path.to_os_path_string().c_str(), 0, &gerror );
	// if the open failed, report the error now
	if( gerror )	return file_err_t(file_err_t::ERROR, gerror->message );

	// scan the directory
	while( (name = g_dir_read_name(g_dir)) ){
		file_stat_t	file_stat( dir_path.fullpath() / name );
		// if this file can't be stated, skip it
		if( file_stat.is_null() )	continue;
		// put the found name in the name_db
		name_db.push_back( name_t(name, file_stat) );
	}
	
	// close the directory
	g_dir_close(g_dir);

	// copy the dir_path
	this->dir_path	= dir_path;
	
	// return no error
	return file_err_t::OK;
}
コード例 #9
0
ファイル: window_server.cpp プロジェクト: Ablu/freeorion
void window_server_t::push_back(const char* name, size_enum_t dialog_size)
{
    boost::filesystem::path     relative_path(window_list_m.back()->path_m.branch_path() / name);
    iterator                    window(window_list_m.insert(window_list_m.end(), NULL));
    boost::filesystem::path     file_name;

    try
    {
        file_name = find_resource(name);
    }
    catch (...)
    {
        file_name = relative_path;
    }

    boost::filesystem::ifstream stream(file_name);

    /*
    Update before attaching the window so that we can correctly capture contributing for reset.
    */
    
    sheet_m.update();

    window_list_m.back() = make_view(   name_t(file_name.string().c_str()),
                                        line_position_t::getline_proc_t(),
                                        stream,
                                        sheet_m,
                                        behavior_m,
                                        boost::bind(&window_server_t::dispatch_window_action,
                                            boost::ref(*this), window, _1, _2),
                                        dialog_size,
                                        default_widget_factory_proc_with_factory(widget_factory_m)).release();
    
    sheet_m.update(); // Force values to their correct states.

    window_list_m.back()->path_m = file_name;
    window_list_m.back()->eve_m.evaluate(eve_t::evaluate_nested);
    window_list_m.back()->show_window_m();
}
コード例 #10
0
ファイル: name.cpp プロジェクト: Tarek-Samy/js2model
std::vector<name_t> nameArrayFromData(const char *jsonData, size_t len) {

    std::vector<char> buffer(len + 1);

    std::memcpy(&buffer[0], jsonData, len);

    Document doc;

    doc.ParseInsitu(&buffer[0]);

    assert(doc.IsArray());

    std::vector<name_t> nameArray;
    nameArray.reserve(doc.Size());

    for( auto array_item = doc.Begin(); array_item != doc.End(); array_item++  ) {

        name_t instance = name_t(*array_item);
        nameArray.push_back(instance);
    }

    return nameArray;
}
コード例 #11
0
ファイル: window_server.cpp プロジェクト: Ablu/freeorion
void window_server_t::push_back(std::istream&                                   data,
                                const boost::filesystem::path&                  path,
                                const line_position_t::getline_proc_t&   getline_proc,
                                size_enum_t                              dialog_size)
{
    /*
    Update before attaching the window so that we can correctly capture contributing for reset.
    */
    sheet_m.update();

    iterator window (window_list_m.insert(window_list_m.end(), NULL));

    //
    // REVISIT (ralpht): Where does this made-up filename get used? Does it need to be localized
    //  or actually be an existing file?
    //
    //  REVISIT (fbrereto) :    The file name is for error reporting purposes; see the const char*
    //                          push_back API where this is filled in. It should be valid, lest the
    //                          user not know the erroneous file.
    //
    window_list_m.back() = make_view(   name_t(path.string().c_str()),
                                        getline_proc,
                                        data,
                                        sheet_m,
                                        behavior_m,
                                        boost::bind(&window_server_t::dispatch_window_action,
                                            boost::ref(*this), window, _1, _2),
                                        dialog_size,
                                        default_widget_factory_proc_with_factory(widget_factory_m)).release();

    sheet_m.update(); // Force values to their correct states.

    window_list_m.back()->path_m = path;
    window_list_m.back()->eve_m.evaluate(eve_t::evaluate_nested);
    window_list_m.back()->show_window_m();
}
コード例 #12
0
ファイル: iomanip_pdf.cpp プロジェクト: apextw/Ramen
void pdf_format::handle_atom(stream_type& os, bool is_push)
{
    const format_element_t& top(stack_top());
    name_t                  self(top.tag());
    name_t                  parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
    name_t                  grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
    const any_regular_t&    value(top.value());
    bool                    outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
    std::size_t&            num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
    bool                    named_argument(outputting_bag && num_out % 2 == 0);

    if (is_push)
    {
        // if this is not the first item in the element, add a comma and set up a newline
        if (num_out > 0)
        {
            if (!outputting_bag)
            {
                os << ' ';
            }
            else if (named_argument)
            {
                os << '\n' << indents(depth());
            }
        }
        else if (outputting_bag)
        {
            os << '\n' << indents(depth());
        }

        if (value.type_info() == adobe::type_info<string_t>())
        {
            os << '(' << value.cast<string_t>() << ')';
        }
        else if (value.type_info() == adobe::type_info<name_t>())
        {
            os << '/' << value.cast<name_t>();

            if (outputting_bag && named_argument)
                os << " ";
        }
        else if (value.type_info() == adobe::type_info<bool>())
        {
            os << (value.cast<bool>() ? "true" : "false");
        }
        else if (value.type_info() == adobe::type_info<double>())
        {
            double         dbl_val(value.cast<double>());
            boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));

            if (dbl_val == int_val)
            {
                os << int_val;
            }
            else
            {
                // For pdf, we want to output floating-point values in decimal-based
                // fixed-point notation (asl_cel doesn't support any other format) with
                // a very high precision for accceptable roundtrip values.
    
                os.setf(std::ios_base::dec, std::ios_base::basefield);
                os.setf(std::ios_base::fixed, std::ios_base::floatfield);
                os.precision(16);

                os << dbl_val;
            }
        }
        else if (value.type_info() == adobe::type_info<empty_t>())
        {
            os << "null";
        }
        else if (value.type_info() == adobe::type_info<dictionary_t>())
        {
            os << value.cast<dictionary_t>();
        }
        else if (value.type_info() == adobe::type_info<array_t>())
        {
            os << value.cast<array_t>();
        }
        else
        {
            os << "(pdf_unknown: " << value.type_info().name() << ")";
        }
    }
    else
    {
        // up the number of outputted items for the parent to this atom
        ++num_out;
    }
}
コード例 #13
0
void asl_cel_format::handle_atom(stream_type& os, bool is_push) {
    const format_element_t& top(stack_top());
    name_t parent(stack_depth() >= 2 ? stack_n(1).tag() : name_t());
    name_t grandparent(stack_depth() >= 3 ? stack_n(2).tag() : name_t());
    const any_regular_t& value(top.value());
    bool outputting_bag(parent == seq_name_g && grandparent == bag_name_g);
    std::size_t& num_out(outputting_bag ? stack_n(2).num_out_m : stack_n(1).num_out_m);
    bool named_argument(outputting_bag && (num_out & 0x1) == 0);

    if (is_push) {
        // if this is not the first item in the element, add a comma and set up a newline
        if (num_out > 0) {
            if (!outputting_bag) {
                os << ", ";
            } else if (named_argument) {
                os << ",\n" << indents(depth());
            }
        } else if (outputting_bag) {
            os << '\n' << indents(depth());
        }

        if (value.type_info() == typeid(string)) {
            bool escape(needs_entity_escape(value.cast<string>()));

            if (escape_m && escape)
                os << "xml_unescape(";

            os << '\"'
               << (escape_m && escape ? entity_escape(value.cast<string>()) : value.cast<string>())
               << '\"';

            if (escape_m && escape)
                os << ")";
        } else if (value.type_info() == typeid(name_t)) {
            if (!named_argument)
                os << '@';

            os << value.cast<name_t>();

            if (outputting_bag && named_argument)
                os << ": ";
        } else if (value.type_info() == typeid(bool)) {
            os << (value.cast<bool>() ? "true" : "false");
        } else if (value.type_info() == typeid(double)) {
            double dbl_val(value.cast<double>());
            boost::int64_t int_val(static_cast<boost::int64_t>(dbl_val));

            if (dbl_val == int_val) {
                os << int_val;
            } else {
                // For asl_cel, we want to output floating-point values in decimal-based
                // fixed-point notation (asl_cel doesn't support any other format) with
                // a very high precision for accceptable roundtrip values.

                os.setf(std::ios_base::dec, std::ios_base::basefield);
                os.setf(std::ios_base::fixed, std::ios_base::floatfield);
                os.precision(16);

                os << dbl_val;
            }
        } else if (value.type_info() == typeid(empty_t)) {
            os << value.cast<empty_t>();
        } else if (value.type_info() == typeid(dictionary_t)) {
            os << value.cast<dictionary_t>();
        } else if (value.type_info() == typeid(array_t)) {
            os << value.cast<array_t>();
        } else {
            os << "'" << value.type_info().name() << "'";
        }
    } else {
        // up the number of outputted items for the parent to this atom
        ++num_out;
    }
}
コード例 #14
0
void asl_cel_format::begin_format(stream_type& os) {
    push_stack(os, format_element_t(name_t("asl_cel")));
}
コード例 #15
0
bool operator<(const static_name_t& x, const static_name_t& y) { return name_t(x) < name_t(y); }
コード例 #16
0
ファイル: name.hpp プロジェクト: ilelann/legacy
 operator name_t() const { return name_t(name_m, name_t::dont_copy_t()); }
コード例 #17
0
ファイル: iomanip_pdf.cpp プロジェクト: apextw/Ramen
void pdf_format::begin_format(stream_type& os)
{ push_stack(os, format_element_t(name_t("pdf"))); }