当前位置: 首页>>代码示例>>C++>>正文


C++ Conversion::create_associations方法代码示例

本文整理汇总了C++中Conversion::create_associations方法的典型用法代码示例。如果您正苦于以下问题:C++ Conversion::create_associations方法的具体用法?C++ Conversion::create_associations怎么用?C++ Conversion::create_associations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversion的用法示例。


在下文中一共展示了Conversion::create_associations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fopen

/*
 * Registers articles.  The arguments in the specified
 * list are (in order):
 *
 * install location
 * datasheet filename
 * parent mnemonic
 * parent id
 *
 * All of these arguments are optional.
 *
 * The install location refers to the directory in which the software
 * has been installed.
 *
 * The datasheet filename specifies the name of the file that contains
 * the data representing articles to be registered.  If the datasheet
 * filename is not provided, the datasheet information will be read
 * from stdin.
 *
 * The parent mnemonic specifies the name of the article which is the
 * parent of the article(s) being registered with this call.
 *
 * The parent id specifies the instance of the article which is the
 * parent of the article(s) being registered with this call.
 *
 * This function returns the id of the article being registered.
 */
static char *
register_articles(List *arg_list)
{
	/*
	 * The default datasheet file is stdin.
	 */
	FILE *in = stdin;
	char *result = NULL;
	char *location = NULL;
	char *parent_mnemonic = NULL;
	char *parent_id = NULL;
	Wsreg_component *parent_component = NULL;
	List *matches = NULL;
	List *article_list = NULL;
	Conversion *conversion;

	if (arg_list->size(arg_list) > 0) {
		/*
		 * Install location, datasheet filename.
		 */
		char *path;
		location = (char *)arg_list->element_at(arg_list, 0);
		if (strcmp(location, "-") == 0) {
			location = NULL;
		}
		path = (char *)arg_list->element_at(arg_list, 1);
		in = NULL;
		if (path != NULL) {
			in = fopen(path, "r");
		}
		if (in == NULL) {
			(void) fprintf(stderr, PRODREG_CANT_READ_FILE,
			    path);
			(void) fprintf(stderr, "\n");
			return ("");
		}

		if (arg_list->size(arg_list) > 2) {
			/*
			 * Parent mnemonic, parent id.
			 */
			parent_mnemonic =
			    (char *)arg_list->element_at(arg_list, 2);
			parent_id = (char *)arg_list->element_at(arg_list, 3);
			if (parent_mnemonic != NULL &&
			    parent_id != NULL) {
				matches =
				    get_matching_components(parent_mnemonic,
					parent_id);
				if (matches != NULL &&
				    matches->size(matches) == 1) {
					parent_component =
					    (Wsreg_component *)
					    matches->element_at(matches, 0);
				} else {
					(void) fprintf(stderr,
					    PRODREG_NO_SUCH_COMPONENT,
					    parent_mnemonic, parent_id);
					(void) fprintf(stderr, "\n");

				}
			}
		}
	}

	article_list = read_articles(in);
	conversion = _wsreg_conversion_create(NULL);

	/*
	 * Creates associations between parent Article and
	 * child Article.
	 */
	conversion->create_associations(article_list);
//.........这里部分代码省略.........
开发者ID:belenix,项目名称:belenixold,代码行数:101,代码来源:Prodreg.c


注:本文中的Conversion::create_associations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。