小编Dom*_*sko的帖子

c ++一次读入一个c字样的字符串?

在c ++ id中,喜欢一次将一个字符读入一个c样式的字符串.如何在不首先创建具有设置大小的字符数组的情况下执行此操作(您不知道用户将输入多少个字符).既然你无法调整数组的大小,那怎么办呢?我正在考虑这些问题,但这不起作用.

char words[1];
int count = 0;

char c;
while(cin.get(c))
{
    words[count] = c;
    char temp[count+1];
    count++;
    words = temp;
    delete[] temp;
}
Run Code Online (Sandbox Code Playgroud)

c c++ c-strings cin

5
推荐指数
1
解决办法
2040
查看次数

Flutter 中的 Firebase 复杂查询

我正在使用 Firebase 中存储有关产品信息的集合。以前,我只是获取所有产品,然后在客户端对它们应用过滤器。有人告诉我,我需要通过查询应用这些过滤器,以减少 Firebase 需要的读取次数,因为会有大量产品。

我曾尝试将多个 .where() 语句链接在一起,但这不会产生我需要的效果,我在另一篇文章中读到多个 .orderBy() 语句会破坏查询,但为了检查其他字段,例如price 输出告诉我我需要先 orderBy() 价格。可以应用任意数量的这些过滤器,或者它们都不能应用,具体取决于设置。我在一个单独的函数中使用底部的 lastVisible 变量作为 .startAfter 以获得更多产品。有什么方法可以产生我想要通过这种方式进行的查询吗?我还想知道是否可以执行类似 .where('field', isEqualTo: x or y or z) 的操作。

    Query productQuery = Firestore.instance.collection('Products');

    if(selectedCategories != null)
    for(int i = 0; i < selectedCategories.length; i++)
      productQuery = productQuery.where('category', isEqualTo: selectedCategories[i]);

    if(minPrice > 0 && maxPrice > 0)
    {
      productQuery = productQuery.orderBy('price').where('price', isGreaterThanOrEqualTo: minPrice).where('price', isLessThanOrEqualTo: minPrice);
    }
    else if(minPrice > 0)
      productQuery = productQuery.orderBy('price').where('price', isGreaterThanOrEqualTo: minPrice);

    else if(maxPrice > 0)
      productQuery = productQuery.orderBy('price').where('price', isLessThanOrEqualTo: maxPrice);

    if(!showUnavailableItems) …
Run Code Online (Sandbox Code Playgroud)

dart firebase flutter google-cloud-firestore

5
推荐指数
1
解决办法
4751
查看次数

标签 统计

c ×1

c++ ×1

c-strings ×1

cin ×1

dart ×1

firebase ×1

flutter ×1

google-cloud-firestore ×1