当前位置: 首页>>代码示例>>C++>>正文


C++ Complex_Selector类代码示例

本文整理汇总了C++中Complex_Selector的典型用法代码示例。如果您正苦于以下问题:C++ Complex_Selector类的具体用法?C++ Complex_Selector怎么用?C++ Complex_Selector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Complex_Selector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: to_string

 Selector* Contextualize::operator()(Complex_Selector* s)
 {
   To_String to_string(&ctx);
   Complex_Selector* ss = new (ctx.mem) Complex_Selector(*s);
   // ss->last_block(s->last_block());
   // ss->media_block(s->media_block());
   Compound_Selector* new_head = 0;
   Complex_Selector* new_tail = 0;
   if (ss->head()) {
     new_head = static_cast<Compound_Selector*>(s->head()->perform(this));
     ss->head(new_head);
   }
   if (ss->tail()) {
     new_tail = static_cast<Complex_Selector*>(s->tail()->perform(this));
     // new_tail->last_block(s->last_block());
     // new_tail->media_block(s->media_block());
     ss->tail(new_tail);
   }
   if ((new_head && new_head->has_placeholder()) || (new_tail && new_tail->has_placeholder())) {
     ss->has_placeholder(true);
   }
   else {
     ss->has_placeholder(false);
   }
   if (!ss->head() && ss->combinator() == Complex_Selector::ANCESTOR_OF) {
     return ss->tail();
   }
   else {
     return ss;
   }
 }
开发者ID:ChelseaBurns,项目名称:mysecondrepo,代码行数:31,代码来源:contextualize.cpp

示例2: new

 Complex_Selector* Complex_Selector::context(Context& ctx)
 {
   if (!tail()) return 0;
   if (!head()) return tail()->context(ctx);
   Complex_Selector* cpy = new (ctx.mem) Complex_Selector(pstate(), combinator(), head(), tail()->context(ctx));
   cpy->media_block(media_block());
   cpy->last_block(last_block());
   return cpy;
 }
开发者ID:Neo-NMO,项目名称:libsass,代码行数:9,代码来源:ast.cpp

示例3: append_optional_linefeed

  void Inspect::operator()(Complex_Selector* c)
  {
    Compound_Selector*           head = c->head();
    Complex_Selector*            tail = c->tail();
    Complex_Selector::Combinator comb = c->combinator();

    if (c->has_line_feed()) {
      if (!(c->has_parent_ref())) {
        append_optional_linefeed();
        append_indentation();
      }
    }

    if (head && head->length() != 0) head->perform(this);
    bool is_empty = !head || head->length() == 0 || head->is_empty_reference();
    bool is_tail = head && !head->is_empty_reference() && tail;
    if (output_style() == COMPRESSED && comb != Complex_Selector::ANCESTOR_OF) scheduled_space = 0;

    switch (comb) {
      case Complex_Selector::ANCESTOR_OF:
        if (is_tail) append_mandatory_space();
      break;
      case Complex_Selector::PARENT_OF:
        append_optional_space();
        append_string(">");
        append_optional_space();
      break;
      case Complex_Selector::ADJACENT_TO:
        append_optional_space();
        append_string("+");
        append_optional_space();
      break;
      case Complex_Selector::REFERENCE:
        append_mandatory_space();
        append_string("/");
        c->reference()->perform(this);
        append_string("/");
        append_mandatory_space();
      break;
      case Complex_Selector::PRECEDES:
        if (is_empty) append_optional_space();
        else append_mandatory_space();
        append_string("~");
        if (tail) append_mandatory_space();
        else append_optional_space();
      break;
    }
    if (tail && comb != Complex_Selector::ANCESTOR_OF) {
      if (c->has_line_break()) append_optional_linefeed();
    }
    if (tail) tail->perform(this);
    if (!tail && c->has_line_break()) {
      if (output_style() == COMPACT) {
        append_mandatory_space();
      }
    }
  }
开发者ID:4145awesome,项目名称:Mortgage_BR,代码行数:57,代码来源:inspect.cpp

