Esempio n. 1
0
int main()
{
  std::ifstream movie_data("data4movies.txt");
  std::ifstream customer_data("data4customers.txt");
  std::ifstream action_data("data4commands.txt");

  if(!movie_data) {
    std::cout << "data4movies.txt could not be opened\n";
    return 1;
  }

  if(!customer_data) {
    std::cout << "data4customers.txt could not be opened\n";
    return 1;
  }

  if(!action_data) {
    std::cout << "data4commands.txt could not be opened\n";
    return 1;
  }

  Store store;

  store.AddMovies(movie_data);
  store.AddCustomers(customer_data);
  store.ProcessActions(action_data);

  return 0;
}
int main()
{
	Store s;
	std::set<std::string> vstring;
	vstring.insert(".");
	vstring.insert("e:/sample");
	int count = 0;
	value v1;
	auto viter = vstring.begin();
	v1.push_back(viter);
	s.getMap()["venk2.txt"] = v1;
	value v2;
	v1.push_back(viter++);
	s.getMap()["venk1.txt"] = v2;
	std::vector<std::map<key, value>::iterator> mapiters;
	std::vector<std::map<key, value>::iterator> mapitersmatch;
	auto miter = s.getMap().begin();	
	mapiters.push_back(miter);
	mapiters.push_back(miter++);
	std::vector<std::string> patts;
	patts.push_back("ven");
	TextSearch Tsearch(s);
	mapitersmatch = Tsearch.getFiles(patts, mapiters);
	for (unsigned int i = 0; i < mapitersmatch.size(); i++)
	{
		for (auto liter = mapitersmatch[i]->second.begin(); liter != mapitersmatch[i]->second.end(); liter++)
		{
			std::cout << "\n" << FileSystem::Path::fileSpec(**liter, mapitersmatch[i]->first) << "\n";
		}
	}
	/*Tsearch.searchText(mapiters, "simple");*/
}
Esempio n. 3
0
Store Store::operator= (const Store & rhs)
{
	if(this == &rhs)
	{
		return *this;
	}
	delete[] _storeName;
	_storeName = NULL;
	delete[] _showcase;
	_showcase = NULL;

	if (rhs._storeName != NULL)
	{
		_storeName = new char[strlen(rhs.getStoreName()) + 1];
		strcpy(_storeName, rhs.getStoreName());
	}

	_productCount = rhs.getProductCount();
	
	_showcase = new Product[_productCount];
	for(int i = 0; i < _productCount; i++)
	{
		_showcase[i] = rhs._showcase[i];
	}
	
	return *this;
}
Esempio n. 4
0
Store* City::robStore() {
	REQUIRE(properlyInitialized(), "Object 'City' was not properly properlyInitializedialized when calling robStore()");

	bool success = false;
	Store* ptr;
	int loops = 0;

	while (!success) {
		std::list<Store>::iterator it = stores.begin();
		int randomInt = rand()% stores.size();
		for (int i = 0; i < randomInt; i++) {
			it++;
		}

		ptr = &(*it);
		if (ptr->getState() == normal) {
			success = true;
		}
		if (loops == 100){
			return NULL;
		}
		loops++;
	}

	ptr->setState(beingrobbed);

	ENSURE(ptr->getState() == beingrobbed, "robStore() did not cause a robbery.");

	return ptr;
}
Esempio n. 5
0
File: ntcc.hpp Progetto: ptal/ntcc
 virtual std::unique_ptr<Program> internal_run(Store& store)
 {
   store.declare(var, domain);
   std::unique_ptr<Program> residual = program->internal_run(store);
   store.unstack(var);
   return residual;
 }
Esempio n. 6
0
QString
StoreLookup::lookupById(Id store_id)
{
    Store loc;
    if (store_id != INVALID_ID && _quasar->db()->lookup(store_id, loc))
	return loc.name();
    return "";
}
Esempio n. 7
0
void StoresManagementSystem::getAllStores(StoreIndex const &index, std::vector<Store::RefT> &stores) const {
	assert(index.isHardpoint());
	Store *store = index.valid() ? m_Hardpoints.at(index.hardpoint())->getStore() : 0;
	if (store) {
		stores.push_back(store);
		if(store->asRack()) store->asRack()->getChildren(stores, true);
	}
}
Esempio n. 8
0
File: store.cpp Progetto: ideawu/sdb
Store* Store::open(const std::string &path){
	if(!file_exists(path)){
		mkdir(path.c_str(), 0744);
	}
	Store *ret = new Store();
	ret->_path = path;
	ret->load_file_seqs();
	return ret;
}
Esempio n. 9
0
void Storage::resize(const Store &other )
{
  setCapacity( other.capacity() );

  for( auto& goodType : good::all() )
  {
    setCapacity( goodType, other.capacity( goodType ) );
  }
}
	DataSnapshot::Ptr getCurrentSelection()
	{
		int row = list.getSelectedRow();
		Store* s = Store::getInstance();

		if (!s || row < 0 || row > s->size()) return nullptr;

		return s->get(row);
	}
