PageRenderTime 33ms CodeModel.GetById 17ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/llui/llrngwriter.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 63 lines | 28 code | 10 blank | 25 comment | 0 complexity | fdb08f428b3ca2c67f5bed170fe80cdf MD5 | raw file
 1/** 
 2 * @file llrngwriter.h
 3 * @brief Generates Relax NG schema files from a param block
 4 *
 5 * $LicenseInfo:firstyear=2003&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LLRNGWRITER_H
28#define LLRNGWRITER_H
29
30#include "llinitparam.h"
31#include "llxmlnode.h"
32
33class LLRNGWriter : public LLInitParam::Parser
34{
35	LOG_CLASS(LLRNGWriter);
36public:
37	void writeRNG(const std::string& name, LLXMLNodePtr node, const LLInitParam::BaseBlock& block, const std::string& xml_namespace);
38	void addDefinition(const std::string& type_name, const LLInitParam::BaseBlock& block);
39
40	/*virtual*/ std::string getCurrentElementName() { return LLStringUtil::null; }
41
42	LLRNGWriter();
43
44private:
45	LLXMLNodePtr createCardinalityNode(LLXMLNodePtr parent_node, S32 min_count, S32 max_count);
46	void addTypeNode(LLXMLNodePtr parent_node, const std::string& type, const std::vector<std::string>* possible_values);
47
48	void writeAttribute(const std::string& type, const Parser::name_stack_t&, S32 min_count, S32 max_count, const std::vector<std::string>* possible_values);
49	LLXMLNodePtr	mElementNode;
50	LLXMLNodePtr	mChildrenNode;
51	LLXMLNodePtr	mGrammarNode;
52	std::string		mDefinitionName;
53
54	typedef std::pair<LLXMLNodePtr, std::set<std::string> >  attribute_data_t;
55	typedef std::map<std::string, attribute_data_t> elements_map_t;
56	typedef std::set<std::string> defined_elements_t;
57
58	defined_elements_t	mDefinedElements;
59	attribute_data_t	mAttributesWritten;
60	elements_map_t		mElementsWritten;
61};
62
63#endif //LLRNGWRITER_H