Exemplo n.º 1
0
ESDLcompiler::ESDLcompiler(const char * sourceFile, bool generatefile, const char *outDir, bool outputIncludes_, bool isIncludedEsdl, const char* includePath_)
{
    outputIncludes = outputIncludes_;
    modules = NULL;
    enums = NULL;
    apis=NULL;
    servs=NULL;
    msgs=NULL;
    includes=NULL;
    methods=NULL;
    versions = NULL;
    esxdlo = -1;
    StringBuffer ext;
    StringBuffer prot;
    splitFilename(sourceFile, &prot, &srcDir, &name, &ext);

    if (includePath_ && *includePath_)
        includeDirs.appendList(includePath_, ENVSEPSTR);

    filename = strdup(sourceFile);

    yyin = fopen(sourceFile, "rt");
    if (!yyin)
    {
        if (isIncludedEsdl)
        {
            StringBuffer locatedFilePath;
            bool located = locateIncludedFile(locatedFilePath, prot.str(), srcDir.str(), name.str(), ext.str());
            if( located)
                yyin = fopen(locatedFilePath.str(), "rt");
            if (!yyin)
            {
                fprintf(stderr, "Fatal Error: Could not load included ESDL grammar %s\n", filename);
                exit(1);
            }
        }
        else
        {
            fprintf(stderr, "Fatal Error: Could not load ESDL grammar %s\n", sourceFile);
            exit(1);
        }

    }

    packagename = es_gettail(sourceFile);

    if (generatefile)
    {
        if (!outDir || !*outDir)
            outDir = srcDir.str();

        char* targetBase = getTargetBase(outDir, sourceFile);

        esxdlo = es_createFile(targetBase,"xml");

        free(targetBase);
    }
}
Exemplo n.º 2
0
std::string BaseConverter::convert(std::string value) const
{
    unsigned int numberBase = getTargetBase();
	std::string result { };

    do
    {
        unsigned int remainder = divide(sourceBaseSet_, value, numberBase);
        result.push_back(targetBaseSet_[remainder]);
    }
    while (!value.empty() && !(value.length() == 1 && value[0] == sourceBaseSet_[0]));

    std::reverse(result.begin(), result.end());
    return result;
}