示例4: Node

  Node Node::createSelector(Complex_Selector* pSelector, Context& ctx) {
    NodeDequePtr null;

    Complex_Selector* pStripped = pSelector->clone(ctx);
    pStripped->tail(NULL);
    pStripped->combinator(Complex_Selector::ANCESTOR_OF);

    return Node(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
  }
开发者ID:msecret,项目名称:libsass,代码行数:9,代码来源:node.cpp

示例5: n

  Node Node::createSelector(Complex_Selector* pSelector, Context& ctx) {
    NodeDequePtr null;

    Complex_Selector* pStripped = pSelector->clone(ctx);
    pStripped->tail(NULL);
    pStripped->combinator(Complex_Selector::ANCESTOR_OF);

    Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
    if (pSelector) n.got_line_feed = pSelector->has_line_feed();
    return n;
  }
开发者ID:0065paula,项目名称:green-seeds,代码行数:11,代码来源:node.cpp

示例6: head

 vector<Compound_Selector*> Complex_Selector::to_vector()
 {
   vector<Compound_Selector*> result;
   Compound_Selector* h = head();
   Complex_Selector* t = tail();
   if (h) result.push_back(h);
   while (t)
   {
     h = t->head();
     t = t->tail();
     if (h) result.push_back(h);
   }
   return result;
 }
开发者ID:Aleri,项目名称:assets-frontend,代码行数:14,代码来源:ast.cpp

示例7: switch

 void Output_Compressed::operator()(Complex_Selector* c)
 {
   Compound_Selector*        head = c->head();
   Complex_Selector*            tail = c->tail();
   Complex_Selector::Combinator comb = c->combinator();
   if (head) head->perform(this);
   switch (comb) {
     case Complex_Selector::ANCESTOR_OF: append_singleline_part_to_buffer(" "); break;
     case Complex_Selector::PARENT_OF:   append_singleline_part_to_buffer(">"); break;
     case Complex_Selector::PRECEDES:    append_singleline_part_to_buffer("~"); break;
     case Complex_Selector::ADJACENT_TO: append_singleline_part_to_buffer("+"); break;
   }
   if (tail) tail->perform(this);
 }
开发者ID:jrabbe,项目名称:libsass,代码行数:14,代码来源:output_compressed.cpp

示例8: switch

 void Inspect::operator()(Complex_Selector* c)
 {
   Compound_Selector*           head = c->head();
   Complex_Selector*            tail = c->tail();
   Complex_Selector::Combinator comb = c->combinator();
   if (head && !head->is_empty_reference()) head->perform(this);
   if (head && !head->is_empty_reference() && tail) append_to_buffer(" ");
   switch (comb) {
     case Complex_Selector::ANCESTOR_OF:                                        break;
     case Complex_Selector::PARENT_OF:   append_to_buffer(">"); break;
     case Complex_Selector::PRECEDES:    append_to_buffer("~"); break;
     case Complex_Selector::ADJACENT_TO: append_to_buffer("+"); break;
   }
   if (tail && comb != Complex_Selector::ANCESTOR_OF) {
     append_to_buffer(" ");
   }
   if (tail) tail->perform(this);
 }
开发者ID:2melissamahan,项目名称:mtg,代码行数:18,代码来源:inspect.cpp

示例9: roundtripTest

  void roundtripTest(const char* toTest) {

    // Create the initial selector

    Complex_Selector* pOrigSelector = NULL;
    if (toTest) {
      pOrigSelector = createComplexSelector(toTest);
    }
    
    string expected(pOrigSelector ? pOrigSelector->perform(&to_string) : "NULL");
  
    
    // Roundtrip the selector into a node and back
    
    Node node = complexSelectorToNode(pOrigSelector, ctx);
    
    stringstream nodeStringStream;
    nodeStringStream << node;
    string nodeString = nodeStringStream.str();
    cout << "ASNODE: " << node << endl;
    
    Complex_Selector* pNewSelector = nodeToComplexSelector(node, ctx);
    
    // Show the result

    string result(pNewSelector ? pNewSelector->perform(&to_string) : "NULL");
    
    cout << "SELECTOR: " << expected << endl;
    cout << "NEW SELECTOR:   " << result << endl;

    
    // Test that they are equal using the equality operator
    
    assert( (!pOrigSelector && !pNewSelector ) || (pOrigSelector && pNewSelector) );
    if (pOrigSelector) {
	    assert( *pOrigSelector == *pNewSelector );
    }

    
    // Test that they are equal by comparing the string versions of the selectors

    assert(expected == result);
    
  }
开发者ID:02002love,项目名称:ioniclub,代码行数:44,代码来源:test_node.cpp

示例10: complexSelectorToNode

  Node complexSelectorToNode(Complex_Selector* pToConvert, Context& ctx) {
    if (pToConvert == NULL) {
      return Node::createNil();
    }
    Node node = Node::createCollection();
    node.got_line_feed = pToConvert->has_line_feed();
    bool has_lf = pToConvert->has_line_feed();

    // unwrap the selector from parent ref
    if (pToConvert->head() && pToConvert->head()->has_parent_ref()) {
      Complex_Selector* tail = pToConvert->tail();
      if (tail) tail->has_line_feed(pToConvert->has_line_feed());
      pToConvert = tail;
    }

    while (pToConvert) {

      bool empty_parent_ref = pToConvert->head() && pToConvert->head()->is_empty_reference();

      if (pToConvert->head() == NULL || empty_parent_ref) {
      }

      // the first Complex_Selector may contain a dummy head pointer, skip it.
      if (pToConvert->head() != NULL && !empty_parent_ref) {
        node.collection()->push_back(Node::createSelector(pToConvert, ctx));
        if (has_lf) node.collection()->back().got_line_feed = has_lf;
        has_lf = false;
      }

      if (pToConvert->combinator() != Complex_Selector::ANCESTOR_OF) {
        node.collection()->push_back(Node::createCombinator(pToConvert->combinator()));
        if (has_lf) node.collection()->back().got_line_feed = has_lf;
        has_lf = false;
      }

      if (pToConvert && empty_parent_ref && pToConvert->tail()) {
        // pToConvert->tail()->has_line_feed(pToConvert->has_line_feed());
      }

      pToConvert = pToConvert->tail();
    }

    return node;
  }
开发者ID:0065paula,项目名称:green-seeds,代码行数:44,代码来源:node.cpp

示例11: SASS_MEMORY_NEW

  Expression* Listize::operator()(Complex_Selector* sel)
  {
    List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), 2);

    Compound_Selector* head = sel->head();
    if (head && !head->is_empty_reference())
    {
      Expression* hh = head->perform(this);
      if (hh) *l << hh;
    }

    To_String to_string;
    std::string reference = ! sel->reference() ? ""
      : sel->reference()->perform(&to_string);
    switch(sel->combinator())
    {
      case Complex_Selector::PARENT_OF:
        *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), ">");
      break;
      case Complex_Selector::ADJACENT_TO:
        *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "+");
      break;
      case Complex_Selector::REFERENCE:
        *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "/" + reference + "/");
      break;
      case Complex_Selector::PRECEDES:
        *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "~");
      break;
      case Complex_Selector::ANCESTOR_OF:
      break;
    }

    Complex_Selector* tail = sel->tail();
    if (tail)
    {
      Expression* tt = tail->perform(this);
      if (tt && tt->concrete_type() == Expression::LIST)
      { *l += static_cast<List*>(tt); }
      else if (tt) *l << static_cast<List*>(tt);
    }
    if (l->length() == 0) return 0;
    return l;
  }
