BCatalogAddOn * DefaultCatalog::InstantiateEmbedded(entry_ref *appOrAddOnRef) { DefaultCatalog *catalog = new(std::nothrow) DefaultCatalog(appOrAddOnRef); if (catalog && catalog->InitCheck() != B_OK) { delete catalog; return NULL; } return catalog; }
int main(int argc, char **argv) { const char *inputFile = NULL; status_t res; if (!argv[1] || !strcmp(argv[1], "--help")) { usage(); } else { inputFile = argv[1]; } if (!inputFile || !strlen(inputFile)) usage(); EditableCatalog inputCatalog("Default", "dummy", "dummy"); if ((res = inputCatalog.InitCheck()) != B_OK) { fprintf(stderr, "couldn't construct catalog %s - error: %s\n", inputFile, strerror(res)); exit(-1); } if ((res = inputCatalog.ReadFromFile(inputFile)) != B_OK) { fprintf(stderr, "couldn't load input-catalog %s - error: %s\n", inputFile, strerror(res)); exit(-1); } DefaultCatalog* inputCatImpl = dynamic_cast<DefaultCatalog*>(inputCatalog.CatalogAddOn()); if (!inputCatImpl) { fprintf(stderr, "couldn't access impl of input-catalog %s\n", inputFile); exit(-1); } // now walk over all entries in input-catalog and dump them to // stdout DefaultCatalog::CatWalker walker; if ((res = inputCatImpl->GetWalker(&walker)) != B_OK) { fprintf(stderr, "couldn't get walker for input-catalog %s - error: %s\n", inputFile, strerror(res)); exit(-1); } BString str, ctx, cmt; while(!walker.AtEnd()) { const CatKey &key(walker.GetKey()); key.GetStringParts(&str, &ctx, &cmt); printf("Hash:\t\t%ld\nKey:\t\t<%s:%s:%s>\nTranslation:\t%s\n-----\n", key.fHashVal, str.String(), ctx.String(), cmt.String(), walker.GetValue()); walker.Next(); } int32 count = inputCatalog.CountItems(); if (count) fprintf(stderr, "%ld entr%s dumped\n", count, (count==1 ? "y": "ies")); else fprintf(stderr, "no entries found\n"); return res; }
BCatalogAddOn * DefaultCatalog::Create(const char *signature, const char *language) { DefaultCatalog *catalog = new(std::nothrow) DefaultCatalog("", signature, language); if (catalog && catalog->InitCheck() != B_OK) { delete catalog; return NULL; } return catalog; }
BCatalogAddOn * DefaultCatalog::Instantiate(const char *signature, const char *language, uint32 fingerprint) { DefaultCatalog *catalog = new(std::nothrow) DefaultCatalog(signature, language, fingerprint); if (catalog && catalog->InitCheck() != B_OK) { delete catalog; return NULL; } return catalog; }
BCatalogData * DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, uint32 fingerprint) { DefaultCatalog *catalog = new(std::nothrow) DefaultCatalog(catalogOwner, language, fingerprint); if (catalog && catalog->InitCheck() != B_OK) { delete catalog; return NULL; } return catalog; }