Esempio n. 11
0
File: main.cpp Progetto: CCJY/coliru
	Store<Args...> operator()(const Args&...  args)
	{
		auto helper = [](auto... param) {
			Store<decltype(param)...> stream;
			using List = int[];
			(void)List{ 0, ((void)(stream.add(param)), 0) ... };
			return stream;
		};
		return helper(args...);
	}
void InventoryStoreQueryResponse::parseNormalResponse() {
    parseError();
    if (responseParser->hasName("store_list")) {
        QList<Parser *> listParser = responseParser->getListObjectParser("store_list");
        Parser *parser;
        foreach (parser, listParser) {
            Store tmp;
            tmp.setParser(parser);
            tmp.parseResponse();
            storeList.append(tmp);
        }
Esempio n. 13
0
void calc(Store& s, char* store_fname, int order){
	s.open(store_fname);
	if (!s.is_init()){
		wcerr << "Store is not initialized, initializing..." << endl;
		s.init();
		wcerr << "Store initialized!" << endl;
	}

	double H = s.entropy(order);

	wcout << H << endl;

}
Esempio n. 14
0
void MenuSupport::addProductToAllStores()
{
	Product* localProduct = getProductWithUserChoise();
	const char* const productName = localProduct->getProductName();

	StoreCountType storeCount = _shoppingStores->getStoreCount();
	for (StoreCountType i = 0; i < storeCount; i++)
	{
		Store* store = _shoppingStores->getStoreAtIndex(i);
		store->addProduct(new Product(*localProduct));
	}
	delete localProduct;
}
Esempio n. 15
0
void
RecurringMaster::setGltx(Id gltx_id)
{
    Gltx gltx;
    _quasar->db()->lookup(gltx_id, gltx);

    Store store;
    _quasar->db()->lookup(gltx.storeId(), store);

    _type->setText(gltx.dataTypeName());
    _number->setText(gltx.number());
    _store->setText(store.name());
    _date->setText(DateValcon().format(gltx.postDate()));

    Card card;
    _quasar->db()->lookup(gltx.cardId(), card);
    _card->setText(card.nameFL());

    if (_curr.cardGroup() == INVALID_ID) {
	_cardLabel->setChecked(true);
    } else {
        _groupLabel->setChecked(true);
    }

    if (_lastPost->getDate().isNull()) {
	_lastPost->setDate(gltx.postDate());
	slotRefresh();
    }

    switch (gltx.dataType()) {
    case DataObject::INVOICE:
	_cardLabel->setText(tr("Customer:"));
	_groupLabel->setEnabled(true);
	_group->setEnabled(true);
	_groupLookup->type->setCurrentItem(Group::typeName(Group::CUSTOMER));
	break;
    case DataObject::RECEIVE:
	_cardLabel->setText(tr("Vendor:"));
	_groupLabel->setEnabled(true);
	_group->setEnabled(true);
	_groupLookup->type->setCurrentItem(Group::typeName(Group::VENDOR));
	break;
    default:
	_cardLabel->setText(tr("Card:"));
	_groupLabel->setEnabled(false);
	_group->setEnabled(false);
    }

    _curr.setGltxId(gltx_id);
}
Esempio n. 16
0
int main()
{
    Student g= {1000, 23};  //声明Student类型结构体变量的同时赋以初值
	 Store<int> S1, S2;   //声明两个Store<int>类对象,其中数据成员item为int类型
	 Store<Student> S3;//声明Store<Student>类对象S3,其中数据成员item为Student类型
	 Store<double> D;   //声明Store<double>类对象D,其中数据成员item为double类型
	 S1.PutElem(3);    //向对象S1中存入数据(初始化对象S1)
    S2.PutElem(-7);   //向对象S2中存入数据(初始化对象S2)
    cout<<S1.GetElem()<<"  "<<S2.GetElem()<<endl;  //输出对象S1和S2的数据成员
	 S3.PutElem(g); //向对象D中存入数据(初始化对象D)
    cout <<"The student id is "<<S3.GetElem().id << endl;	//输出对象S3的数据成员
    cout << "Retrieving object D  " ;
	    cout << D.GetElem() << endl;  //输出对象D的数据成员
	// 由于D未经初始化,在执行函数D.GetElement()过程中导致程序终止
}
Esempio n. 17
0
static void test_problem_text(TestCase *tc, void *data)
{
    Store *store = (Store *)data;
    IndexWriter *iw = create_iw(store);
    Document *problem_text = prep_doc();

    iw_add_doc(iw, problem_text);
    Aiequal(1, iw_doc_count(iw));
    Assert(!store->exists(store, "_0.cfs"),
           "data shouldn't have been written yet");
    iw_commit(iw);
    Assert(store->exists(store, "_0.cfs"), "data should now be written");
    iw_close(iw);
    Assert(store->exists(store, "_0.cfs"), "data should still be there");
}
Esempio n. 18
0
void PlayerData::BuildBlobData(Store db)
{
    if (mBlobData.empty())
        return;

    db.append(mBlobData.data(), mBlobData.size());
}
Esempio n. 19
0
Store* City::robStore(int x, int y){
	REQUIRE(properlyInitialized(), "Object 'City' was not properly properlyInitializedialized when calling robStore(int, int)");

	CityObjects* ptr;
	ptr = matrix.getObject(x, y);
	Store* storeptr = dynamic_cast<Store*>(ptr);
	if (storeptr->getState() != normal || storeptr->getType() != store){
		return NULL;
	}

	storeptr->setState(beingrobbed);

	ENSURE(storeptr->getState() == beingrobbed, "setFire() did not correctly set fire to the given house.");

	return storeptr;
}
Esempio n. 20
0
        void clearDynamic ()
        {
            for (std::map<int, StoreBase *>::iterator it = mStores.begin(); it != mStores.end(); ++it)
                it->second->clearDynamic();

            mNpcs.insert(mPlayerTemplate);
        }
Esempio n. 21
0
void gen(Store& s, char* store_fname, char* output_fname, int length, int order){
	ofstream ofs;
	ofs.open(output_fname);
	s.open(store_fname);

	if (!s.is_init()){
		wcerr << "Store is not initialized, initializing..." << endl;
		s.init();
		wcerr << "Store initialized!" << endl;
	}

	string txt = generate_text(s, length, order);
	replace(txt.begin(), txt.end(), '_', ' ');
	ofs << txt;
	ofs.close();
}
Esempio n. 22
0
TEST_F(ClientTest, StoreInfoSynchronous)
{
    string endpoint;
    string store_path = "simpledirectory://test/stores/00-simple";
    this->GetServer(store_path, endpoint);
    Store *store = this->GetStore(store_path);

    Client c(this->GetContext(), endpoint);

    protocol::StoreInfoV1 si;
    ASSERT_TRUE(c.GetStoreInfo(si));
    protocol::StoreInfoV1 expected;
    ASSERT_TRUE(store->StoreInfo(expected));

    ASSERT_TRUE(si.SerializeAsString() == expected.SerializeAsString());
}
Esempio n. 23
0
//---------------------------------------------------------------------------
// Perform
// Preconditions:	Movie exists, Movie Count is not 0, Customer doen't have 
//					the movie 
// Postconditions:	Customer has the movie, movie count is decremented
// Overrides Transactions virtual Perform. Before Performing the transaction
// the fucntion checks for validity. Then adds the movie to customer sets 
// performed variable to true and adds the transaction to the transaction
// list
//---------------------------------------------------------------------------
bool Borrow::Perform(Store& store)
{
	store.getInventory().Retrieve(*tempMovie, movie); 

	if (movie == NULL)
	{
		performed = false; 
		return false; 
	}

	else if (movie->getCount() < 1)
	{
		performed = false; 
		return false; 
	}

	else if (customer->HasMovie(movie))
	{
		performed = false;
		return false;
	}

	else if (!movie->DecrementCount())
		return false; 

	else
	{
		customer->AddMovie(movie); 
		performed = true; 
		customer->getTransactionList().Insert(this); 

		return true; 
	}
}
Esempio n. 24
0
void PlayerData::BuildSocialData(Store db)
{
    if (mFriendsData.empty())
        return;
    
    db.append(mFriendsData.data(), mFriendsData.size());
}
Esempio n. 25
0
//Interface handling of mouse click
void Interface::MouseClick(int x, int y, bool left)
{
    if(inRect(x,y,60,160,80,105) && stage == STAGE_MENU)
    {
        //Nova hra
        pNetwork->DoConnect();
    }
    if(inRect(x,y,60,160,130,155) && stage == STAGE_MENU)
    {
        //Konec
        exit(0);
    }
    if(inRect(x,y,10+2,10+2+2+40*(2+15),45+2,45+2+40*(2+15)) && stage == STAGE_GAME)
    {
        //Tah
        if(!gStore.IsMyTurn())
            return;

        unsigned char field_x, field_y;

        field_x = (unsigned char)(int(x-10) / int(2+15));
        field_y = (unsigned char)(int(y-45) / int(2+15));

        GamePacket data(CMSG_TURN);
        data << field_x;
        data << field_y;
        SendToServer(&data);
    }
}
Esempio n. 26
0
void MenuSupport::showProdutcsForStoreIndex(StoreCountType index) const
{
	if (_shoppingStores->getStoreCount() <= index)
		return;
	Store* store = _shoppingStores->getStoreAtIndex(index);
	printf("    %s:\n", store->getStoreName());

	ProductCountInStoreType productCount = store->getProductCount();
	if (0 == productCount)
		printf(kNoProductsStringMessage);
	for (ProductCountInStoreType i = 0; i < productCount; i++)
	{
		Product* product = store->getProductAtIndex(i);
		printf(kProductStringFormatMessage, i + 1, product->getProductName(), product->getProductPrice(), product->getProductAmount());
	}
}
Esempio n. 27
0
void PlayerData::BuildDialData(Store db)
{
    if(mDialData.empty())
        return;

    BuildDataType            (db, PlayerDataType_Dial);
    db.append(mDialData.data(), mDialData.size());
}
Esempio n. 28
0
void MenuSupport::removeProductFromAllStores()
{
	printf(kRemoveProductByOptionMessage);
	printf(kInputSymbolMessage);
	if (!getUserChoise(3))
		return;

	if (1 == _userChoise)
	{
		char* productName = inputProductName();
		StoreCountType storeCount = _shoppingStores->getStoreCount();
		for (StoreCountType i = 0; i < storeCount; i++)
		{
			Store* store = _shoppingStores->getStoreAtIndex(i);
			ProductCountInStoreType productIndex = kUndefinedProductIndex;
			while (kUndefinedProductIndex != (productIndex = store->getProductIndexByName(productName)))
			{
				store->removeProductAtIndex(productIndex);
			}
		}
		delete[] productName;
	}
	else if (2 == _userChoise)
	{
		ProductPriceType productPrice = inputProductPrice();
		StoreCountType storeCount = _shoppingStores->getStoreCount();
		for (StoreCountType i = 0; i < storeCount; i++)
		{
			Store* store = _shoppingStores->getStoreAtIndex(i);
			ProductCountInStoreType productIndex = kUndefinedProductIndex;
			while (kUndefinedProductIndex != (productIndex = store->getProductIndexByPrice(productPrice)))
			{
				store->removeProductAtIndex(productIndex);
			}
		}
	}
	else if (3 == _userChoise)
	{
		ProductAmountType productAmount = inputProductAmount();
		StoreCountType storeCount = _shoppingStores->getStoreCount();
		for (StoreCountType i = 0; i < storeCount; i++)
		{
			Store* store = _shoppingStores->getStoreAtIndex(i);
			ProductCountInStoreType productIndex = kUndefinedProductIndex;
			while (kUndefinedProductIndex != (productIndex = store->getProductIndexByAmount(productAmount)))
			{
				store->removeProductAtIndex(productIndex);
			}
		}
	}
}
Esempio n. 29
0
void PlayerData::BuildTreasureData(Store db)
{
    if (mTreasureData.empty())
        return;

    BuildDataType            (db, PlayerDataType_Treasure);
    db.append(mTreasureData.data(), mTreasureData.size());
}
Esempio n. 30
0
/**
 * 转为记录集合
 * \param record 串
 **/
void Stores::parseRecord(Stream& record)
{
#if (0)
    stream = record;
    return;
#endif
    record.reset();
    Store store;
    while(record.pickStore(store))
    {
        int index = store.getIndex();
        if (index < 0) continue;
        if (stores.size() <= index)
            stores.resize(index + 5);
        stores[index] = store;
    }
}