开发者ID:pra85,项目名称:libsass,代码行数:43,代码来源:listize.cpp

示例12: error

  Statement* Expand::operator()(Extension* e)
  {
    To_String to_string;
    Selector_List* extender = static_cast<Selector_List*>(selector_stack.back());
    if (!extender) return 0;
    Selector_List* extendee = static_cast<Selector_List*>(e->selector()->perform(contextualize->with(0, env, backtrace)));
    if (extendee->length() != 1) {
      error("selector groups may not be extended", extendee->path(), extendee->position(), backtrace);
    }
    Complex_Selector* c = (*extendee)[0];
    if (!c->head() || c->tail()) {
      error("nested selectors may not be extended", c->path(), c->position(), backtrace);
    }
    Compound_Selector* s = c->head();

    // // need to convert the compound selector into a by-value data structure
    // vector<string> target_vec;
    // for (size_t i = 0, L = s->length(); i < L; ++i)
    // { target_vec.push_back((*s)[i]->perform(&to_string)); }

    for (size_t i = 0, L = extender->length(); i < L; ++i) {
      ctx.extensions.insert(make_pair(*s, (*extender)[i]));
      // let's test this out
      // cerr << "REGISTERING EXTENSION REQUEST: " << (*extender)[i]->perform(&to_string) << " <- " << s->perform(&to_string) << endl;
      ctx.subset_map.put(s->to_str_vec(), make_pair((*extender)[i], s));
    }
    return 0;
  }
