AM_CXXFLAGS =
# gperf: -pg
-LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la -lboost_regex
+LDADD = -L$(top_srcdir)/zypp/.libs -lzypp -lboost_regex
## ##################################################
-Main_SOURCES = Main.cc Packages.cc
+Main_SOURCES = Main.cc
Main_debug_SOURCES = $(Main_SOURCES)
Main_debug_LDFLAGS = -static
echoOn( MIL, first, last, s );
}
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // SingleTag Grammar
+ //
+ ////////////////////////////////////////////////////////////////////////////
+
+
+ struct Merror_report_parser
+ {
+ Merror_report_parser( const char * msg_r )
+ : msg( msg_r )
+ {}
+
+ typedef spirit::nil_t result_t;
+
+ template <typename ScannerT>
+ int operator()( const ScannerT & scan, result_t & /*result*/ ) const
+ {
+ SEC << scan.first.get_position() << ' ' << msg << std::endl;
+ return -1; // Fail.
+ }
+
+ const char * msg;
+ };
+
+ typedef functor_parser<Merror_report_parser> Merror_report_p;
+
+
+
+
/////////////////////////////////////////////////////////////////
} // namespace tagfile
///////////////////////////////////////////////////////////////////
std::string v;
std::string r;
std::string a;
+
parse_info<> info = parse( value.c_str(),
lexeme_d[(+~space_p)] [assign_a(n)]
scoped_ptr<NVRA> _nvra;
};
-struct X
-{
- template <typename Item>
- struct result
- {
- typedef rule_t type;
- };
-
- template <typename Item>
- rule_t operator<<( const Item & stag_r ) const
- {
- return eps_p;//error_report_p( "neither empty nor comment" );
- }
-};
-//const phoenix::function<X_impl> XX = X_impl();
-
////////////////////////////////////////////////////////////////////////////
//
// Main
MTag mtagData;
PConsume consume;
- rule_t c = eps_p;
- rule_t a = nothing_p;
- rule_t x = error_report_p( "abort" );
+#if 1
rule_t file = end_p
- | ( stag //[var(consume)=arg1]
- >> lazy_p(var(x))
+ | ( stag [var(consume)=arg1]
| mtag [var(consume)=arg1]
| ( *blank_p
>> !( ch_p('#')
)
>> (eol_p|end_p)
)
- | error_report_p( "neither empty nor comment" )
+ | error_report_p( "illegal line" )
)
- >> file;
+ >> file
+ ;
+#else
+ rule_t file =
+ end_p
+ | (+~space_p) [&echo]
+ >> ( lazy_p(var(skip))
+ | Merror_report_p( "lazy failed" )
+ )
+ >> file
+ ;
+#endif
// Parse
shared_ptr<Measure> duration( new Measure );
parse_info<iterator_t> info
- = parse( begin, end, file );
+ = parse( begin, end,
+
+ file
+
+ );
duration.reset();
// Check for fail...
${INDENT}public:
${INDENT} /** Offer default Impl. */
${INDENT} static shared_ptr<Impl> nullimpl()
-${INDENT} { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
-
-${INDENT}private:
-${INDENT} /** Default Impl. */
-${INDENT} static shared_ptr<Impl> _nullimpl;
+${INDENT} {
+${INDENT} static shared_ptr<Impl> _nullimpl( new Impl );
+${INDENT} return _nullimpl;
+${INDENT} }
${INDENT}private:
${INDENT} friend Impl * rwcowClone<Impl>( const Impl * rhs );
${INDENT}};
${INDENT}///////////////////////////////////////////////////////////////////
-${INDENT}shared_ptr<${CLASS}::Impl> ${CLASS}::Impl::_nullimpl;
-
-${INDENT}///////////////////////////////////////////////////////////////////
-
${INDENT}/** \relates ${CLASS}::Impl Stream output */
${INDENT}inline std::ostream & operator<<( std::ostream & str, const ${CLASS}::Impl & obj )
${INDENT}{
namespace
{ /////////////////////////////////////////////////////////////////
- typedef std::map<std::string,std::string> CodeMap;
- typedef CodeMap::const_iterator Index;
-
- // CodeMap[code] = untranslated country name
- // Translation is done in name().
- CodeMap _iso3166_CodeMap;
- CodeMap _others_CodeMap;
-
- void setDefaultCodeMaps( CodeMap & iso3166,
- CodeMap & others );
-
- /** Assert code maps are initialized. */
- void assertInitCodemaps()
+ /** Wrap static codemap data. */
+ struct CodeMaps // singleton
{
- if ( _others_CodeMap.empty() )
- setDefaultCodeMaps( _iso3166_CodeMap,
- _others_CodeMap );
- }
-
- /** Return index of \a code_r, if it's in the code maps. */
- Index lookupCode( const std::string & code_r )
+ typedef std::map<std::string,std::string> CodeMap;
+ typedef CodeMap::const_iterator Index;
+
+ /** Return the CodeMap Index for \a code_r. */
+ static Index getIndex( const std::string & code_r )
+ {
+ static CodeMaps _maps; // the singleton instance
+ return _maps.lookup( code_r );
+ }
+
+ private:
+ /** Ctor initializes the code maps.
+ * http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
+ */
+ CodeMaps();
+
+ /** Make shure the code is in the code maps and return it's index. */
+ inline Index lookup( const std::string & code_r );
+
+ /** Return index of \a code_r, if it's in the code maps. */
+ inline Index lookupCode( const std::string & code_r );
+
+ private:
+ /** Two letter codes. */
+ CodeMap iso3166;
+ /** All the stuff the application injects. */
+ CodeMap others;
+ };
+
+ inline CodeMaps::Index CodeMaps::lookupCode( const std::string & code_r )
{
- assertInitCodemaps();
switch ( code_r.size() )
{
case 2:
{
- Index it = _iso3166_CodeMap.find( code_r );
- if ( it != _iso3166_CodeMap.end() )
+ Index it = iso3166.find( code_r );
+ if ( it != iso3166.end() )
return it;
}
break;
}
- // not found: check _others_CodeMap
- // !!! not found at all returns _others_CodeMap.end()
- return _others_CodeMap.find( code_r );
+ // not found: check others
+ // !!! not found at all returns others.end()
+ return others.find( code_r );
}
- /** Assert \a code_r is in the code maps and return it's index.
- * That's what CountryCode::Impl calls.
- */
- Index getIndex( const std::string & code_r )
+ inline CodeMaps::Index CodeMaps::lookup( const std::string & code_r )
{
Index it = lookupCode( code_r );
- if ( it != _others_CodeMap.end() )
+ if ( it != others.end() )
return it;
// not found: Remember a new code
// but maybe we're lucky with the upper case code
// and find a country name.
it = lookupCode( lcode );
- if ( it != _others_CodeMap.end() )
+ if ( it != others.end() )
nval.second = it->second;
}
MIL << "Remember CountryCode '" << code_r << "': '" << nval.second << "'" << endl;
- return _others_CodeMap.insert( nval ).first;
+ return others.insert( nval ).first;
}
/////////////////////////////////////////////////////////////////
struct CountryCode::Impl
{
Impl()
- : _index( getIndex( std::string() ) )
+ : _index( CodeMaps::getIndex( std::string() ) )
{}
Impl( const std::string & code_r )
- : _index( getIndex( code_r ) )
+ : _index( CodeMaps::getIndex( code_r ) )
{}
std::string code() const
private:
/** index into code map. */
- Index _index;
+ CodeMaps::Index _index;
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
- { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
-
- private:
- /** Default Impl. */
- static shared_ptr<Impl> _nullimpl;
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
};
///////////////////////////////////////////////////////////////////
- shared_ptr<CountryCode::Impl> CountryCode::Impl::_nullimpl;
-
- ///////////////////////////////////////////////////////////////////
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : CountryCode
namespace
{ /////////////////////////////////////////////////////////////////
- /** Initialize the code maps.
- * http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
- */
- void setDefaultCodeMaps( CodeMap & iso3166,
- CodeMap & others )
+ CodeMaps::CodeMaps()
{
// Defined CountryCode constants
others[""] = N_( "noCode" );
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
- { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
-
- private:
- /** Default Impl: empty sets. */
- static shared_ptr<Impl> _nullimpl;
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
private:
friend Impl * rwcowClone<Impl>( const Impl * rhs );
};
///////////////////////////////////////////////////////////////////
- shared_ptr<Dependencies::Impl> Dependencies::Impl::_nullimpl;
-
- ///////////////////////////////////////////////////////////////////
-
/** \relates DependenciesImpl Stream output */
inline std::ostream & operator<<( std::ostream & str, const Dependencies::Impl & obj )
{
namespace
{ /////////////////////////////////////////////////////////////////
- typedef std::map<std::string,std::string> CodeMap;
- typedef CodeMap::const_iterator Index;
+ /** Wrap static codemap data. */
+ struct CodeMaps // singleton
+ {
+ typedef std::map<std::string,std::string> CodeMap;
+ typedef CodeMap::const_iterator Index;
- // CodeMap[code] = untranslated language name
- // Translation is done in name().
- CodeMap _iso639_1_CodeMap;
- CodeMap _iso639_2_CodeMap;
- CodeMap _others_CodeMap;
+ /** Return the CodeMap Index for \a code_r. */
+ static Index getIndex( const std::string & code_r )
+ {
+ static CodeMaps _maps; // the singleton instance
+ return _maps.lookup( code_r );
+ }
- void setDefaultCodeMaps( CodeMap & iso639_1,
- CodeMap & iso639_2,
- CodeMap & others );
+ private:
+ /** Ctor initializes the code maps.
+ * http://www.loc.gov/standards/iso639-2/ISO-639-2_values_8bits.txt
+ */
+ CodeMaps();
- /** Assert code maps are initialized. */
- void assertInitCodemaps()
- {
- if ( _others_CodeMap.empty() )
- setDefaultCodeMaps( _iso639_1_CodeMap,
- _iso639_2_CodeMap,
- _others_CodeMap );
- }
+ /** Make shure the code is in the code maps and return it's index. */
+ inline Index lookup( const std::string & code_r );
- /** Return index of \a code_r, if it's in the code maps. */
- Index lookupCode( const std::string & code_r )
+ /** Return index of \a code_r, if it's in the code maps. */
+ inline Index lookupCode( const std::string & code_r );
+
+ private:
+ /** Two letter codes. */
+ CodeMap iso639_1;
+ /** Three letter codes. */
+ CodeMap iso639_2;
+ /** All the stuff the application injects. */
+ CodeMap others;
+ };
+
+ inline CodeMaps::Index CodeMaps::lookupCode( const std::string & code_r )
{
- assertInitCodemaps();
switch ( code_r.size() )
{
case 2:
{
- Index it = _iso639_1_CodeMap.find( code_r );
- if ( it != _iso639_1_CodeMap.end() )
+ Index it = iso639_1.find( code_r );
+ if ( it != iso639_1.end() )
return it;
}
break;
case 3:
{
- Index it = _iso639_2_CodeMap.find( code_r );
- if ( it != _iso639_2_CodeMap.end() )
+ Index it = iso639_2.find( code_r );
+ if ( it != iso639_2.end() )
return it;
}
break;
}
- // not found: check _others_CodeMap
- // !!! not found at all returns _others_CodeMap.end()
- return _others_CodeMap.find( code_r );
+ // not found: check others
+ // !!! not found at all returns others.end()
+ return others.find( code_r );
}
- /** Assert \a code_r is in the code maps and return it's index.
- * That's what LanguageCode::Impl calls.
- */
- Index getIndex( const std::string & code_r )
+ inline CodeMaps::Index CodeMaps::lookup( const std::string & code_r )
{
Index it = lookupCode( code_r );
- if ( it != _others_CodeMap.end() )
+ if ( it != others.end() )
return it;
// not found: Remember a new code
// but maybe we're lucky with the lower case code
// and find a language name.
it = lookupCode( lcode );
- if ( it != _others_CodeMap.end() )
+ if ( it != others.end() )
nval.second = it->second;
}
MIL << "Remember LanguageCode '" << code_r << "': '" << nval.second << "'" << endl;
- return _others_CodeMap.insert( nval ).first;
+ return others.insert( nval ).first;
}
/////////////////////////////////////////////////////////////////
struct LanguageCode::Impl
{
Impl()
- : _index( getIndex( std::string() ) )
+ : _index( CodeMaps::getIndex( std::string() ) )
{}
Impl( const std::string & code_r )
- : _index( getIndex( code_r ) )
+ : _index( CodeMaps::getIndex( code_r ) )
{}
std::string code() const
private:
/** index into code map. */
- Index _index;
+ CodeMaps::Index _index;
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
- { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
-
- private:
- /** Default Impl. */
- static shared_ptr<Impl> _nullimpl;
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
};
///////////////////////////////////////////////////////////////////
- shared_ptr<LanguageCode::Impl> LanguageCode::Impl::_nullimpl;
-
- ///////////////////////////////////////////////////////////////////
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : LanguageCode
namespace
{ /////////////////////////////////////////////////////////////////
- /** Initialize the code maps.
- * http://www.loc.gov/standards/iso639-2/ISO-639-2_values_8bits.txt
- */
- void setDefaultCodeMaps( CodeMap & iso639_1,
- CodeMap & iso639_2,
- CodeMap & others )
+ CodeMaps::CodeMaps()
{
// Defined LanguageCode constants
others[""] = N_( "noCode" );
public:
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
- { if ( ! _nullimpl ) _nullimpl.reset( new Impl ); return _nullimpl; }
-
- private:
- /** Default Impl. */
- static shared_ptr<Impl> _nullimpl;
+ {
+ static shared_ptr<Impl> _nullimpl( new Impl );
+ return _nullimpl;
+ }
};
///////////////////////////////////////////////////////////////////
- shared_ptr<Locale::Impl> Locale::Impl::_nullimpl;
-
- ///////////////////////////////////////////////////////////////////
-
/** \relates Locale::Impl Stream output */
inline std::ostream & operator<<( std::ostream & str, const Locale::Impl & obj )
{
//
///////////////////////////////////////////////////////////////////
-#warning NO STATIC VARIABLES
-// const Locale Locale::noCode;
+ const Locale Locale::noCode;
///////////////////////////////////////////////////////////////////
//
/** \name Locale constants. */
//@{
/** No or empty code. */
-// static const Locale noCode;
+ static const Locale noCode;
//@}
public: