Orb/Doxygen/src/xmlditaelementprefix.cpp
changeset 1 82f11024044a
parent 0 42188c7ea2d9
equal deleted inserted replaced
0:42188c7ea2d9 1:82f11024044a
    11  */
    11  */
    12 #include "xmlditaelementprefix.h"
    12 #include "xmlditaelementprefix.h"
    13 
    13 
    14 // Version to use in the DOCTYPE declaration
    14 // Version to use in the DOCTYPE declaration
    15 // Should match regex: v(\d+)\.(\d+)\.(\d+)(\S*)
    15 // Should match regex: v(\d+)\.(\d+)\.(\d+)(\S*)
    16 const char *DOCTYPE_VERSION = "v0.1.0";
    16 const char *DOCTYPE_VERSION = "v0.5.0";
    17 
    17 
    18 DITAElementPrefix::DITAElementPrefix()
    18 DITAElementPrefix::DITAElementPrefix()
    19 {
    19 {
    20 	//QDict<char> m_extToLang;
    20 	//QDict<char> m_extToLang;
    21 	//QDict<char> m_langToPrefix;
    21 	//QDict<char> m_langToPrefix;
    28 	// TODO: Have list of supported languages in DITA e.g. isSupported(Definition*);
    28 	// TODO: Have list of supported languages in DITA e.g. isSupported(Definition*);
    29 	// so that callers can decide to supress output for unsupported languages
    29 	// so that callers can decide to supress output for unsupported languages
    30 	m_extToLang.insert(".h",     "C++");
    30 	m_extToLang.insert(".h",     "C++");
    31 	m_extToLang.insert(".c",     "C++");
    31 	m_extToLang.insert(".c",     "C++");
    32 	m_extToLang.insert(".cpp",   "C++");
    32 	m_extToLang.insert(".cpp",   "C++");
       
    33 	m_extToLang.insert(".cc",    "C++");
    33 	m_extToLang.insert(".cp",    "C++");
    34 	m_extToLang.insert(".cp",    "C++");
    34 	m_extToLang.insert(".cxx",   "C++");
    35 	m_extToLang.insert(".cxx",   "C++");
    35 	m_extToLang.insert(".inl",   "C++");
    36 	m_extToLang.insert(".inl",   "C++");
       
    37 	m_extToLang.insert(".cia",   "C++");
       
    38 	m_extToLang.insert(".hrh",   "C++");
       
    39 	m_extToLang.insert(".s",     "C++");
    36 	// Other languages
    40 	// Other languages
    37 	m_extToLang.insert(".idl",   "IDL"); 
    41 	m_extToLang.insert(".idl",   "IDL"); 
    38 	m_extToLang.insert(".ddl",   "IDL"); 
    42 	m_extToLang.insert(".ddl",   "IDL"); 
    39 	m_extToLang.insert(".odl",   "IDL"); 
    43 	m_extToLang.insert(".odl",   "IDL"); 
    40 	m_extToLang.insert(".java",  "Java");
    44 	m_extToLang.insert(".java",  "Java");
    53 	m_extToLang.insert(".py",    "Python");
    57 	m_extToLang.insert(".py",    "Python");
    54 	m_extToLang.insert(".f",     "Fortran");
    58 	m_extToLang.insert(".f",     "Fortran");
    55 	m_extToLang.insert(".f90",   "Fortran");
    59 	m_extToLang.insert(".f90",   "Fortran");
    56 	m_extToLang.insert(".vhd",   "VHDL");
    60 	m_extToLang.insert(".vhd",   "VHDL");
    57 	m_extToLang.insert(".vhdl",  "VHDL");
    61 	m_extToLang.insert(".vhdl",  "VHDL");
       
    62 	// Default Language
       
    63 	m_defaultLanguage = "C++";
    58 	//
    64 	//
    59 	// Now load the language to element prefix, case sensitve all round.
    65 	// Now load the language to element prefix, case sensitve all round.
    60 	// However the class behavior is that if there is no entry then the prefix is the
    66 	// However the class behavior is that if there is no entry then the prefix is the
    61 	// language in lower case with spaces removed i.e. implicitly "C Sharp" -> "csharp"
    67 	// language in lower case with spaces removed i.e. implicitly "C Sharp" -> "csharp"
    62 	//
    68 	//
    68 
    74 
    69 QString DITAElementPrefix::srcLang(const QString &fileName)
    75 QString DITAElementPrefix::srcLang(const QString &fileName)
    70 {
    76 {
    71 	QString retStr;
    77 	QString retStr;
    72 	int i = fileName.findRev('.');
    78 	int i = fileName.findRev('.');
    73 	QString ext = fileName.right(fileName.length() - i).lower();
    79 	QFileInfo fInfo(fileName);
    74 	if (i != -1 && (fileName.length() - i)) {
    80 	//QString ext = fileName.right(fileName.length() - i).lower();
    75 		char *p = m_extToLang[ext];
    81 	QString ext = fInfo.extension();
    76 		if (p) {
    82 	if (ext.length() > 0 && m_extToLang.find(ext)) {
    77 			retStr = QString(p);
    83 		retStr = QString(m_extToLang[ext]);
    78 		} else {
    84 	} else {
    79 			// WTF?
    85 		// WTF?
    80 			retStr = "_" + ext + "_";
    86 		//retStr = "_" + ext + "_";
    81 		}
    87 		retStr = m_defaultLanguage;
    82 	}
    88 	}
       
    89 	//printf("DITAElementPrefix::srcLang file \"%s\" extension \"%s\" gets \"%s\"\n", fileName.data(), ext.data(), retStr.data());
    83 	return retStr;
    90 	return retStr;
    84 }
    91 }
    85 
    92 
    86 QString DITAElementPrefix::elemPrefix(const QString &srcLang)
    93 QString DITAElementPrefix::elemPrefix(const QString &srcLang)
    87 {
    94 {