开发者ID:A-G-F,项目名称:coda-sass-plugin,代码行数:28,代码来源:expand.cpp

示例13: nodeToComplexSelector

  Complex_Selector* nodeToComplexSelector(const Node& toConvert, Context& ctx) {
    if (toConvert.isNil()) {
      return NULL;
    }


    if (!toConvert.isCollection()) {
      throw "The node to convert to a Complex_Selector* must be a collection type or nil.";
    }


    NodeDeque& childNodes = *toConvert.collection();

    string noPath("");
    Position noPosition(-1, -1, -1);
    Complex_Selector* pFirst = new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
    Complex_Selector* pCurrent = pFirst;

    for (NodeDeque::iterator childIter = childNodes.begin(), childIterEnd = childNodes.end(); childIter != childIterEnd; childIter++) {

      Node& child = *childIter;

      if (child.isSelector()) {
        pCurrent->tail(child.selector()->clone(ctx));   // JMA - need to clone the selector, because they can end up getting shared across Node collections, and can result in an infinite loop during the call to parentSuperselector()
        pCurrent = pCurrent->tail();
      } else if (child.isCombinator()) {
        pCurrent->combinator(child.combinator());

        // if the next node is also a combinator, create another Complex_Selector to hold it so it doesn't replace the current combinator
        if (childIter+1 != childIterEnd) {
          Node& nextNode = *(childIter+1);
          if (nextNode.isCombinator()) {
            pCurrent->tail(new (ctx.mem) Complex_Selector(ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
            pCurrent = pCurrent->tail();
          }
        }
      } else {
        throw "The node to convert's children must be only combinators or selectors.";
      }
    }

    // Put the dummy Compound_Selector in the first position, for consistency with the rest of libsass
    Compound_Selector* fakeHead = new (ctx.mem) Compound_Selector(ParserState("[NODE]"), 1);
    Selector_Reference* selectorRef = new (ctx.mem) Selector_Reference(ParserState("[NODE]"), NULL);
    fakeHead->elements().push_back(selectorRef);
    pFirst->head(fakeHead);

    return pFirst;
  }
开发者ID:msecret,项目名称:libsass,代码行数:49,代码来源:node.cpp

示例14: new

 Selector* Contextualize::operator()(Complex_Selector* s)
 {
   To_String to_string;
   Complex_Selector* ss = new (ctx.mem) Complex_Selector(*s);
   if (ss->head()) {
     ss->head(static_cast<Compound_Selector*>(s->head()->perform(this)));
   }
   if (ss->tail()) {
     ss->tail(static_cast<Complex_Selector*>(s->tail()->perform(this)));
   }
   if (!ss->head() && ss->combinator() == Complex_Selector::ANCESTOR_OF) {
     return ss->tail();
   }
   else {
     return ss;
   }
 }
开发者ID:AndreasDriesen,项目名称:libsass,代码行数:17,代码来源:contextualize.cpp

示例15: new

 Selector* Contextualize::operator()(Selector_List* s)
 {
   Selector_List* p = static_cast<Selector_List*>(parent);
   Selector_List* ss = 0;
   if (p) {
     ss = new (ctx.mem) Selector_List(s->pstate(), p->length() * s->length());
     for (size_t i = 0, L = p->length(); i < L; ++i) {
       for (size_t j = 0, L = s->length(); j < L; ++j) {
         parent = (*p)[i];
         Complex_Selector* comb = static_cast<Complex_Selector*>((*s)[j]->perform(this));
         if (parent->has_line_feed()) comb->has_line_feed(true);
         if (comb) *ss << comb;
       }
     }
   }
   else {
     ss = new (ctx.mem) Selector_List(s->pstate(), s->length());
     for (size_t j = 0, L = s->length(); j < L; ++j) {
       Complex_Selector* comb = static_cast<Complex_Selector*>((*s)[j]->perform(this));
       if (comb) *ss << comb;
     }
   }
   return ss->length() ? ss : 0;
 }
开发者ID:ChelseaBurns,项目名称:mysecondrepo,代码行数:24,代码来源:contextualize.cpp


注:本文中的Complex_Selector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。